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

@NLconstraint names #3069

Closed
3 tasks
hdavid16 opened this issue Sep 10, 2022 · 5 comments
Closed
3 tasks

@NLconstraint names #3069

hdavid16 opened this issue Sep 10, 2022 · 5 comments
Labels
Category: Nonlinear Related to nonlinear programming

Comments

@hdavid16
Copy link
Contributor

hdavid16 commented Sep 10, 2022

It's great to see that names (with indexing) can now be assigned to nonlinear constraints. The following features would be nice to have:

  • extend the @NLconstraint macro to allow the base_name kwarg as is the case in @constraint.
  • extend JuMP.name to allow accessing the name of the nonlinear constraint.
  • extend JuMP.set_name for nonlinear constraints.
@hdavid16 hdavid16 changed the title base_name for @NLconstraint @NLconstraint name Sep 10, 2022
@hdavid16 hdavid16 changed the title @NLconstraint name @NLconstraint names Sep 10, 2022
hdavid16 referenced this issue in hdavid16/DisjunctiveProgramming.jl Sep 10, 2022
@odow odow added the Category: Nonlinear Related to nonlinear programming label Sep 10, 2022
@odow
Copy link
Member

odow commented Sep 10, 2022

This is related to the MOI Nonlinear redesign. At the moment, nonlinear constraints don't exist as first-class objects, so they don't support the MOI.ConstraintName attribute, and therefore JuMP can't set their name.

So implementing this would first require jump-dev/MathOptInterface.jl#846

@odow
Copy link
Member

odow commented Sep 11, 2022

I'm going to close this as won't-fix for now. Nonlinear constraints don't have names. If/when we update MOI to have first-class nonlinear constraints, this is something that will happen naturally.

@odow odow closed this as completed Sep 11, 2022
@hdavid16
Copy link
Contributor Author

They do appear to have names now...

using JuMP
m=Model()
@variable(m,x);
@NLconstraint(m, constraint_1, exp(x) <= 1)
#exp(x) - 1.0 <= 0
m[:constraint_1]
#exp(x) - 1.0 <= 0

@odow
Copy link
Member

odow commented Sep 12, 2022

They have a symbolic identifier, but not a MOI.ConstraintName. The distinction is somewhat subtle:
https://jump.dev/JuMP.jl/stable/manual/constraints/#String-names,-symbolic-names,-and-bindings

JuMP.name is syntactic sugar for get/set of MOI.ConstraintName. There is no mechanism in JuMP or MOI for nonlinear constraints to store a String as the constraint, and you cannot look up a nonlinear constraint by a String name.

I think what you're asking for in DisjunctiveProgramming is a way to look up if a constraint has been stored in the object_dictionary, but that is orthogonal to the name discussion.

@hdavid16
Copy link
Contributor Author

ok. makes sense. Thanks for clarifying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Nonlinear Related to nonlinear programming
Development

No branches or pull requests

2 participants