Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue building EAGO and CPLex in JuMP. #56

Closed
KikivanElsen opened this issue Sep 12, 2024 · 2 comments
Closed

Issue building EAGO and CPLex in JuMP. #56

KikivanElsen opened this issue Sep 12, 2024 · 2 comments

Comments

@KikivanElsen
Copy link

KikivanElsen commented Sep 12, 2024

I wrote the following script in Julia because I want to test the piecewise-linear function for different solvers. Solvers GLPK, Gurobi and HiGHS are working. However, when I try to add EAGO and CPLEX I keep getting errors...

import Pkg
Pkg.add("JuMP")

ENV["CPLEX_STUDIO_BINARIES"] = raw"C:\Program Files\IBM\ILOG\CPLEX_Enterprise_Server1210\CPLEX_Studio\cplex\bin\x64_win64"
Pkg.add("CPLEX")
Pkg.build("CPLEX")

using JuMP, CPLEX, PiecewiseLinearOpt

m = Model(CplexSolver())
f(x) = x^2
    
@variable(m, -2 <= x <= 2)

d = [-2, -1, 0, 1, 2]
fd = f.(d)

z = piecewiselinear(m, x, d, fd)

@objective(m, Min, z) 
    
optimize!(m)

solution = (value(x), value(f(x)))
print(solution)

The error that is shown is the following:

ERROR: LoadError: Failed to precompile ForwardDiff [f6369f11-7733-5829-9624-2563aa707210] to "C:\\Users\\kikiv\\.julia\\compiled\\v1.10\\ForwardDiff\\jl_87E7.tmp".
Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:35
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
    @ Base .\loading.jl:2468
  [3] compilecache
    @ .\loading.jl:2340 [inlined]
  [4] (::Base.var"#968#969"{Base.PkgId})()
    @ Base .\loading.jl:1974
  [5] mkpidlock(f::Base.var"#968#969"{Base.PkgId}, at::String, pid::Int32; kwopts::@Kwargs{stale_age::Int64, wait::Bool})
    @ FileWatching.Pidfile C:\Users\kikiv\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\FileWatching\src\pidfile.jl:93
  [6] #mkpidlock#6
    @ C:\Users\kikiv\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\FileWatching\src\pidfile.jl:88 [inlined]
  [7] trymkpidlock(::Function, ::Vararg{Any}; kwargs::@Kwargs{stale_age::Int64})
    @ FileWatching.Pidfile C:\Users\kikiv\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\FileWatching\src\pidfile.jl:111
  [8] #invokelatest#2
    @ .\essentials.jl:894 [inlined]
  [9] invokelatest
    @ .\essentials.jl:889 [inlined]
 [10] maybe_cachefile_lock(f::Base.var"#968#969"{Base.PkgId}, pkg::Base.PkgId, srcpath::String; stale_age::Int64)
    @ Base .\loading.jl:2983
 [11] maybe_cachefile_lock
    @ .\loading.jl:2980 [inlined]
 [12] _require(pkg::Base.PkgId, env::String)
    @ Base .\loading.jl:1970
 [13] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1812
 [14] #invoke_in_world#3
    @ .\essentials.jl:926 [inlined]
 [15] invoke_in_world
    @ .\essentials.jl:923 [inlined]
 [16] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1803
 [17] macro expansion
    @ .\loading.jl:1790 [inlined]
 [18] macro expansion
    @ .\lock.jl:267 [inlined]
 [19] __require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1753
 [20] #invoke_in_world#3
    @ .\essentials.jl:926 [inlined]
 [21] invoke_in_world
    @ .\essentials.jl:923 [inlined]
 [22] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1746
 [23] include
    @ .\Base.jl:495 [inlined]
 [24] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
    @ Base .\loading.jl:2222
 [25] top-level scope
    @ stdin:3
