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

Support JuMP.@constraint #4

Open
lassepe opened this issue Feb 2, 2021 · 2 comments
Open

Support JuMP.@constraint #4

lassepe opened this issue Feb 2, 2021 · 2 comments

Comments

@lassepe
Copy link

lassepe commented Feb 2, 2021

First of all, thank you for making SNOPT available in Julia!

I was able to run the JuMP example in example/hs72.jl. However, I am not able to run an equivalent formulation in which the last constraint is encoded via JuMP.@constraint rather than JuMP.@NLconstraint:

import JuMP
import SNOPT7


m = JuMP.Model(JuMP.optimizer_with_attributes(
        SNOPT7.Optimizer,
        "print_level" => 0,
        "system_information" => "yes",
))

JuMP.@variable(m, 1 <= x[i = 1:4] <= 5)
JuMP.@NLobjective(m, Min, x[1] * x[4] * (x[1] + x[2] + x[3]) + x[3])
JuMP.@NLconstraint(m, x[1] * x[2] * x[3] * x[4] >= 25)
JuMP.@constraint(m, sum(el -> el^2, x) == 40)

JuMP.optimize!(m)

println(JuMP.value.(x))

objval = JuMP.objective_value(m)
println("Final objective: $objval")

println(JuMP.termination_status(m))

I am getting the following error message (truncated)

ERROR: LoadError: `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.EqualTo{Float64}` constraints are not supported and cannot be bridged into supported constrained variables and constraints. See details below:
 [1] constrained variables in `MOI.RotatedSecondOrderCone` are not supported because:
   Cannot use `MOIB.Variable.RSOCtoSOCBridge{Float64}` because:
   [2] constrained variables in `MOI.SecondOrderCone` are not supported
   Cannot use `MOIB.Variable.RSOCtoPSDBridge{Float64}` because:
   [5] constrained variables in `MOI.PositiveSemidefiniteConeTriangle` are not supported
   Cannot add free variables and then constrain them because:
   (9) `MOI.VectorOfVariables`-in-`MOI.RotatedSecondOrderCone` constraints are not supported
 [2] constrained variables in `MOI.SecondOrderCone` are not supported because:
   Cannot use `MOIB.Variable.SOCtoRSOCBridge{Float64}` because:
   [1] constrained variables in `MOI.RotatedSecondOrderCone` are not supported
   Cannot add free variables and then constrain them because:
   (11) `MOI.VectorOfVariables`-in-`MOI.SecondOrderCone` constraints are not supported
 [5] constrained variables in `MOI.PositiveSemidefiniteConeTriangle` are not supported because no added bridge supports bridging it.
   Cannot add free variables and then constrain them because:
   (18) `MOI.VectorOfVariables`-in-`MOI.PositiveSemidefiniteConeTriangle` constraints are not supported
 (1) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.EqualTo{Float64}` constraints are not supported because:
   Cannot use `MOIB.Constraint.VectorizeBridge{Float64,MOI.VectorQuadraticFunction{Float64},MOI.Zeros,MOI.ScalarQuadraticFunction{Float64}}` because:
   (2) `MOI.VectorQuadraticFunction{Float64}`-in-`MOI.Zeros` constraints are not supported
   Cannot use `MOIB.Constraint.SplitIntervalBridge{Float64,MOI.ScalarQuadraticFunction{Float64},MOI.EqualTo{Float64},MOI.GreaterThan{Float64},MOI.LessThan{Float64}}` because:
[...]

Tl;DR
Is it not possible to use any JuMP.@contraint calls with SNOPT7.jl; i.e. do I have to convert all of them to JuMP.@NLconstraint? If so, are there any plans to support JuMP.@constraint in the future?

@gnowzil
Copy link
Contributor

gnowzil commented Feb 3, 2021

Hi, I think this is in-line with the JuMP documentation (https://jump.dev/JuMP.jl/v0.21.1/nlp). "Note that the @objective and @constraint macros (and corresponding functions) do not currently support nonlinear expressions."

I haven't kept up with recent JuMP developments though so if this isn't accurate, I can look into updating to support @constraint.

@lassepe lassepe changed the title Working with JuMP.@constraint Support JuMP.@constraint Feb 3, 2021
@lassepe
Copy link
Author

lassepe commented Feb 3, 2021

Hi, thank you for your quick reply!

Hi, I think this is in-line with the JuMP documentation (https://jump.dev/JuMP.jl/v0.21.1/nlp). "Note that the @objective and @constraint macros (and corresponding functions) do not currently support nonlinear expressions."

I think the use of the term "nonlinear" is a bit confusing in the JuMP documentation. JuMP allows affine and quadratic expressions in @constraint and @objective. Thus, the formulation above should be valid. In fact, Ipopt and other JuMP enabled solvers are able to solve this problem.

I haven't kept up with recent JuMP developments though so if this isn't accurate, I can look into updating to support @constraint.

It would certainly be good to have support for @constraint and @objective in SNOPT7.jl because they are perhaps the main workhorses in JuMP at the moment. Unfortunately, I am not too familiar with the backend of either JuMP or SNOPT7 at this point. However, I'd be happy to help with the implementation of this feature if you can provide some rough guidance of what would be needed for this.

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