Code: Select all
# load the lp file
$pf = lp2poly("test.lp");
# polymake cannot compute integer points with float coordinates so we convert it
$pr = convert_to<Rational>($pf);
# the next line is to make the following one faster due to a bug in polymake
$pr->FACETS;
# take the integer points and define a new polytope with these as input points
$ih = integer_hull($pr);
# print the facets of the integer hull
print $ih->FACETS;
Dear kisas,
First note that all core algorithms in polymake are written in C or C++, the perl shell provides an easy interface that still comes with the efficiency of the compiled code running in the background.
This means that you can do:And all important computations, i.e. computing convex hulls and integer points, are done in C/C++ code and there is no need to write C++ code yourself.Code: Select all
# load the lp file $pf = lp2poly("test.lp"); # polymake cannot compute integer points with float coordinates so we convert it $pr = convert_to<Rational>($pf); # the next line is to make the following one faster due to a bug in polymake $pr->FACETS; # take the integer points and define a new polytope with these as input points $ih = integer_hull($pr); # print the facets of the integer hull print $ih->FACETS;
Writing your own C++ client code is recommended if you implement larger algorithms and the documentation can be found here. You can take any C++ client that comes with polymake as an example and you do not need a Makefile as any .cc file in apps/polytope/src is compiled automatically if you run make in the main polymake folder.
Regards
Benjamin
I'm afraid, it seems to be not completely true. When you look into the LPparser perl class, you'll see a "prefix" option there defaulting to "x". It suggests that all variables in fact should be named xNNN, because the deeper parsing code simply strips off the prefix and uses the rest as an index.... how you name your variables does not matter. Polymake should still parse the lp-file.
Hey,
I do not know if I understood you right. But how you name your variables does not matter. Polymake should still parse the lp-file. And the names of your variables will be stored in the property COORDINATE_LABELS.
Regards
Benjamin
EDIT: but anyway you should only use proper lp-code. You might want to check: http://lpsolve.sourceforge.net/5.5/lp-format.htm
you said: "lp files have variable names only starting with 'x'"
As far as I know this is not true. Where did you get this information?
I'm afraid, it seems to be not completely true. When you look into the LPparser perl class, you'll see a "prefix" option there defaulting to "x". It suggests that all variables in fact should be named xNNN, because the deeper parsing code simply strips off the prefix and uses the rest as an index.... how you name your variables does not matter. Polymake should still parse the lp-file.
Our LPparser is quite aged, maybe it is still following an ancient syntactic rule for LP files, while the naming convention has been relaxed in the meanwhile?
It would not be overly hard to teach the parser to accept arbitrary variable names, but it has still to be done.
Or it's already there but I am too dumb to recognize it?