2

would you please help me in this error . ERROR: Solver does not support discrete variables.

for example in the following code

using JuMP,CPUTime, Distributions, Ipopt
#parameters--------------------------------------------------------
sig=0.86;
#---------------------------------------------------------------------------
ALT=Model(solver=IpoptSolver());
# variables-----------------------------------------------------------------
f(x) = cdf(Normal(0, 1), x);
JuMP.register(ALT, :f, 1, f; autodiff = true);
@variable(ALT, h >= 0);
@variable(ALT, L >= 0);
@variable(ALT, n, Int);
#-------------------------------------------------------------------
@NLexpression(ALT,k7,1-f(L-sig*sqrt(n))+f(-L-sig*sqrt(n)));
#constraints--------------------------------------------------------
@NLconstraint(ALT, f(-L) <= 1/400);
#-------------------------------------------------------------------
@NLobjective(ALT, Min, 1/k7)
solve(ALT)

How is it possible to solve the problem? Thanks very much.

Soma
  • 743
  • 6
  • 19

1 Answers1

2

The full list of JuMP solvers and their capabilities with regard to model types is availabe here https://jump.dev/JuMP.jl/dev/installation/

According to this list the following solver support mixed-integer nonlinear programming:

  • KNITRO.jl
  • Juniper.jl
  • SCIP.jl

There is also worth noting Alpine.jl from Los Alamos not mentioned in JuMP docs.

I recommend trying to start with Juniper.jl. Since it is using heuristics and other solvers you Model line could look like this:

m = Model(optimizer_with_attributes(Juniper.Optimizer, "nl_solver"=>optimizer_with_attributes(Ipopt.Optimizer, "print_level" => 0), "mip_solver"=>optimizer_with_attributes(Cbc.Optimizer, "logLevel" => 0)))
Przemyslaw Szufel
  • 40,002
  • 3
  • 32
  • 62
  • Thabks very much. would you please help me more. can I use Gurobi or Cplex instead Cbc? . How can I apply the solver for version JuliaPro 0.6.4.1? Im really thankful for your kindly helps. – Soma Aug 20 '20 at 08:03
  • 1
    Yes you can - those solvers are just parameters for Juniper's heuristics. Regarding Julia version you can assume that anything older than 1.0 will just not work with the current package ecosystem - you need a newer version of JuliaPro. – Przemyslaw Szufel Aug 20 '20 at 08:57