Jump.jl: 'fixate' function for convenience

Created on 12 Dec 2016  Â·  8Comments  Â·  Source: jump-dev/JuMP.jl

In some problem formulations, for example MPC problems, it would be convenient to be able to specify the state variables as
@variable(m, x[1:5])
and then fix x[1,1] to some given initial value. Currently, it is achievable through setlowerbound(x[1,1],x_init) and setupperbound(x[1,1],x_init), but I also found that by allowing :Fixed in setcategory I was able to do

@variable(m, x[1:5])
setcategory(x[1,1],:Fixed)
setvalue(x[1,1],1)

which on print yields

Subject to
 x[1] = 1
 x[2] free
 x[3] free
 x[4] free
 x[5] free

Would it be possible to allow for this behavior for convenience and readability? for example through some fixate function:

function fixate(v::Variable, val::Number)
    v.m.colVal[v.col] = val
    v.m.colCat[v.col] = :Fixed
    v.m.colLower[v.col] = val
    v.m.colUpper[v.col] = val
end

Most helpful comment

I'm open to a PR. Maybe JuMP.fix?

All 8 comments

I'm not opposed to this, though I'm not crazy about the name. @mlubin?

I'm open to a PR. Maybe JuMP.fix?

Would it make more sense as a macro or as a function ?

I don't see much value in the additional complexity of using a macro.

Has anybody done something? If not, I volunteer... the function was even written in this post...

Go for it!

On Tue, Dec 20, 2016 at 12:11 PM -0500, "Joaquim Dias Garcia" notifications@github.com wrote:

Has anybody done something? If not, I volunteer... the function was even written in this post...

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

@joaquimg I was planning to do it but I didn't find the time :( Thanks !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mlubin picture mlubin  Â·  8Comments

dourouc05 picture dourouc05  Â·  7Comments

matbesancon picture matbesancon  Â·  5Comments

Thuener picture Thuener  Â·  7Comments

mlubin picture mlubin  Â·  5Comments