Use of MINLP in Julia

Hello people, all rigth?
I need to solve a nonlinear integer nonconvex problem. The objective and constraints are nonlinear functions.
First question:

  1. What the ideal package and solve to solve this problem?
  2. Is there any code-example for share with me?
  3. I found in the net the solver Juniper, able to solve these problems. The article describing this package is in:
    https://arxiv.org/pdf/1804.07332.pdf
    But, when I run this lines

using JuMP, Ipopt, Cbc, Juniper

ipopt = IpoptSolver(print_level=0);
cbc = CbcSolver()
m = Model(solver=JuniperSolver(ipopt, mip_solver=cbc))
v = [10,20,12,23,42];
w = [12,45,12,22,21]
@variable(m, 0 <= x[1:5] <= 10, Int)
@objective(m, Max, dot(v,x))
@constraint(m, sum(x[i] for i=1:5) <= 6)
@NLconstraint(m, sum(w[i]*x[i] for i=1:5) <= 300)
status = solve(m);
getvalue(x)

I have a mistake: “UndefVarError: base not defined”. This solver is very nice for my problem, but I would like to underestand this mistake.

Anyone could help me?

What the ideal package and solve to solve this problem?

JuMP! It seems like you’ve found the right place.

UndefVarError: base not defined

Do you have the full error message? It’s hard to know where this is coming from otherwise.

p.s. please read PSA: make it easier to help you, particularly about formatting code.

1 Like

Thanks for your response.
Yes, I use JUMP.
My problem is to use the package Juniper or other that solve MINLP. Do you have other suggestion and help me how to use in JUMP?

The complete message erros is the following, when I complile the code:

using JuMP
using Juniper
using Ipopt
using Cbc

solver = JuniperSolver(IpoptSolver(print_level=0);
mip_solver=CbcSolver())

m = Model(solver=solver)
v = [10,20,12,23,42]
w = [12,45,12,22,21]
@variable(m, x[1:5], Bin)
@objective(m, Max, dot(v,x))
@NLconstraint(m, sum(w[i]*x[i]^2 for i=1:5) <= 45)
status = solve(m)

Complete error message:

UndefVarError: base not defined
round at Compat.jl:1625 [inlined]
are_type_correct(::Array{Float64,1}, ::Array{Symbol,1}, ::Array{Int64,1}, ::Float64) at bb_type_correct.jl:22
fpump(::Juniper.JuniperModel) at fpump.jl:235
optimize!(::Juniper.JuniperModel) at model.jl:135
#solvenlp#165(::Bool, ::Function, ::JuMP.Model, ::JuMP.ProblemTraits) at nlp.jl:1271
(::JuMP.#kw##solvenlp)(::Array{Any,1}, ::JuMP.#solvenlp, ::JuMP.Model, ::JuMP.ProblemTraits) at :0
#solve#116(::Bool, ::Bool, ::Bool, ::Array{Any,1}, ::Function, ::JuMP.Model) at solvers.jl:172
solve(::JuMP.Model) at solvers.jl:150
include_string(::String, ::String) at loading.jl:522
include_string(::String, ::String, ::Int64) at eval.jl:30
include_string(::Module, ::String, ::String, ::Int64, ::Vararg{Int64,N} where N) at eval.jl:34
(::Atom.##102#107{String,Int64,String})() at eval.jl:82
withpath(::Atom.##102#107{String,Int64,String}, ::String) at utils.jl:30
withpath(::Function, ::String) at eval.jl:38
hideprompt(::Atom.##101#106{String,Int64,String}) at repl.jl:67
macro expansion at eval.jl:80 [inlined]
(::Atom.##100#105{Dict{String,Any}})() at task.jl:80

This is a weird error. Are you using Julia 0.6? Try running Pkg.update() and then try again.

Otherwise, upgrade to Julia 1.0. Note that Juniper hasn’t been updated to the latest version of JuMP (work is in progress https://github.com/lanl-ansi/Juniper.jl/pull/114), so you will need to run ] add JuMP#release-0.18.

Thanks. I will try to update my packages.
I will send you what happened.

SCIP.jl was recently completely revamped and brought up to speed with the latest JuMP release. I think the wrapper is in pretty good shape now. SCIP itself can be a bit challenging to install though.

I already used SCIP in matlab.
How can I use in JUMP? Do you have some idea?
Thank you for your atttention!

Well the wrapper is just over at https://github.com/SCIP-Interfaces/SCIP.jl, and it’s registered so you can just add it. If you’re having trouble installing SCIP itself, I can dig up the notes I made while installing it when I’m at my computer.

If you’re having trouble installing SCIP itself, I can dig up the notes I made while installing it when I’m at my computer.

Can you elaborate what was difficult about that?

I assumed that most users will just download the .deb or rpm packages that should work on several popular Linux distributions. I now see that there is also a self-extracting archive with precompiled binarys.
It is then a matter of setting the environment variable (e.g., in my case SCIPOPTDIR=/home/rs/opt/scip) to where the package was installed to.

If you require manual installation, for some reason, then we should make describe the steps in the README, as it was before.

If I recall correctly, the .deb file didn’t work for me because the latest released version of SCIP required a version of Ipopt that’s newer than what’s available through apt on Ubuntu 18.04, so installation failed. I don’t remember if I tried tarbalIs, but at that point I decided to build both SCIP and the latest version of Ipopt from source, also because I wanted to have SCIP use CPLEX.

Building Ipopt then required HSL from http://www.hsl.rl.ac.uk/ipopt/ (or at least that’s what my labmate told me is the fastest linear solver package). I needed to add its lib directory to LD_LIBRARY_PATH and also needed to symlink (or rename) libcoinhsl.so to libhsl.so, as that’s what Ipopt is looking for (must have been renamed at some point).

Then, for SCIP itself, I needed to edit one of their CMake files, as I was getting linking errors when using their CMake build with CPLEX. In gcg/cmake/Modules/FindCPLEX.cmake, I added dl and util to CPLEX_LIBRARIES.

After that, I built using

mkdir install
mkdir build
cd build
CC=clang-7 CXX=clang++-7 cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_TESTING=OFF -D IPOPT_DIR=/home/twan/code/ipopt/Ipopt-3.12.12 -D CPLEX=ON -D CPLEX_DIR=/opt/ibm/ILOG/CPLEX_Studio128/cplex -D CMAKE_INSTALL_PREFIX=../install ..
make -j 20
make install
1 Like

OK, that should be solved, since recent version of IPOPT (with HSL) is now actually contained in the binary packages, including the .deb package.

I see. This will require some manual setup and compilation, of course.
In that case, you might get away with only compiling SCIP (and not SoPlex, GCG, ZIMPL, etc.), so that you also won’t have to fix the GCG CMake files…

Hi, I’m the main developer of Juniper. Do you still have an issue with it? It works now with the latest version of JuMP. If you have any issues please use the GitHub issue system. Thanks for using Juniper :wink: