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

Assertion failure while solving MINLPs with fixed variables using AmplNLWriter #523

Closed
ashwincarvalho opened this issue Aug 11, 2015 · 2 comments

Comments

@ashwincarvalho
Copy link

Originally posted here

This piece of code gives me an assertion failure:

using JuMP, AmplNLWriter

x0 = 1.0   # continuous fixed variable value

m = Model(solver=BonminNLSolver())
@defVar(m, x == x0)
@defVar(m, y, Bin)
@setNLObjective(m, Min, x*y)
solve(m)

Error message:

ERROR: assertion failed: all(x->begin  # /Users/Ashwin/.julia/v0.3/AmplNLWriter/src/AmplNLWriter.jl, line 195:
            $(Expr(:in, :x, :([:Cont,:Bin,:Int])))
        end,cat)
 in setvartype! at /Users/Ashwin/.julia/v0.3/AmplNLWriter/src/AmplNLWriter.jl:195
 in _buildInternalModel_nlp at /Users/Ashwin/.julia/v0.3/JuMP/src/nlp.jl:543
 in buildInternalModel at /Users/Ashwin/.julia/v0.3/JuMP/src/solvers.jl:623
 in solve at /Users/Ashwin/.julia/v0.3/JuMP/src/solvers.jl:39
 in include at /Applications/Juno.app/Contents/Resources/app/julia/lib/julia/sys.dylib
 in include_from_node1 at /Applications/Juno.app/Contents/Resources/app/julia/lib/julia/sys.dylib
 in reload_path at loading.jl:152
 in reload at loading.jl:85
while loading /Users/Ashwin/Documents/GitHub/Ashwin/Research/Research/MIPLaneChange/testBonminAmplSolve2.jl, in expression starting on line 10

I was able to resolve that by using the Variable() method to specify the variable category:

x = Variable(m, x0, x0, :Cont)

Another workaround suggested by @mlubin :

@defVar(m, x0 <= x <= x0)

If no binary variables are involved, fixed continuous variables defined by the @defvar macro work fine. Eg:

@defVar(m, x == x0)
y = 1.0
@setNLObjective(m, Min, x*y)

This is not a problem when I call Bonmin via CoinOptServices. Using BonminNLSolver() or CouenneNLSolver() gives the assertion failure.

@tkelman
Copy link
Contributor

tkelman commented Aug 11, 2015

I do explicitly translate :Fixed variables to continuous inside CoinOptServices, here https://github.com/JuliaOpt/CoinOptServices.jl/blob/cc73be365583c6acc969869c5238776494960cfa/src/translations.jl#L64

I think there was a fix at some point to prevent fixed variables from leaking out of JuMP, but it may have gotten broken (or never fixed in the first place?) for MINLP's. I might be wrong but I don't think any of the MINLP tests currently have any fixed variables.

@mlubin mlubin closed this as completed in 4b4c463 Aug 11, 2015
@mlubin
Copy link
Member

mlubin commented Aug 11, 2015

@tkelman, :Fixed isn't defined in the MPB interface. You should be able to remove that special case now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants