Page 1 of 1

Creating polytope - unsatisfied preconditions

Posted: 01 Jun 2016, 15:43
by seriousstuff
Hello everyone,
I have a file with a list of polytopes given by their vertices. I try do some simple calculations on them, but it does not work yet. I wrote a comment to note, where the error occurs. I cannot read the vertices, instead I get the error message:
}
polymake: WARNING: could not compute 'VERTICES' probably because of unsatisfied preconditions:
precondition : RAYS | INPUT_RAYS | LINEALITY_SPACE | INPUT_LINEALITY | INEQUALITIES | FACETS | EQUATIONS | LINEAR_SPAN ( CONE_AMBIENT_DIM : )
precondition : INPUT_RAYS | RAYS ( FACETS, LINEAR_SPAN : )
Can anybody help me find my mistake? I also added the file that gets read.

Code: Select all

open( INPUT, "< neighb.txt" ) or die "Can't open $filename: $!"; while (my $line = <INPUT> ) { chomp $line; $line=substr $line, 6, -2; #removes the unneccessary stuff and prepares parsing $line="\[\[1,".join ("\], \[1, ",split(/\], \[/, $line))."\]\]"; #parses the vertices and adds a 1 for the homogenous coordinate my $points; eval('$points=new Matrix<Rational>('.$line.');'); #creates matrix with the coordinates in it my $p=new Polytope<Rational>(POINTS=>$points); print $p->VERTICES; #here is where I get the error message #$p=polarize(center($p))->TWO_FACE_SIZES; #this does not work as well, when I delete the line above #my $s=0;foreach(1..20){ # $s+=$p->{$_} if $_!=4; #}; #print $s/9; print "\n"; } close(INPUT);

Code: Select all

0: [[-123984206864/2768850730773, -101701330976/922950243591, -64154618668/2768850730773, -2748446474675/2768850730773], [-11083969050/98314591817, -4717557075/98314591817, -32618537490/98314591817, -91960210208/98314591817], [-9690950/554883199, -73651220/554883199, 1823050/554883199, -549885101/554883199], [-5174928/72012097, 5436288/72012097, -37977984/72012097, 60721345/72012097], [-19184/902877, 26136/300959, -21472/902877, 899005/902877], [53511524/1167061933, 88410344/1167061933, 621795064/1167061933, 982203941/1167061933], [4674489456/83665171433, -4026061312/83665171433, 28596876672/83665171433, -78383796375/83665171433], [857794884940/98972360190089, -10910202223200/98972360190089, 2974263671400/98972360190089, -98320463346111/98972360190089]] 1: [[-1002945720/30187053481, -3059834400/30187053481, -1228096800/30187053481, -29989689719/30187053481], [-39421800/3581181049, -432445200/3581181049, -64866780/3581181049, -3554164751/3581181049], [-3447600/44369069, 3381300/44369069, -27350960/44369069, 34600869/44369069], [-611618/7662509, -379358/7662509, -2140663/7662509, -7322132/7662509], [-1050/84439, 8550/84439, -1260/84439, 83989/84439], [10890/189967, 15246/189967, 114048/189967, 150763/189967], [3042000/61794121, -3120000/61794121, 14601600/61794121, -59885879/61794121], [173660563125/15757451586458, -1598265860625/15757451586458, 59871546525/15757451586458, -15675110339167/15757451586458]] 2: [[-430629/14864582, -376119/14864582, -376119/14864582, -14848819/14864582], [-381312/570703313, -47330352/570703313, 63107136/570703313, -565225135/570703313], [-90/5843, 300/5843, -1575/5843, 5618/5843], [-24/281, 48/281, -180/281, 209/281], [18/157, 18/157, 135/157, 76/157], [6768/320341, -159048/1601705, 212064/1601705, -315851/320341], [54144/1284005, -106032/1284005, 212064/1284005, -1260763/1284005], [7489200/93635641, -2275200/93635641, 35948160/93635641, -86105159/93635641]]

Re: Creating polytope - unsatisfied preconditions

Posted: 01 Jun 2016, 17:23
by gawrilow
The input parsing can be simplified, since the input lines are already in valid perl/polymake-compliant format. You just have to append a column with homogeneous 1's:

Code: Select all

$line =~ s/^\d+://; # remove the line number my $points=new Matrix<Rational>(eval $line); my $p=new Polytope<Rational>(POINTS => (ones_vector<Rational>()) | $points); # make homogeneous coordinates print "POINTS:\n", $p->POINTS; # verify the correctness of input parsing print "VERTICES:\n", $p->VERTICES;
BTW, your mistake is superfluous backslashes in front of square brackets in strings (as opposed to regular expressions).

Re: Creating polytope - unsatisfied preconditions

Posted: 15 Jun 2016, 14:15
by seriousstuff
Thank you very much for your quick help.
Unfortunately, it still cannot compute the vertices and the centering does not work. I do not get any error message for the output, but a warning and no vertices or points behind the "POINTS:".
Also, I receive the following for the centering part:
polymake: WARNING: available properties insufficient to compute 'POINTS'
POINTS:
polymake: WARNING: rule REL_INT_POINT : CONE_AMBIENT_DIM failed: unit_vector - invalid dimension or index out of range at input line 7.
polymake: WARNING: rule REL_INT_POINT : VERTEX_BARYCENTER failed: attempt to use a property VERTEX_BARYCENTER with undefined value
polymake: WARNING: rule REL_INT_POINT : VERTICES | POINTS failed: computed point not affine at /import/polymake-2.14/share/polymake/apps/polytope/rules/polarize.rules line 51.
polymake: WARNING: rule TRIANGULATION.FACETS : RAYS ( applied to parent ) failed: std::bad_alloc at /import/polymake-2.14/share/polymake/apps/polytope/rules/cone_common.rules line 514.
polymake: WARNING: rule default.volume: CENTROID, VOLUME : VERTICES, TRIANGULATION failed: no more rules available to compute 'FACETS'
polymake: WARNING: rule CONE_DIM, REL_INT_POINT : FACETS | INEQUALITIES, ONE_VERTEX, BOUNDED failed: unexpected undefined value of an input property at /import/polymake-2.14/share/polymake/apps/polytope/rules/polarize.rules line 59.

polymake: ERROR: no more rules available to compute 'REL_INT_POINT'

Code: Select all

open( INPUT, "< neighb.txt" ) or die "Can't open $filename: $!"; while (my $line = <INPUT> ) { $line =~ s/^\d+://; # remove the line number my $points=new Matrix<Rational>(eval $line); my $p=new Polytope<Rational>(POINTS => (ones_vector<Rational>()) | $points); # make homogeneous coordinates print "POINTS:\n", $p->POINTS; # verify the correctness of input parsing print "VERTICES:\n", $p->VERTICES; $p=polarize(center($p))->TWO_FACE_SIZES; #my $s=0;foreach(1..20){ # $s+=$p->{$_} if $_!=4; #} #print $s/9; } close(INPUT);

Re: Creating polytope - unsatisfied preconditions

Posted: 15 Jun 2016, 18:33
by gawrilow
Well, something still goes wrong in the input parsing part, the points matrix is then obviously empty and nothing interesting can be computed from it. Could you add some debugging output:

Code: Select all

... $line =~ s/^\d+://; my $parsed=eval $line; if ($@) { print STDERR "ERROR parsing line '$line': $@\n"; last; } print STDERR "parsed '$line' as $parsed\n"; my $points=new Matrix<Rational>($parsed); print STDERR "points: ", $points->rows, " x ", $points->cols, "\n";