Ask Your Question
0

Sage 4.6.2: how to use CPLEX

asked 2011-03-05 11:37:01 -0500

updated 2011-04-28 12:17:55 -0500

I've just upgraded from 4.6 to 4.6.2. The COIN and CPLEX backends were included (in .../devel/sage-main/sage/numerical/backends), but I can't find a way to import them. The line

lp = MixedIntegerLinearProgram(solver="GLPK");

works, but solver="Coin" and solver="CPLEX" lead to messages that the corresponding _backend module is not found. I tried a few blind guesses to import them but had not luck. The docs seem to be a lap behind (the help for MixedIntegerLinearProgram says the CPLEX interface is not implemented yet, but that COIN's is; on the other hand, asking for help for sage.numerical.backends.xxxx_backend works for xxxx=glpk but not for xxxx=coin or cplex).

Does anybody know the correct incantation?

TIA, Paul

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted
1

answered 2011-04-23 07:54:28 -0500

you can install CPLEX Python interface as a "plain" Python package in Sage's python, following the standard instructions for installing CPLEX Python's interface, replacing calls (if I recall right, you need to run "python setup.py" in some directory) to python with "sage -python", which will invoke Sage's python interpreter. Then it will be available within Sage (you'd need to do the usual CPLEX Python stuff to call it, though).

edit flag offensive delete link more
1

answered 2011-04-27 08:56:43 -0500

As Mike said it earlier, CBC (Coin) and CPLEX are not included in Sage by default. When you install Sage, GLPK is the only solver available and used.

What Sage does contain, however, are backends to GLPK CBC and CPLEX so that you can use them when they are available.

Coin is free, so you can install it by a spkg, but CPLEX is proprietary and you need a license if you want to use it. CPLEX is very expensive, but you can get a free license (without restriction on the size of problems you want to solve, or the number of threads) though IBM's Academic Initiative.

By default, Sage use Cplex if it is available. If not, then is uses CBC. If it is not available, GLPK is used. And you shouldn't have to import backends manually for a normal use of LP in Sage (it may be interesting to do so if you want to use solver-specific functions, though).

edit flag offensive delete link more
1

answered 2011-03-05 12:24:26 -0500

In order to use the COIN solver within Sage you have to have the cbc pacakge installed. It can be easily installed with :

sage -i cbc

After the cbc package installed, run

sage -br

to build the new backend module for COIN. Then, you'll be able to run

lp = MixedIntegerLinearProgram(solver="Coin")

CPLEX is a little trickier, but there is documentation you can find documentation at http://www.sagemath.org/doc/thematic_tutorials/linear_programming.html#installing-cplex .

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2011-03-05 11:37:01 -0500

Seen: 1,157 times

Last updated: Apr 27 '11
{"cc_re__cc_re__cc_by_sa_3_0_le": ["by Sage</a> </p> <p> <a href=\"/question/30366/best_known_objective_bound/\">best_known_objective_bound()</a> </p> <p> <a href=\"/question/10535/optimization-of-boolean-evaluation/\">Optimization of boolean evaluation</a> </p> <p> <a href=\"/question/23603/need-help-finding-maximum-values-over-3-d-parameters/\">Need help finding maximum values over 3-d parameters?</a> </p> </div> </div> </div> </div> <!-- template footer.html --> <div id=\"ground\"> <div class=\"content-wrapper\"> <div class=\"copyright\"> <a href=\"http://creativecommons.org/licenses/by-sa/3.0/legalcode\"> <img\n                            class=\"license-logo\"\n                            src=\"/m/default/media/images/cc-by-sa.png?v=19\"\n                            title=\"cc-by-sa\"\n                            alt=\"cc-by-sa\"\n                        /> </a>\n                \n                Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a <a href=\"http://creativecommons.org/licenses/by-sa/3.0/legalcode\">Creative Commons Attribution Share", "wrapper\"> <div class=\"copyright\"> <a href=\"http://creativecommons.org/licenses/by-sa/3.0/legalcode\"> <img\n                            class=\"license-logo\"\n                            src=\"/m/default/media/images/cc-by-sa.png?v=19\"\n                            title=\"cc-by-sa\"\n                            alt=\"cc-by-sa\"\n                        /> </a>\n                \n                Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a <a href=\"http://creativecommons.org/licenses/by-sa/3.0/legalcode\">Creative Commons Attribution Share Alike 3.0</a> license.\n\n            </div> <div class=\"footer-links\" > <a href=\"/about/\">about</a><span class=\"link-separator\"> |</span> <a href=\"/faq/\">faq</a><span class=\"link-separator\"> |</span> <a href=\"/help/\" title=\"help\">help</a> <span class=\"link-separator\"> |</span> <a href=\"/privacy/\">privacy policy</a><span class=\"link-separator\"> |</span> <a href=\"/terms/\">terms of service</a> </div> <div class=\"powered-link\"> <a href=\"http://askbot.com\" target=\"_b"], "copyright__copyright__copyright": ["MixedIntegerLinearProgram(solver=\"Coin\")\n\nCPLEX is a little trickier, but there is documentation you can find documentation at http://www.sagemath.org/doc/thematic_tutorials/linear_programming.html#installing-cplex .\n\nedit flag offensive delete link more\n\nYour Answer\n\nPlease start posting anonymously - your entry will be published after you log in or create a new account.\n\nAdd Answer\n\nQuestion Tools\n\n1 follower\n\nStats\n\nAsked: 2011-03-05 11:37:01 -0500\n\nSeen: 1,157 times\n\nLast updated: Apr 27 '11", "MixedIntegerLinearProgram(solver=\"Coin\")\n\nCPLEX is a little trickier, but there is documentation you can find documentation at http://www.sagemath.org/doc/thematic_tutorials/linear_programming.html#installing-cplex .\n\nedit flag offensive delete link more\n\nYour Answer\n\nPlease start posting anonymously - your entry will be published after you log in or create a new account.\n\nAdd Answer\n\nQuestion Tools\n\n1 follower\n\nStats\n\nAsked: 2011-03-05 11:37:01 -0500\n\nSeen: 1,157 times\n\nLast updated: Apr 27 '11"]}