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

MOI.initialize and sub solvers #269

Open
odow opened this issue Sep 30, 2024 · 0 comments
Open

MOI.initialize and sub solvers #269

odow opened this issue Sep 30, 2024 · 0 comments

Comments

@odow
Copy link
Collaborator

odow commented Sep 30, 2024

There's an issue somewhere with how we initialize the sub solver. See jump-dev/Convex.jl#706

The MWE of @CaG21 is:

using Convex, Juniper, ECOS
const MOI = Convex.MOI

w = [23; 31; 29; 44; 53; 38; 63; 85; 89; 82]
C = 165
p = [92; 57; 49; 68; 60; 43; 67; 84; 87; 72];
n = length(w)
x = Variable(n, BinVar)
problem = maximize(dot(p, x), dot(w, x) <= C)
opt = MOI.OptimizerWithAttributes(Juniper.Optimizer,
    "nl_solver" => MOI.OptimizerWithAttributes(ECOS.Optimizer, MOI.Silent() => true))
solve!(problem, opt)

gives the error

ERROR: LoadError: MathOptInterface.AddConstraintNotAllowed{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.Nonnegatives}: Adding `MathOptInterface.VectorAffineFunction{Float64}`-in-`MathOptInterface.Nonnegatives` constraints cannot be performed: MatrixOfConstraints does not allow modifications to be made to the model once
`MOI.Utilities.final_touch` has been called. This is called at the end of
`MOI.copy_to` and in `MOI.Utilities.attach_optimizer` (which is called by
`MOI.optimize!` in a `MOI.Utilities.CachingOptimizer`). In order to be able to
apply modifications to this model, you should add a layer
`MOI.Utilities.CachingOptimizer(MOI.Utilities.Model{Float64}(), model)`
where `model` is the current model. This will automatically empty `model` when
modifications are done after `MOI.Utilities.final_touch` is called and copy the
model again in `MOI.Utilities.attach_optimizer`.
 You may want to use a `CachingOptimizer` in `AUTOMATIC` mode or you may need to call `reset_optimizer` before doing this operation if the `CachingOptimizer` is in `MANUAL` mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant