compute volume using callable library

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

compute volume using callable library

Postby soeren » 10 Feb 2013, 21:36

Hi,
when I try to determine the volume of a polytope running the following code:

Code: Select all

perl::Object K; [...] Rational vol=K.give("VOLUME");
polymake throws an exception:

polymake: WARNING: could not compute 'VOLUME' probably because of unsatisfied preconditions:
precondition : CONE_DIM, CONE_AMBIENT_DIM ( VOLUME : )

The polytope K is created by handing over its vertices or facets. If I build a polytope in the polymake application in similar manner, there is no problem at all. I'm not sure what the preconditions imply (dimension of the tangent cones?).

best regards,
Sören

paffenholz
Developer
Posts: 212
Joined: 24 Dec 2010, 13:47

Re: compute volume using callable library

Postby paffenholz » 11 Feb 2013, 09:51

Volume computation in polymake requires a full-dimensional polytope, and the error message you posted suggests that your input was not. You will have to transform your polytope into a full-dimensional one.

Internally, polyhedra in polymake are represented via their homogenization (the cone over 1 x P), so the internal dimension of a polytope is the dimension of this cone, which is stored in CONE_DIM, and used for checking preconditions. CONE_AMBIENT_DIM ist the ambient dimension of the space the cone lives in. Both are just one more than the dimensions for the polytope.

Andreas

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

Re: compute volume using callable library

Postby soeren » 11 Feb 2013, 16:12

Hi Andreas,
having a not full-dimensional polytope was my initial thought. However, I tested this with polytopes which are guaranteed to be full dimensional (e.g. cube). Interestingly, polymake tells me that FULL_DIM is true and CONE_DIM as well as CONE_AMBIENT_DIM is 4 (I'm working with 3 dimensional polytopes only). However, trying to get the properties DIM or AMBIENT_DIM an exception is thrown:

Code: Select all

terminate called after throwing an instance of 'pm::perl::exception' what(): unknown property Polytope<Rational>::DIM at /usr/local/share/polymake/perllib/Polymake/Core/ObjectType.pm line 460 Polymake::Core::ObjectType::encode_request_element('Polymake::Core::ObjectType=ARRAY(0x140cd2310)', 'DIM', 'Polymake::polytope::Polytope__Rational=ARRAY(0x140c973c8)', undef) called at /usr/local/share/polymake/perllib/Polymake/Core/ObjectType.pm line 475 Polymake::Core::ObjectType::encode_read_request('Polymake::Core::ObjectType=ARRAY(0x140cd2310)', 'DIM', 'Polymake::polytope::Polytope__Rational=ARRAY(0x140c973c8)') called at /usr/local/share/polymake/perllib/Polymake/Core/Object.pm line 1369 Polymake::Core::Object::give_pv called at /usr/local/share/polymake/perllib/Polymake/Core/Object.pm line 1385 Polymake::Core::Object::give('Polymake::polytope::Polytope__Rational=ARRAY(0x140c973c8)', 'DIM') called at /Users/[...]/polymake-2.12/lib/callable/src/perl/Main.cc line 0 eval {...} called at /Users/[...]/polymake-2.12/lib/callable/src/perl/Main.cc line 0
Note, that despite the problems regarding the volume, I can compute the face lattice, vertices, facets without any problems.
I also tried this: Create a polytope in polymake and write it to a file. Then, when loading it again into polymake, everything's fine (I can compute VOLUME, DIM, AMBIENT_DIM). But loading the same file into my program, I still get the error above.

best regards,
Sören

paffenholz
Developer
Posts: 212
Joined: 24 Dec 2010, 13:47

Re: compute volume using callable library

Postby paffenholz » 11 Feb 2013, 16:32

Okay, then I will have to think about the original problem again. I can explain the exceptions though. DIM and AMBIENT_DIM are user methods, not properties. Accordingly, you should call them with CallPolymakeUserMethod in you program. They both basically return the cone dimension-1.

Andreas

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

Re: compute volume using callable library

Postby soeren » 11 Feb 2013, 16:38

Ah, I didn't knew that. And yes, both 'DIM' and 'AMBIENT_DIM' are equal to 3 (if that's helpful).

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

Re: compute volume using callable library

Postby blorenz » 11 Feb 2013, 18:12

I tried to reproduce the problem with a small callable library program (using polymake 2.12) but it computes the volume just fine.
Can you post the code which constructs your polytope ?
You can also increase the verbosity of the scheduler and rule-execution with the following commands and attach the output. Maybe this can give a hint what is going wrong.

Code: Select all

pm.set_custom("$Verbose::rules",1); pm.set_custom("$Verbose::scheduler",1);
Where pm is the polymake::Main object. You can also try 2 instead of 1 which will produce even more output.

Benjamin

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

Re: compute volume using callable library

Postby soeren » 12 Feb 2013, 22:40

I think I got it:
Using perl::Object p("Polytope<Rational>"); instead of perl::Object p("Polytope<Float>"); eliminates all errors. Why is that? Must I always use Polytope<Rational>?

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

Re: compute volume using callable library

Postby joswig » 13 Feb 2013, 10:46

Must I always use Polytope<Rational>?
Well, if you want to get exact results: yes. However, I should also point out that there are other exact data types, such as QuadraticExtension<Rational>.

The data type Polytope<Float> must be used with care since the combinatorics of such polytopes might not be correct (a sad fact which is, however, unavoidable). Some algorithms might fail (giving errors difficult to analyze) on Polytope<Float> objects. These are mainly useful for visualization purposes.

paffenholz
Developer
Posts: 212
Joined: 24 Dec 2010, 13:47

Re: compute volume using callable library

Postby paffenholz » 13 Feb 2013, 13:50

I am still not able to reproduce your specific error.

Yet, even if we would get you beyond the precondition check (which maybe is not related to VOLUME but to a precondition of some rule executed prior to VOLUME on your specific input), volume computation would not work for polytopes with float coordinates due to a known bug in the corresponding function polymake would call (we need a triangulation of the polytope, and that currently fails for float coordinates).

There are also much less properties available for polytopes with float coordinates, and less rules applicable to the few properties defined (and, they are probably also less tested...), so unless you really have to use float you should stick to Rational. If you use the perpetual beta you could also use QuadraticExtension as your field.

Best
Andreas


Return to “Helpdesk”