Installing PuLP within Sage

46 views
Skip to first unread message

Louis

unread,
Apr 26, 2011, 11:35:29 AM4/26/11
to pulp-or...@googlegroups.com
I spent some time getting PuLP to run within Sage (http://www.sagemath.org), and since I know that someday I’ll want to do this again, I’m posting this here so I can find.  Note that it is entirely possible that some of these instructions are redundant and/or unnecessary, but it does work now.

Note that there are two obvious alternatives.  Sage comes with a MixedIntegerLinearProgram class, but I don’t think that it is usable outside of Sage which limits its utility.  I also tried Pyomo, but I’m having trouble reading in an AMPL style data file within Sage (because Sage keeps on trying to parse it as Python code and complains)

1.  Rebuild setuptools

In a temporary directory
wget http://peak.telecommunity.com/dist/ez_setup.py,
/path.to.sage/local/bin/lib/python ez_setup.py

(note: important to use the sage installation of Python, so it points to the correct site-packages directories for use within Sage)

2.  Add Sage python site-packages directory to PYTHONPATH
PYTHONPATH=$PYTHONPATH:~/apps/sage-4.6.2/local/lib/python2.6/site-packages
export PYTHONPATH

3.  Install solvers (i.e. cbc)
>sage -i cbc-2.3.p2     

(look at http://www.sagemath.org/packages/optional/ for the current version number.  Note that glpk is installed as a standard package within Sage.  I have not tried gurobi or CPLEX.  I also suspect that since I have GLPK and the Coin packages installed on my Ubuntu machine, it could be picking those up instead of using the included GLPK and CBC)


4.  Install PuLP
>/path.to.sage/local/bin/lib/easy_install -d /path.to.sage/local/lib/python2.6/site-packages pulp-or

5.  Because you installed packages, build and install modified packages
>sage -b

At this point, I can run PuLP examples using CBC (COINMP_DLL) or GLPK within the Sage notebook. 

Stuart Mitchell

unread,
Apr 26, 2011, 4:57:11 PM4/26/11
to pulp-or...@googlegroups.com
Thanks very much.

I'll have to experiment with this myself.

Stu

> --
> You received this message because you are subscribed to the Google Groups
> "pulp-or-discuss" group.
> To post to this group, send email to pulp-or...@googlegroups.com.
> To unsubscribe from this group, send email to
> pulp-or-discu...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pulp-or-discuss?hl=en.
>

--
Stuart Mitchell
PhD Engineering Science
Freelance Programmer and Optimisation Expert
www.stuartmitchell.com

Reply all
Reply to author
Forward
0 new messages