Currently I’m using the COSMO.jl solver, with the following function defining and solving the model:
function solve_linear_program(perc_drops::Vector{Float64}, omega::Float64)
# NOTE: see - http://lpsolve.sourceforge.net/5.1/absolute.htm (Objective function - minimization and sign is positive or maximization and sign is negative)
model = Model(with_optimizer(COSMO.Optimizer))
@variable(model, x[1:length(perc_drops)] >= 0, Int)
@variable(model, X[1:length(perc_drops)] >= 0, Int)
@constraint(model, omega*x - perc_drops .>= X)
@constraint(model, perc_drops - omega*x .>= X)
@objective(model, Min, sum(X))
optimize!(model)
end
The function above is effectively a port of the working Python code I already had, which used PuLP, and the CBC solver by default. However, when compiling I get the following error:
ERROR: LoadError: `MOI.SingleVariable`-in-`MOI.Integer` constraints are not supported and cannot be bridged into supported constrained variables and constraints. See details below:
[2] constrained variables in `MOI.Integer` are not supported because no added bridge supports bridging it.
Cannot add free variables and then constrain them because:
(6) `MOI.SingleVariable`-in-`MOI.Integer` constraints are not supported
(6) `MOI.SingleVariable`-in-`MOI.Integer` constraints are not supported because:
Cannot use `MOIB.Constraint.ScalarFunctionizeBridge{Float64, MOI.Integer}` because:
(7) `MOI.ScalarAffineFunction{Float64}`-in-`MOI.Integer` constraints are not supported
(7) `MOI.ScalarAffineFunction{Float64}`-in-`MOI.Integer` constraints are not supported because:
Cannot use `MOIB.Constraint.ScalarSlackBridge{Float64, MOI.ScalarAffineFunction{Float64}, MOI.Integer}` because:
[2] constrained variables in `MOI.Integer` are not supported
What exactly does the above error mean? Is the limitation due to JuMP, its dependency library MathOptInterface or the COSMO solver that I’m using? Or perhaps I’m just not using the library correctly?
Alternatively, do you have any suggestions for solvers that support integer programming and are written in pure Julia without dependencies in another language?
I tried the custom installation instructions for Cbc.jl again, and it’s working now. It probably would’ve worked before too, but what happened was I got confused by the error output from running Pkg.add("Cbc"), which I’m guessing still tries to use the CBC library that comes from Julia’s package repository, despite ENV["JULIA_CBC_LIBRARY_PATH"] being set. However, with Pkg.build("Cbc"), the user’s custom CBC library path gets picked up, and the build succeeds, allowing using Cbc to work too.
Hi @jyscao, could you share to us how you set ENV["JULIA_CBC_LIBRARY_PATH"]?
Edit: I solved it. Very long way as Cbc require v2.10.0
julia
import Pkg
Pkg.rm("Cbc")
exit()
sudo cd /usr/local/lib
sudo curl -LO https://github.com/coin-or/Cbc/archive/refs/tags/2.10.0.tar.gz
sudo tar -xvzf 2.10.0.tar.gz
cd Cbc-releases-2.10.0
sudo ./configure
make
sudo make install
julia
ENV["JULIA_CBC_LIBRARY_PATH"] = "/usr/local/lib/Cbc-releases-2.10.0/lib"
import Pkg
Pkg.build("Cbc")
using Cbc
Sadly, using Pkg.add("Cbc") will fails in Mac M1. I’m using it as part as PandaModels. It is reported on Pythonpandapower bug in [bug] Failed to precompile PandaModels on Mac M1 · Issue #2417 · e2nIEE/pandapower · GitHub. Thanks for the HIGHS.jl recommendation. Currently I’m only using Ipopt.jl though. I’ve read about HIGHS since a long time ago but haven’t look at it yet.
Thanks @odow. Sadly, I’m not the one to decide that as I only use and partly contributing to pandapower. I will raise Issue there so that pandapower should migrate PandaModels to use HiGHS by default instead of Cbc.