ERROR: The provided `optimizer_constructor` is invalid

Hello everyone, I am trying to solve a math model using Alpine.jl. Given n arrays of different dimension, n constraint of strict equalities (one for each sum of the whole array i.e. sum(x)==X, sum(y)==Y, sum(z)==Z), one upper-bound constraint for the sum of the n arrays, my objective function will be to maximize the sum of the arrays.
I use Binary variables to set to 0 when a condition of equality can’t be respected.

From this code:

using Alpine, JuMP, GLPK, MadNLP, SCIP, Ipopt, Gurobi, Juniper
nlp_solver = get_ipopt() # local continuous solver
mip_solver = get_gurobi() # convex mip solver
minlp_solver = get_juniper(mip_solver, nlp_solver)
const alpine = JuMP.optimizer_with_attributes(
“minlp_solver” => minlp_solver,
#“nlp_solver” => nlp_solver,
#“mip_solver” => mip_solver,
“presolve_bt” => false,
“apply_partitioning” => true,
“partition_scaling_factor” => 10,

model = JuMP.Model(alpine)
@variable(model, x[1:9])
nx = length(x)
@variable(model, y[1:7])
ny = length(y)
@variable(model, z[1:10])
nz = length(z)
@variable(model, i[1:3, 1:max(nx, ny, nz)], Bin)
@constraint(model, sum(x’*i[1,1:nx]) == 500)
@constraint(model, sum(y’*i[2,1:ny]) == 1000)
@constraint(model, sum(z’*i[3,1:nz]) == 650)
@constraint(model, sum(x’*i[1,1:nx]) + sum(y’*i[2,1:ny]) + sum(z’*i[3,1:nz]) <= 1600)

@objective(model, Max, sum(x’*i[1,1:nx]) + sum(y’*i[2,1:ny]) + sum(z’*i[3,1:nz]))

I get this error:

ERROR: The provided optimizer_constructor is invalid. It must be callable with zero arguments. For example, “Ipopt.Optimizer” or “() → ECOS.Optimizer()”. It should not be an instantiated optimizer like “Ipopt.Optimizer()” or “ECOS.Optimizer()”. (Note the difference in parentheses!)

Can someone please help me to solve this problem?

I can’t reproduce your code because I don’t know what the get_ipopt function is, etc.

I haven’t tested locally so I might have made a typo, but something like this should work:

using JuMP, Alpine, Ipopt, Gurobi, Juniper

gurobi = optimizer_with_attributes(Gurobi.Optimizer)
ipopt = optimizer_with_attributes(Ipopt.Optimizer)
juniper = optimizer_with_attributes(
    "nl_solver" => ipopt,
    "mip_solver" => gurobi,
alpine = optimizer_with_attributes(
    "mip_solver" => gurobi,
    "nl_solver" => ipopt
    "minlp_solver" => juniper,
model = Model(alpine)
1 Like