jump-dev / JuMP.jl

Modeling language for Mathematical Optimization (linear, mixed-integer, conic, semidefinite, nonlinear)
http://jump.dev/JuMP.jl/
Other
2.24k stars 395 forks source link

@defVar like @defExpr #616

Closed FabrizioLacalandra closed 8 years ago

FabrizioLacalandra commented 8 years ago

I don't know if this may sound silly, but have we have thought at a definition of vars that does not add this vars to the model, preatty much like @defExpr define a L cns without adding it to the model ?

Btw, any news on #606 and more importantly #595 ?

Thanks Fabrizio

mlubin commented 8 years ago

JuMP doesn't have any concept of variables that are not attached to a model. What would that mean?

FabrizioLacalandra commented 8 years ago

that can be still used in a @LinearConstraint(expr) that, in turn, is not attached to a model either...at some point in the problem generation yet. Later when you use this Lcns in a @addContraint then it is inserted in the model with its variables...

mlubin commented 8 years ago

Other modeling languages like Convex.jl and PuLP have a design where on solve() you have to ask the question "what variables are in my model?". A JuMP model is meant to be much closer to a solver's internal representation of the problem which allows us to easily manipulate the solver's representation, e.g., when adding a new constraint and resolving, we don't regenerate the whole model. I don't see this design changing any time soon.

It sounds like you want to use JuMP's syntax and expression generation infrastructure but not the JuMP model object. That's okay, but why don't you define your own variable object and collection of constraints then? I think we'd be open to generalizing the macro infrastructure so that it can be used outside of JuMP. For the case of linear constraints, it's not really difficult at all.

FabrizioLacalandra commented 8 years ago

Yes @mlubin I see, I was thinking on just a enlargement of the present design where you define bloks of cns and you want to assign to different models (in the JuMP sense) later.

mlubin commented 8 years ago

Could you give an example use case for this?

FabrizioLacalandra commented 8 years ago

At a higher level my idea is similar (but more advanced) to that of SMP http://www.maths.ed.ac.uk/~agr/SML.pdf. Here you (recursively) define blocks of cns and inside them the corrispondent variables that are therefore not used outside the block. I think that with JuMP you can do the same things also if the var are carefully defined a priori (and attached to different models), but having your hands free to define a var without attaching to a model could simplify something...i don't know if that makes sense to you.

mlubin commented 8 years ago

Are you aware of https://github.com/joehuchette/StochJuMP.jl?

FabrizioLacalandra commented 8 years ago

No, i ve seen JuMPer only (i like RO more)...but this bl = StochasticBlock(m) is something similar to what i have in mind even if not in the stochastic framework..i will give a look! Thanks

mlubin commented 8 years ago

@FabrizioLacalandra, hoping to make progress on #606 and #595 next month after some upcoming paper deadlines