pypolymake: A Sage Interface to polymake
Posted: 30 Oct 2011, 13:00
There is a new attempt to create an interface from Sage to polymake. This thread is meant to report on this development and to discuss how to proceed. To answer the obvious question of why this is not discussed in the developer's forum: the topic seems to be of interest to a wider audience, and the bulk of the development is outside polymake's code base.
Before I start I would like to express my sincere thanks to Burcin Erocal who took the lead to write this first interface. The code is available at https://bitbucket.org/burcin/pypolymake. The installation instructions below are also mostly due to him.
The setup is somewhat delicate but has been tried with sage 4.7.1 and polymake 2.9.10. While it does not work with our most recent release 2.10 Benjamin Lorenz was able to resolve this extremely subtle issue a few days ago, and the patch will appear in our next release (to be expected soon).
Here are my installation details on Ubuntu 11.04 which includes building sage. I used an additionally installed gcc 4.4 (from the Ubuntu package), since the default compiler from the 4.5 series is bogus. The newer versions of gcc 4.6.x would be another viable option.
In the sequel I assume that the sage source code has been extracted to /usr/local/sage-4.7.1. Building libatlas is very tedious and also unnecessary since it can be installed from a package.
The following updates some sage packages to versions compatible with polymake. This includes a version of polymake 2.9.10 as a sage package.
For me the following trick was neceassary:
You now should have custom made version of sage 4.7.1 up and running.
This is where the installation of pypolymake starts. The commands below require mercurial (with extension mq) to be installed. The patch itself is attached below. First we patch sage.
Now comes the actual pypolymake:
That's it.
Here is a first demo (in a sage notebook):
The above should return False. You can save objects to files which can then be processed further by polymake.
Visualization via jreality should work, too.
More fancy polymake functions can be called via passing the corresponding property as a string:
Please look into the pypolymake code for more examples.
The current pypolymake implementation has the following limitations:
Happy pypolymaking!
-- Michael
Before I start I would like to express my sincere thanks to Burcin Erocal who took the lead to write this first interface. The code is available at https://bitbucket.org/burcin/pypolymake. The installation instructions below are also mostly due to him.
The setup is somewhat delicate but has been tried with sage 4.7.1 and polymake 2.9.10. While it does not work with our most recent release 2.10 Benjamin Lorenz was able to resolve this extremely subtle issue a few days ago, and the patch will appear in our next release (to be expected soon).
Here are my installation details on Ubuntu 11.04 which includes building sage. I used an additionally installed gcc 4.4 (from the Ubuntu package), since the default compiler from the 4.5 series is bogus. The newer versions of gcc 4.6.x would be another viable option.
Code: Select all
CC=gcc-4.4; CXX=g++-4.4
SAGE64=yes
SAGE_FORTRAN=/usr/bin/gfortran-4.4
SAGE_FORTRAN_LIB=/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.4/libgfortran.so
Code: Select all
cd /usr/local/sage-4.7.1
touch spkg/installed/atlas-3.8.3.p16
make
Code: Select all
./sage -i http://sage.math.washington.edu/home/burcin/polymake/mpfi-1.5.spkg
./sage -i http://sage.math.washington.edu/home/burcin/polymake/mpfr-3.0.0.spkg
./sage -f spkg/standard/mpir-1.2.2.p2.spkg
./sage -i http://sage.math.washington.edu/home/burcin/polymake/polymake-2.9.10.p0.spkg
./sage -b
Code: Select all
cd local/lib
ln -s libmpfr.so libmpfr.so.1
cd -
This is where the installation of pypolymake starts. The commands below require mercurial (with extension mq) to be installed. The patch itself is attached below. First we patch sage.
Code: Select all
cd local/bin
hg qimport sage-env.patch
hg qpush
cd -
Code: Select all
hg clone https://bitbucket.org/burcin/pypolymake
ln -s /usr/local/sage-4.7.1/devel/sage/c_lib/include /usr/local/sage-4.7.1/local/include/sage
./sage -sh
cd pypolymake
python setup.py install
Here is a first demo (in a sage notebook):
Code: Select all
import polymake
m = matrix(QQ,[[1, 3, 0, 0], [1, 0, 3, 0], [1, 1, 1, 1], [1, 0, 0, 3], [1, 0, 0, 0], [1, 2, 2, 2]])
p = polymake.Polytope('POINTS',m)
p.is_simple()
Code: Select all
p._save("p.poly")
Code: Select all
p.visual()
Code: Select all
p._get_integer_property("CUBICALITY")
The current pypolymake implementation has the following limitations:
- The only basic polymake types supported so far are: Bool, Int, Matrix<Rational>.
- The only big object types supported so far is: Polytope<Rational>.
Happy pypolymaking!
-- Michael