in expression starting at C:\Users\kikiv\.julia\packages\JuMP\klrjG\src\JuMP.jl:11
in expression starting at stdin:
Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types C:\Users\kikiv\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\Types.jl:70
  [2] precompile(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; internal_call::Bool, strict::Bool, warn_loaded::Bool, already_instantiated::Bool, timing::Bool, _from_loading::Bool, kwargs::@Kwargs{io::Base.TTY})
    @ Pkg.API C:\Users\kikiv\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\API.jl:1659
  [3] precompile(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::@Kwargs{_from_loading::Bool}) 
    @ Pkg.API C:\Users\kikiv\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\API.jl:159
  [4] precompile
    @ C:\Users\kikiv\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\API.jl:147 [inlined]
  [5] #precompile#114
    @ C:\Users\kikiv\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\API.jl:146 [inlined]
  [6] #invokelatest#2
    @ .\essentials.jl:894 [inlined]
  [7] invokelatest
    @ .\essentials.jl:889 [inlined]
  [8] _require(pkg::Base.PkgId, env::String)
    @ Base .\loading.jl:1963
  [9] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1812
 [10] #invoke_in_world#3
    @ .\essentials.jl:926 [inlined]
 [11] invoke_in_world
    @ .\essentials.jl:923 [inlined]
 [12] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1803
 [13] macro expansion
    @ .\loading.jl:1790 [inlined]
 [14] macro expansion
    @ .\lock.jl:267 [inlined]
 [15] __require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1753
 [16] #invoke_in_world#3
    @ .\essentials.jl:926 [inlined]
 [17] invoke_in_world
    @ .\essentials.jl:923 [inlined]
 [18] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1746
 [19] eval
    @ .\boot.jl:385 [inlined]
 [20] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
    @ Base .\loading.jl:2076
 [21] include_string(m::Module, txt::String, fname::String)
    @ Base .\loading.jl:2086
 [22] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})
    @ Base .\essentials.jl:892
 [23] invokelatest(::Any, ::Any, ::Vararg{Any})
    @ Base .\essentials.jl:889
 [24] inlineeval(m::Module, code::String, code_line::Int64, code_column::Int64, file::String; softscope::Bool)
    @ VSCodeServer c:\Users\kikiv\.vscode\extensions\julialang.language-julia-1.120.2\scripts\packages\VSCodeServer\src\eval.jl:271
 [25] (::VSCodeServer.var"#69#74"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer c:\Users\kikiv\.vscode\extensions\julialang.language-julia-1.120.2\scripts\packages\VSCodeServer\src\eval.jl:181
 [26] withpath(f::VSCodeServer.var"#69#74"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
    @ VSCodeServer c:\Users\kikiv\.vscode\extensions\julialang.language-julia-1.120.2\scripts\packages\VSCodeServer\src\repl.jl:276
 [27] (::VSCodeServer.var"#68#73"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer c:\Users\kikiv\.vscode\extensions\julialang.language-julia-1.120.2\scripts\packages\VSCodeServer\src\eval.jl:179
 [28] hideprompt(f::VSCodeServer.var"#68#73"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
    @ VSCodeServer c:\Users\kikiv\.vscode\extensions\julialang.language-julia-1.120.2\scripts\packages\VSCodeServer\src\repl.jl:38
 [29] (::VSCodeServer.var"#67#72"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer c:\Users\kikiv\.vscode\extensions\julialang.language-julia-1.120.2\scripts\packages\VSCodeServer\src\eval.jl:150
 [30] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging .\logging.jl:515
 [31] with_logger
    @ .\logging.jl:627 [inlined]
 [32] (::VSCodeServer.var"#66#71"{VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer c:\Users\kikiv\.vscode\extensions\julialang.language-julia-1.120.2\scripts\packages\VSCodeServer\src\eval.jl:263
 [33] #invokelatest#2
    @ .\essentials.jl:892 [inlined]
 [34] invokelatest(::Any)
    @ Base .\essentials.jl:889
 [35] (::VSCodeServer.var"#64#65")()
    @ VSCodeServer c:\Users\kikiv\.vscode\extensions\julialang.language-julia-1.120.2\scripts\packages\VSCodeServer\src\eval.jl:34
in expression starting at c:\Users\kikiv\Documents\WUR\THESIS\Julia_files\Julia_EAGO_example.jl:8

In the GitHub for EAGO someone gave me the following answer:

Ah, this is because of PiecewiseLinearOpt. Adding that package will downgrade JuMP and EAGO to versions that were designed in earlier versions of Julia and likely will not work in Julia v1.10.

If you need to use PiecewiseLinearOpt with a more recent version of JuMP, you should post an issue here: https://github.com/jump-dev/PiecewiseLinearOpt.jl/issues.

Can you help me to do this?
Kind regards,
Kiki

@odow
Copy link
Member

odow commented Sep 12, 2024

Hi Kiki,

This is fortuitous timing.

PiecewiseLinearOpt was unmaintained for a number of years, and I only started reviving it two days ago. (Take a look at the commits: https://github.com/jump-dev/PiecewiseLinearOpt.jl/commits/master/).

I'll tag a new release, which should fix this: JuliaRegistries/General#115093

Once it is merged, you can update your packages.

@odow
Copy link
Member

odow commented Sep 12, 2024

The new version is released.

Here was my previous environment, with [email protected]

(eago2) pkg> st
Status `/private/tmp/eago2/Project.toml`
  [a076750e] CPLEX v1.0.3
⌅ [4076af6c] JuMP v0.23.2
  [0f51c51e] PiecewiseLinearOpt v0.4.1
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated`

Updating now gives [email protected] and [email protected] 😄

(eago2) pkg> up
    Updating registry at `~/.julia/registries/General.toml`
   Installed PiecewiseLinearOpt ─ v0.4.2
    Updating `/private/tmp/eago2/Project.toml`
  [4076af6c] ↑ JuMP v0.23.2 ⇒ v1.23.1
  [0f51c51e] ↑ PiecewiseLinearOpt v0.4.1 ⇒ v0.4.2
    Updating `/private/tmp/eago2/Manifest.toml`
  [49dc2e85] - Calculus v0.5.1
  [4076af6c] ↑ JuMP v0.23.2 ⇒ v1.23.1
  [0f51c51e] ↑ PiecewiseLinearOpt v0.4.1 ⇒ v0.4.2
Precompiling project...
  1 dependency successfully precompiled in 5 seconds. 39 already precompiled.

(eago2) pkg> st
Status `/private/tmp/eago2/Project.toml`
  [a076750e] CPLEX v1.0.3
  [4076af6c] JuMP v1.23.1
  [0f51c51e] PiecewiseLinearOpt v0.4.2

@odow odow closed this as completed Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants