On 2013-03-26, tvn <[email protected]> wrote:
> ------=_Part_232_6092612.1364277288756
> Content-Type: text/plain; charset=ISO-8859-1
>
> I am trying to play around with  MixedIntegerLinearProgram but now sure how 
> to add constraints properly to it.  My input is a list of relations , e.g. 
> csts = [l <= 15, u >= 10, l <= u]  and I want to add these to the solver.   
>
> All the examples I've seen requires constructing these constraints 
> explicity (e.g. p = MixedIntegerLinearProgram(),  l = p['l'], u = p['u'], 
> p.set_objective(l-u), p.add_constraint(l <= 15), p.add_constraint(u>=10)) 
> .   I could analyze the input list of constraint to determine is 
> coeficients and variables etc and then recreate new variables and relations 
the format of your relations seems to be good enough.

All you need is to specify the variables.
(Well, how else the code is supposed to know that l is a variable, and not 
something you set to l=42
and want to keep like this?)



> but that seem too cumbersome.   Is there an easier method to feed a given 

just do

for r in csts:
   p.add_constraint(r)

or even 

map(p.add_constraint, csts)

Is it easy enough?

> list of relations as above directly to p.add_constraint() ?  

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to