I would like to use Polymake called from a script.
For example, if I copy-paste the following "script-snipplet"
Code: Select all
$p1=new Polytope(POINTS=>[[1, 0, 0, 0], [1, 2, 0, 0], [1, 0, 2, 0], [1, 0, 0, 2],[1,0,0,0]]);
$p2=new Polytope(POINTS=>[[1, 0, 0, 0], [1, 0, 0, 1], [1, 0, 1, 0], [1, 1, 0, 0], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0], [1, 1, 1, 1]]);
$cp=conv([$p1,$p2]);
print $cp->VOLUME;
print $cp->N_LATTICE_POINTS;
$w=rows($cp->LATTICE_POINTS);
@strs={};
foreach(@$w){
@arr1=@{$_}; shift(@arr1);
$str1= "{" . join(",",@arr1) . "}" ;
push( @strs, $str1 ) ;
};
shift(@strs);
declare $fh;
open($fh, '>', 'result.txt');
print $fh "{" . join(",", @strs) . "}" ;
close $fh;
it works fine. I would need that something like
polymake - <TEXTFILE
instead of copy-paste. I tried to rewrite the above code, but
Code: Select all
use application 'Polymake';
use Polymake;
use Polymake::User;
use Polymake::Core::CPlusPlus;
declare $p1, $p2, $cp;
$p1=new Polytope(POINTS=>[[1, 0, 0, 0], [1, 2, 0, 0], [1, 0, 2, 0], [1, 0, 0, 2],[1,0,0,0]]);
$p2=new Polytope(POINTS=>[[1, 0, 0, 0], [1, 0, 0, 1], [1, 0, 1, 0], [1, 1, 0, 0], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0], [1, 1, 1, 1]]);
$cp=conv([$p1,$p2]);
print $cp->N_LATTICE_POINTS;
print $cp->VOLUME;
exit();
As you see I am new to Polymake, and Perl too and sorry if it is very simple.
What would be the correct Polymake script?
Thanks for any help in advance!
Bela