-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
completing variable indices #105
Comments
That's not really feasible with the current way that variables are handled. The easiest workaround is to use a different name for the 0-index variable. |
You can also change the lower bounds after definition:
|
That also works but is less pretty. At some point we might allow you to say that a given vector of variables is constrained to be in the Lorentz cone. |
Definitely, once we get block structures we can do all kinds of cool things |
This is now possible with, e.g. julia> @defVar(m, x[1,1:2])
x[i,j], for all i in {1}, j in {1..2} free
julia> x[1,0] = @defVar(m, foo >= 0)
foo
julia> x[1,0]
foo We could potentially make it work so that you could do @defVar(m, x[1,1:2])
@defVar(m, x[1,0] >= 0) and have things work as expected, but it's not clear that that's the best behavior (though many people seem to expect this kind of behavior). |
This seems to be a pretty common point of confusion with users, but I don't think we can address it cleanly yet. Let's not publicize the fact that you can add variables to JuMPContainers. |
Yep, I intentionally left it off the docs. We can only add variables to JuMPDicts, also, which makes things even more confused. Staged functions will also help make the code to potentially do this a bit cleaner. |
Coming back to this, I think there's no way that we can support the semantics for adding variables to
then a user coming from AMPL and similar AMLs could expect that |
OTOH, the name |
That being said, the only really compelling case I've seen for appending elements to a JuMPDict is @juan-pablo-vielma example with the Lorentz cone. In the case of column generation, I think using Julia containers instead is probably a better idea. We could bypass this by having build-in cone definitions ( |
Is this resolved? Should we add support for |
Should be like 10 lines of code, can add once someone asks. |
The following code fails in the last command.
m = Model()
@defvar(m,x[1,1:2])
@addConstraint(m,x[1,1]+x[1,2]<=1)
@defvar(m,x[1,0]>=0)
@addConstraint(m,x[1,1]+x[1,2]+x[1,0]<=1)
ERROR: key not found: 1
in getindex at dict.jl:515
in getindex at no file
This code could be useful when dealing with socp constraints. There is an easy fix bellow, but adding new indices as above could be useful (if it is feasible).
m = Model()
@defvar(m,x[1,i=0:2]>= ( i == 0 ? 0 : -Inf))
@addConstraint(m,x[1,1]+x[1,2]<=1)
@addConstraint(m,x[1,1]+x[1,2]+x[1,0]<=1)
The text was updated successfully, but these errors were encountered: