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
|
# 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 azove
azove is a tool designed for counting (without explicit enumeration) and enumeration of 0/1 vertices.
Copyright by Markus Behle
http://www.mpi-inf.mpg.de/~behle/azove.html
# path to the "azove" executable
custom $azove;
CONFIGURE {
find_program($azove, qw(azove2 azove));
}
object Polytope<Rational> {
# @category Geometry
# Use the [[wiki:external_software#azove|azove]] program for counting 0/1-points in a polytope.
label azove
rule azove.points01: N_01POINTS : CONE_AMBIENT_DIM, FACETS | INEQUALITIES, AFFINE_HULL | EQUATIONS {
my $dim = $this->CONE_AMBIENT_DIM-1;
my $ineqs = eliminate_denominators_in_rows($this->give("FACETS | INEQUALITIES"));
if (defined (my $AFFINE_HULL=$this->lookup("AFFINE_HULL | EQUATIONS"))) {
my $eqs = eliminate_denominators_in_rows($AFFINE_HULL);
$ineqs /= $eqs / (-$eqs);
}
# write the ine-file
my $tempname=new Tempfile;
open(P, ">$tempname.ine")
or die "can't create temporary file $tempname.ine: $!";
print P "* Automatically generated by polymake.\n",
"H-representation\n",
"begin\n", $ineqs->rows, " ", $dim+1, " integer\n",
dense($ineqs), # polymake and azove have the same format, but azove does not know how to handle sparse matrices
"end\n";
close P;
# call azove
open P, "$azove -c $tempname.ine 2>&1 |"
or die "couldn't run $azove: $!";
local $_;
while (<P>) {
if (my ($n)=/^Number of 0\/1 vertices =\s+(\d+)/) {
$this->N_01POINTS=$n;
close P;
return;
}
}
die "can't parse output from $azove";
}
}
# Local Variables:
# mode: perl
# cperl-indent-level:3
# End:
|