You could also use the LP solver in cvxopt.

http://www.sagemath.org/doc/numerical_sage/cvxopt.html

For your example problem:

sage: RealNumber=float
sage: Integer=int
sage: from cvxopt.base import matrix as m
sage: from cvxopt import solvers
sage: c = m([-1., -5.])
sage: G = m([[1., 1.5, -1., 0.], [0.2, 3., 0., -1.]])
sage: h = m([4., 4., 0., 0.])
sage: sol = solvers.lp(c,G,h)
sage: print sol['x']
sage: print -c.trans() * sol['x']

HTH!
Rick

On Dec 9, 7:28 am, hassan <hsn.zam...@gmail.com> wrote:
> Hi all
> I need to solve a LP so I have installed 'csc':
>
> sage: p.solve(solver='cbc')
>
> and then copy and paste the example 
> inhttp://www.sagemath.org/doc/reference/sage/numerical/mip.htmthat is:
>
> sage: p = MixedIntegerLinearProgram(maximization=True)
> sage: x = p.new_variable()
> sage: p.set_objective(x[1] + 5*x[2])
> sage: p.add_constraint(x[1] + 0.2*x[2], max=4)
> sage: p.add_constraint(1.5*x[1] + 3*x[2], max=4)
> sage: p.solve()
>
> and the result is:
>
> ---------------------------------------------------------------------------
> AttributeError                            Traceback (most recent call
> last)
>
> /home/hassan/<ipython console> in <module>()
>
> /home/hassan/Apps/sage-4.2.1/local/lib/python2.6/site-packages/sage/numerical/mip.so
>  in sage.numerical.mip.MixedIntegerLinearProgram.solve 
> (sage/numerical/mip.c:5059)()
>
> /home/hassan/Apps/sage-4.2.1/local/lib/python2.6/site-packages/sage/numerical/mipCoin.so
>  in sage.numerical.mipCoin.solveCoin (patch/mipCoin.cpp:595)()
>
> AttributeError: MixedIntegerLinearProgram instance has no attribute
> '_variables_type'
>
> Pleas Help!

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

Reply via email to