On Tuesday, March 26, 2013 4:13:39 AM UTC-6, Dima Pasechnik wrote:
>
> On 2013-03-26, tvn <[email protected] <javascript:>> 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? 
>


May be I misunderstand your suggestion but the whole point is that I cannot 
simply apply p.add_constrain() to my input csts as you said.  
p.add_constraint(c) requires c to a Linear Constraint but my input is a 
list of Expressions.  So one way is to create a list of LinearConstraints 
from this list of Expressions as I originally stated - but that requires 
constructing a LinearConstraint from Expression.  

Let's try it again 

l,u = var(l,u )
csts = [l <= 15, u >= 10, l <= u]   #list of expressions
p = MIPL .... 

ok -- from here, what is the easiest way to add csts to p ?



> > 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