Who wants to try the first version of Coin-Or for SAGE ?!

5 views
Skip to first unread message

Nathann Cohen

unread,
Jul 9, 2009, 12:36:35 PM7/9/09
to sage-devel
Hello everybody !!!

After a discussion from a few days ago where I asked for people
interested in a LP Solver in SAGE, I began to write what I could of
it. I have now what seems to be a "minimal" interface between SAGE and
Clp/Cbc( the Coin-or LP Solver and Branch and Bound solver,
respectively ). It uses CBC to solve Linear programs with or without
integer values, and it is now for me the easiest way to use a LP
solver, as I had to generate Cplex or MPS files before to use GLPK or
Cbc...

There are probably a lot of errors, of mistakes, of necessary
modifications which would improve the code. I have never been writing
code for anyone else except myself, so there is bound to be a lot of
things to criticize. I would also like those of you who are interested
in a good implementation of a LP solver in SAGE to try this code,
because I will continue to implement the interface by addings features
to it and it would be better if I avoid now a big mistake I did not
see which would have to be corrected later ;-)

You will find two TRAC tickets for this, the first being a SPKG for
CBC :
http://trac.sagemath.org/sage_trac/ticket/6501

and the second the patch needed to use it :
http://trac.sagemath.org/sage_trac/ticket/6502

Once you will have the two installed, you can try to solve a simple
"maximal independant set problem" with those lines :

g=graphs.RandomGNP(10,.5)

p=MIP(max=True)

obj={}
for i in g.vertices():
obj["V"+str(i)]=1
p.setinteger("V"+str(i))
p.setobj(Constraint(obj,obj=True))
for (a,b,c) in g.edges():
obj={}
obj["V"+str(a)]=1
obj["V"+str(b)]=1
p.addconstraint(Constraint(obj,lt=1))
p.solve()

I hope those who already used LP solvers will find the notations
natural.

Thank you !!! ;-)

Nathann

Robert

unread,
Jul 10, 2009, 2:07:50 PM7/10/09
to sage-devel
I am still missing equality constraints. Sure, you can just add 2
inequalities, but since CoinPackedVector seems to support lower and
upper bounds for each row, why not set them directly? Otherwise I'm
quite satisfied, after playing around a bit.
Reply all
Reply to author
Forward
0 new messages