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

DictModel cannot convert a JuMP model with quadratic objective #129

Open
odow opened this issue Feb 24, 2022 · 2 comments
Open

DictModel cannot convert a JuMP model with quadratic objective #129

odow opened this issue Feb 24, 2022 · 2 comments

Comments

@odow
Copy link

odow commented Feb 24, 2022

julia> using JuMP

julia> import Nonconvex

julia> Nonconvex.@load Ipopt
[ Info: Attempting to load the package NonconvexIpopt.
[ Info: Loading succesful.

julia> model = JuMP.Model();

julia> @variable(model, x >= 0)
x

julia> @objective(model, Min, x^2)
x²

julia> ncvx_model = DictModel(model)
ERROR: AssertionError: obj isa AffExpr
Stacktrace:
 [1] get_objective_info(model::JuMP.Model, nvars::Int64)
   @ NonconvexCore ~/.julia/packages/NonconvexCore/YjDSM/src/models/jump.jl:184
 [2] DictModel(model::JuMP.Model)
   @ NonconvexCore ~/.julia/packages/NonconvexCore/YjDSM/src/models/jump.jl:204
 [3] top-level scope
   @ REPL[7]:1

cc @ccoffrin

@odow
Copy link
Author

odow commented Feb 24, 2022

Adding an epigraph variable also fails:

julia> using JuMP

julia> import Nonconvex

julia> Nonconvex.@load Ipopt
[ Info: Attempting to load the package NonconvexIpopt.
[ Info: Loading succesful.

julia> model = JuMP.Model();

julia> @variable(model, x >= 0)
x

julia> @variable(model, t)
t

julia> @constraint(model, t >= x^2)
-+ t  0.0

julia> @objective(model, Min, t)
t

julia> ncvx_model = DictModel(model)
ERROR: AssertionError: obj isa AffExpr
Stacktrace:
 [1] get_objective_info(model::JuMP.Model, nvars::Int64)
   @ NonconvexCore ~/.julia/packages/NonconvexCore/YjDSM/src/models/jump.jl:184
 [2] DictModel(model::JuMP.Model)
   @ NonconvexCore ~/.julia/packages/NonconvexCore/YjDSM/src/models/jump.jl:204
 [3] top-level scope
   @ REPL[17]:1

@mohamed82008
Copy link
Member

mohamed82008 commented Feb 24, 2022

Yes currently I only support linear expressions because this is the main utility of using JuMP over Nonconvex directly to define objectives or constraints. Extending this is possible but it will need to add support for more expression types in https://github.com/JuliaNonconvex/NonconvexCore.jl/blob/master/src/models/jump.jl.

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

2 participants