I’m trying to solve an optimization problem described in the following Stats SE question:
https://stats.stackexchange.com/questions/544065/how-to-fit-data-to-a-discrete-linear-model
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?