1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
# Copyright (c) 1997-2024
# Ewgenij Gawrilow, Michael Joswig, and the polymake team
# Technische Universität Berlin, Germany
# https://polymake.org
#
# 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.
#-------------------------------------------------------------------------------
CREDIT tplib
TPLib: Tropical Polyhedra Library
Copyright by Xavier Allamigeon
https://gforge.inria.fr/projects/tplib/
# path to the tplib executable
custom $tplib_compute_halfspaces;
CONFIGURE {
find_program($tplib_compute_halfspaces, "compute_halfspaces") or return;
# check the version
open TPLIB_OUT, "$tplib_compute_halfspaces -help |"
or die "can't run $tplib_compute_halfspaces: $!";
local $/;
my $version=<TPLIB_OUT>;
close TPLIB_OUT;
$version =~ /Version of TPLib:\s+([\d\.]+)/ and $version=$1;
eval("v$version") ge v1.1.1
or die <<'.';
polymake requires TPLib v1.1.1 or newer;
Please download the current version
and repeat the auto-configuration.
.
}
object TropicalPolytope {
# Tropical double description method.
label tplib
# Allamigeon, Xavier
# Static analysis of memory manipulations by abstract interpretation,
# PhD thesis, Ecole Polytechnique, 2009.
rule tplib.half_spaces : HALF_SPACES : POINTS, AMBIENT_DIM {
my $d=$this->AMBIENT_DIM+1;
my @points=@{$this->POINTS};
my $n_points=scalar(@points);
my $tempname=new Tempfile;
open TPLIB_FILE, ">$tempname"
or die "can't create temporary file $tempname: $!";
for (my $i=0; $i<$n_points; ++$i) {
my $p=$this->POINTS->[$i];
my $single_point="$p"; $single_point =~ s/ +/,/g;
print TPLIB_FILE "[$single_point]\n";
}
close TPLIB_FILE;
my @halfspaces;
open TPLIB_OUT, "$tplib_compute_halfspaces -min-plus -numerical-data ocaml_big_rat $d < $tempname |"
or die "can't read TPLib output: $!";
foreach my $line (<TPLIB_OUT>) {
my ($apex,$sectors) = ($line =~ /\(\[(.*)\],\[(.*)\]\)/);
$apex =~ s/,/ /g; $sectors =~ s/,/ /g; $sectors="{$sectors}";
my $apex_as_vector=new Vector<Rational>($apex);
my $sectors_as_set=new Set<Int>($sectors);
push @halfspaces, [$apex_as_vector,$sectors_as_set];
}
close TPLIB_OUT;
$this->HALF_SPACES=\@halfspaces;
}
}
# Local Variables:
# mode: perl
# cperl-indent-level:3
# End:
|