[sage-support] Re: Linear Programming Error

2010-07-24 Thread tvn
thanks for the quick response ...

On Jul 22, 8:38 pm, Nathann Cohen nathann.co...@gmail.com wrote:
 This is now patch #9579, which is waiting for review :-)

 Nathann

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Linear Programming Error

2010-07-22 Thread Nathann Cohen
Hello !!

 I am trying to solve this simple linear programming prob using
 MixedIntegerLinearProgram and it gives an AttributeError:
 LinearFunction instance has no attribute '__float__' exception

This is mainly my fault, and the reason is that min/max arguments do
not like to get something different from a real value :-)

sage: p = MixedIntegerLinearProgram(maximization=True)
sage: x = p.new_variable()
sage: p.add_constraint(x[0] + x[1] , min=3)
sage: p.add_constraint(20*x[0] + 10*x[1] , max=80)
sage: p.add_constraint(x[1] - 2*x[0], max = 0) # This line has
changed !
sage: p.set_objective(2*x[0]+3*x[1])
sage: p.solve()
16.0

I will immediately send a patch so that it returns an exception
otherwise, and update the manual accordingly. There is something else
I wrote which may interest you, though :

sage: p = MixedIntegerLinearProgram(maximization=True)
sage: x = p.new_variable()
sage: p.add_constraint(x[0] + x[1] = 3) # This line has
changed !
sage: p.add_constraint(20*x[0] + 10*x[1] = 80)  # This line has
changed !
sage: p.add_constraint(x[1] = 2*x[0])   # This line has
changed !
sage: p.set_objective(2*x[0]+3*x[1])
sage: p.solve()
16.0

Note that is it (very, very slightly) slower than the min/max syntax.
I do no think it will make any difference until your Linear Programs
have several hundreds of constraints, and even then it will only slow
(if at all) the construction of the LP, not the actual solving
process.

I will also try to take the time to rewrite an up-to-date tutorial for
LP in Sage... :-)

Have fun !!!

Nathann

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Linear Programming Error

2010-07-22 Thread Nathann Cohen
This is now patch #9579, which is waiting for review :-)

Nathann

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org