Is it possible to add dynamically constraints and/or variables to a model?
I know there is a syntax to add variable (for column generation) but in the documentation I found that “Some solvers do not expose the ability to modify a model after creation - the model must be constructed from scratch each time”
How do we know which solvers are able to modify and which ones are not?
It’s useful to look at the source code to see what’s actually going on. You’ll see that if the solver does not support adding variables, JuMP will print the following warning,
Solver does not appear to support adding variables to an existing model. JuMP's internal model will be discarded.
Or is there another way of doing it, because i’m having an issue solving an MIP with range constraints. It gives two different results for the left and right side of the equivalence i wrote. Do you have any idea why?
To clarify, JuMP does not convert range constraints into two one-sided constraints. These are passed directly to the solver. Not all solvers handle range constraints correctly, unfortunately. It’s usually safer just to replace them with an equality constraint involving a slack variable that has lower and upper bounds.
I replaced the constraint with equality one and slack variables. It gives the same results now.
To be honest, I think my problem came from solving the same problem with two different solvers : GLPKSolverMIP and CPLEX, Cplex being faster but providing a less accurate solution. The second one not handling ranged constraint, I though the difference came from a mistake translating into equality constraint.