;### Produce a new polytope with rational coordinates. $p=new Polytope; $p->POINTS=<<"."; 1 0 0 0 1 1 0 0 1 0 1 0 1 0 0 1 1 1 1 0 1 1 0 1 1 0 1 1 1 1 1 1 . ;### Calculate and print some properties of p. print join (", ",$p->list_properties); print $p->VERTICES; print join (", ",$p->list_properties); print rows_labeled($p->FACETS); show_credits; print $p->N_VERTICES, "\t", $p->N_FACETS, "\t", $p->SIMPLE; @a=@{$p->FACET_SIZES}; print @a; print "@a"; print join(", ", @a); ;### A for loop in Perl. for($i=0;$i<$p->N_FACETS;++$i){print $a[$i]." ";} ;### Vizualization. $p->VISUAL; jreality($p->VISUAL); ;### Produce a pyramid over p. $all_zeros=new Vector([ (0)x($p->N_VERTICES) ]); $point=new Vector(1,3/4,1/4,1/2); $height=3; $m=( ($p->VERTICES | $all_zeros) / ($point|$height)); $pyr=new Polytope(POINTS=>$m); $pyr->SCHLEGEL; $pyr->SCHLEGEL(FACET=>6, EdgeColor=>"blue"); help 'functions/Producing a new polyhedron from others/'; $pyr2=pyramid($p,$height); print isomorphic($pyr,$pyr2); ;### Other help: F1, apropos, documentation, forum ; ;### Cones and fans. print rows_labeled($p->FACETS); $indices=new Array(0,1,2); $c=new Polytope(INEQUALITIES=>($p->FACETS->minor($indices,All))); print $c->VERTICES; $c=new Cone(INPUT_RAYS=>[[1,0,0],[0,1,0],[0,-1,0]]); print $c->DIM,"\t",$c->AMBIENT_DIM; print $c->LINEALITY_SPACE; print $c->FACETS; application "fan"; help '/'; $f=new PolyhedralFan(INPUT_RAYS=>[[1,0,0],[0,1,0],[0,-1,0]],INPUT_CONES=>[[0,1],[0,2]]); prefer("jreality"); $f->VISUAL; print $f->FACET_NORMALS; print $f->MAXIMAL_CONES_FACETS; $p2=polytope::transportation((new Vector('3 6 5')),(new Vector('7 7'))); print $p2->AMBIENT_DIM; $t=polytope::projection_full( $p2 ); $t->VISUAL->LATTICE_COLORED; print $t->INTERIOR_LATTICE_POINTS; ;### ILP tomorrow save($t,"transportation.poly"); ### Graphs with polymake. application "graph"; $g=new Graph(ADJACENCY=>[[1,2,4],[0,2],[0,1,3,4],[2,4],[0,1,2,3]]); $g->VISUAL; graphviz($g->VISUAL); $g=new props::Graph(5); $g->edge(0,1);$g->edge(1,2);$g->edge(0,2); print $g; $g->delete_node(0); ;### Linear programming with polymake. application "polytope"; $t=load("transportation.poly"); $objective=new LinearProgram(LINEAR_OBJECTIVE=>[0,1,1]); $lp=new Polytope(VERTICES=>$t->VERTICES, LP=>$objective); print $lp->LP->MAXIMAL_VALUE; print $lp->LP->MAXIMAL_FACE; ;### The end of BEG. ;### type 'exit;' to exit polymake