# Copyright (c) 1997-2006 # Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany) # http://www.math.tu-berlin.de/polymake, mailto:polymake@math.tu-berlin.de # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2, or (at your option) any # later version: http://www.gnu.org/licenses/gpl.txt. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. #----------------------------------------------------------------------------- # $Project: polymake $$Id: rand_polytopes 6969 2006-02-08 17:36:57Z gawrilow $ # n_polytopes, dimension, n_vertices (in each) => list of RationalPolytope sub generate_random_spheres { my ($n, $d, $n_vert)=@_; my @polytopes; my $seed=time; for (my $i=0; $i<$n; ++$i, $seed+=100) { $polytopes[$i]=new Apps::polytope::RationalPolytope("rand_$i"); Modules::client("rand_sphere", $polytopes[$i], $d, $n_vert, "-seed", $seed); $polytopes[$i]->commit; } return @polytopes; } # list of polytopes => saves the polytope with the most facets in a file sub save_max_facets { my $p=shift; foreach (@_) { $p=$_ if $_->N_FACETS > $p->N_FACETS; } # construct the file name from the dimension and the number of vertices my $filename= "max_facets_" . $p->DIM . "_" . $p->N_VERTICES; save($p, $filename, 1); print "$filename has ", $p->N_FACETS, " facets\n"; } # main if (@ARGV != 3) { die "usage: $0 n_polytopes dimension n_vertices\n"; } my @p=generate_random_spheres(@ARGV); save_max_facets(@p); 1 # Local Variables: # mode: perl # c-basic-offset:3 # End: