Wikunia / ConstraintSolver.jl

ConstraintSolver in Julia: Blog posts ->
https://opensourc.es/blog/constraint-solver-1
MIT License
136 stars 14 forks source link

(n+1)th variable is not a bounded integer #82

Closed metanoid closed 3 years ago

metanoid commented 4 years ago

I have a JuMP model where all variables are bounded and type Int (I had some Bin variables, and changed them to be Int with 0 lower bound and 1 upper bound, but that does not help).

If I run v = JuMP.all_variables(model) on my model then v has length 15272.

So the following error message is very strange:


julia> optimize!(model)
ERROR: Each variable must be an integer and bounded. Currently the variable index 15273 doesn't fulfill this requirements.
Stacktrace:
 [1] check_var_bounds at C:\Users\username\.julia\packages\ConstraintSolver\qrqj1\src\MOI_wrapper\variables.jl:23 [inlined]
 [2] optimize!(::ConstraintSolver.Optimizer) at C:\Users\username\.julia\packages\ConstraintSolver\qrqj1\src\MOI_wrapper\MOI_wrapper.jl:79
 [3] optimize!(::MathOptInterface.Bridges.LazyBridgeOptimizer{ConstraintSolver.Optimizer}) at C:\Users\username\.julia\packages\MathOptInterface\izyVf\src\Bridges\bridge_optimizer.jl:239
 [4] optimize!(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at C:\Users\username\.julia\packages\MathOptInterface\izyVf\src\Utilities\cachingoptimizer.jl:189
 [5] #optimize!#78(::Bool, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Model, ::Nothing) at C:\Users\username\.julia\packages\JuMP\MsUSY\src\optimizer_interface.jl:141
 [6] optimize! at C:\Users\colin37\.julia\packages\JuMP\MsUSY\src\optimizer_interface.jl:111 [inlined] (repeats 2 times)
 [7] top-level scope at none:0

I don't understand what I might be doing wrong, so I'm logging this in the hope that my mistake is obvious to someone else.

Wikunia commented 4 years ago

Can you provide a minimum working example with the model?

Wikunia commented 4 years ago

i.e do you create the variables in one go or one after another?

Wikunia commented 4 years ago

Did you maybe have all different constraints of the form:

@constraint(model, x in CS.AllDifferentSet(y))

and y was bigger than the length of x?

metanoid commented 4 years ago

I did not, but I can try that.

On Mon, Mar 9, 2020 at 5:04 PM Ole Kröger notifications@github.com wrote:

Did you maybe have all different constraints of the form:

@constraint(model, x in CS.AllDifferentSet(y)

and y was bigger than the length of x?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Wikunia/ConstraintSolver.jl/issues/82?email_source=notifications&email_token=ABZOZLHLH4SU777DXDS7WHDRGUARJA5CNFSM4KUS6HCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOHTDHQ#issuecomment-596586910, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZOZLAVE7GGIQD2PF533VTRGUARJANCNFSM4KUS6HCA .

Wikunia commented 4 years ago

Now AllDifferent is a bit easier and should be written as: @constraint(model, x in CS.AllDifferentSet())

Wikunia commented 3 years ago

Can happen in a variety of different cases and is normally because something isn't supported by the solver directly. In that case bridges might be used which sometimes create additional unbounded variable (or continuous variables). Those are not supported by my ConstraintSolver but I don't have the option to tell the bridge layer about this.