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

@LinearConstraint with syntiax as @addConstraint #595

Closed
FabrizioLacalandra opened this issue Oct 3, 2015 · 3 comments
Closed

@LinearConstraint with syntiax as @addConstraint #595

FabrizioLacalandra opened this issue Oct 3, 2015 · 3 comments

Comments

@FabrizioLacalandra
Copy link

@LinearConstraint(expr) (as well as @QuadConstraint(expr))
does not enable the full expressive power of
@addConstraint(m::Model, con)

or that of
@defExpr(ref, expr)

so that the following does not work
MyLCns = @LinearConstraint([i=1:2:4], x[i]+x[i+1] <=1)

It could be useful to have the same expressive power also for @LinearConstraint to define a (linear/quadratic) constraint without addint it to the model. Later one could get the coefficient of the linear constraints and manipulate them

Fabrizio

@mlubin
Copy link
Member

mlubin commented Oct 3, 2015

It shouldn't be hard to get this working:

@LinearConstraint(MyLCns[i=1:2:4], x[i]+x[i+1] <=1)

My only concern is that it could be confusing to someone reading the model how this differs from @addConstraint. What about @defLinearConstraint for consistency with @defExpr?

@FabrizioLacalandra
Copy link
Author

Totally agree, in fact it is a def of a cns. My final goal is to have this things working
MyLCns.terms.vars

@mlubin
Copy link
Member

mlubin commented Nov 20, 2019

See @build_constraint. We don't have the one-line version that constructs a JuMP container given index sets. If this is needed, please open a new issue.

@mlubin mlubin closed this as completed Nov 20, 2019
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

2 participants