JuliaConstraints / CPLEXCP.jl

Julia interface for CPLEX CP Optimizer
MIT License
3 stars 1 forks source link

Java configuration in Ubuntu 20.04 and CPLEX 20.1 #5

Open IgnacioRubioScola opened 2 years ago

IgnacioRubioScola commented 2 years ago

Before running correctly the Readme example I had to do some JavaCall.jl related configurations for Ubuntu and CPLEX:

1) add in the java.library.path the path _/opt/ibm/ILOG/CPLEX_Studio201/opl/bin/x86-64linux/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/ibm/ILOG/CPLEX_Studio201/opl/bin/x86-64_linux/

2) set the environment variable JULIA_COPY_STACKS=1 before running Julia

dourouc05 commented 2 years ago

The first point should be achieved by calling cpo_java_init (at least, that's sufficient on Windows). Did you do it?

For the second one, I understand that it is no more required for recent versions of Julia (hence the requirement for Julia 1.5), that's strange, because you seem to use 1.6 :/. What kind of errors do you get without this setting?

IgnacioRubioScola commented 2 years ago

I got the following errors with cpo_java_init

julia> using CPLEXCP
┌ Warning: JavaCall needs the environment variable `JULIA_COPY_STACKS` to be `1` or `yes`.
│ Calling the JVM may result in undefined behavior.
└ @ JavaCall ~/.julia/packages/JavaCall/tjlYt/src/JavaCall.jl:53
julia> cpo_java_init()
┌ Warning: JVM already initialised. This call has no effect
└ @ JavaCall ~/.julia/packages/JavaCall/tjlYt/src/jvm.jl:155
ERROR: JavaCall.JavaCallError("JVM already initialised")

The second problem is relate to VSCode terminal, because i got the following error

ERROR: JavaCall.JavaCallError("Either the environmental variable JULIA_COPY_STACKS must be 1 OR JavaCall must be used on the root Task.")
Stacktrace:
assertroottask_or_goodenv at /home/ign/.julia/packages/JavaCall/tjlYt/src/jvm.jl
jfield(typ::Type{JavaCall.JavaObject{Symbol("ilog.cp.IloCP\$ConflictStatus")}}, field::String, fieldType::Type) at /home/ign/.julia/packages/JavaCall/tjlYt/src/core.jl
JavaCPOModel at /home/ign/.julia/packages/CPLEXCP/jbgSe/src/api_java.jl
CPLEXCP.Optimizer() at /home/ign/.julia/packages/CPLEXCP/jbgSe/src/MOI/wrapper.jl
top-level scope at /home/ign/Test.jl

but in a linux terminal it runs well without "JULIA_COPY_STACKS=1" but with a Warning:

┌ Warning: JavaCall needs the environment variable `JULIA_COPY_STACKS` to be `1` or `yes`.
│ Calling the JVM may result in undefined behavior.
└ @ JavaCall ~/.julia/packages/JavaCall/tjlYt/src/JavaCall.jl:53