LATTICE_POINTS & callable library

Questions and problems about using polymake go here.
soeren
Posts: 23
Joined: 12 Jul 2012, 22:25

LATTICE_POINTS & callable library

Postby soeren » 08 Aug 2014, 13:27

Hi,
I would like to compute all lattice points of a polytope via the callable library, e.g.

Code: Select all

Main pm; pm.set_application("polytope"); perl::Object p("Polytope<Rational>"); p.take("VERTICES") << (ones_vector<Rational>() | 5*unit_matrix<Rational>(4)); Matrix<Rational> latpoints = p.give("LATTICE_POINTS");
This code gives the following errors when executed:

Code: Select all

libc++abi.dylib: terminating with uncaught exception of type pm::perl::exception: unknown property Polytope<Rational>::LATTICE_POINTS at /usr/local/share/polymake/perllib/Polymake/Core/ObjectType.pm line 459. Polymake::Core::ObjectType::encode_request_element('Polymake::Core::ObjectType=ARRAY(0x1015b60e8)', 'LATTICE_POINTS', 'Polymake::polytope::Polytope__Rational=ARRAY(0x102c763c8)', undef) called at /usr/local/share/polymake/perllib/Polymake/Core/ObjectType.pm line 474 Polymake::Core::ObjectType::encode_read_request('Polymake::Core::ObjectType=ARRAY(0x1015b60e8)', 'LATTICE_POINTS', 'Polymake::polytope::Polytope__Rational=ARRAY(0x102c763c8)') called at /usr/local/share/polymake/perllib/Polymake/Core/Object.pm line 1452 Polymake::Core::Object::give_pv called at /usr/local/share/polymake/perllib/Polymake/Core/Object.pm line 1468 Polymake::Core::Object::give('Polymake::polytope::Polytope__Rational=ARRAY(0x102c763c8)', 'LATTICE_POINTS') called at [...]/polymake-beta/lib/callable/src/perl/Main.cc line 0 eval {...} called at [...]/polymake-beta/lib/callable/src/perl/Main.cc line
Strange thing is, that computing the interior lattice points works without a problem. That is, replacing the last line in the code above by

Code: Select all

Matrix<Rational> latpoints = p.give("INTERIOR_LATTICE_POINTS");
yields the desired output.

I'm using a Mac (OS X 10.9.4) and the polymake beta 2.13. I tested it on a Linux machine with polymake 2.12.5 as well and got the same errors.

blorenz
Developer
Posts: 139
Joined: 10 Jan 2011, 17:21

Re: LATTICE_POINTS & callable library

Postby blorenz » 08 Aug 2014, 15:11

The lattice points of a polytope are not a property but a user method because there is a slightly more general property LATTICE_POINTS_GENERATORS which also works for unbounded polyhedra.

You have two ways to achieve what you are trying:

Code: Select all

Array< Matrix<Rational> > lattice_point_gens(3); p.give("LATTICE_POINTS_GENERATORS") >> lattice_point_gens; // the matrix of lattice points is now in: lattice_point_gens[0]
Alternatively you can call the user_method:

Code: Select all

Matrix<Rational> Lattice_Points = p.CallPolymakeMethod("LATTICE_POINTS");
Benjamin


PS:

Code: Select all

polytope > help 'LATTICE_POINTS_GENERATORS'; objects/Polytope<Rational>/properties/Lattice Points Generators in Polytopes/LATTICE_POINTS_GENERATORS: property LATTICE_POINTS_GENERATORS : Array The lattice points generators in the polytope. The output consists of three matrices [P,R,L], where P are lattice points which are contained in the polytope R are rays and L is the lineality. Together they form a description of all lattice points. Every lattice point can be described as p + lambda*R + mu*L where p is a row in P and lambda has only non-negative integral coordinates and mu has arbitrary integral coordinates.

soeren
Posts: 23
Joined: 12 Jul 2012, 22:25

Re: LATTICE_POINTS & callable library

Postby soeren » 11 Aug 2014, 10:20

Thanks!

User avatar
gawrilow
Main Author
Posts: 423
Joined: 25 Dec 2010, 17:40

Re: LATTICE_POINTS & callable library

Postby gawrilow » 11 Aug 2014, 11:04

User methods and property retrieval look so innocently equal in the interactive shell, it doesn't come as a surprise that people are tempted to call both in the same way in C++ code. Maybe give() should gracefully fall back to method call when the property lookup fails.

User avatar
assarf
Developer
Posts: 74
Joined: 12 Oct 2011, 15:52

Re: LATTICE_POINTS & callable library

Postby assarf » 11 Aug 2014, 11:51

User methods and property retrieval look so innocently equal in the interactive shell, it doesn't come as a surprise that people are tempted to call both in the same way in C++ code. Maybe give() should gracefully fall back to method call when the property lookup fails.
+1
no signature

User avatar
joswig
Main Author
Posts: 280
Joined: 24 Dec 2010, 11:10

Re: LATTICE_POINTS & callable library

Postby joswig » 09 Sep 2014, 18:19

User methods and property retrieval look so innocently equal in the interactive shell, it doesn't come as a surprise that people are tempted to call both in the same way in C++ code. Maybe give() should gracefully fall back to method call when the property lookup fails.
Sounds good to me, too.


Return to “Helpdesk”