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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
# 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.
#-------------------------------------------------------------------------------
# @Category Combinatorics
object Polytope {
#rule PSEUDOVERTEX_LABELS : PSEUDOVERTEX_COVECTORS {
# $this->PSEUDOVERTEX_LABELS(temporary)=[ map { join("", @$_) } @{$this->PSEUDOVERTEX_COVECTORS} ];
#}
rule PROJECTIVE_AMBIENT_DIM : POINTS {
$this->PROJECTIVE_AMBIENT_DIM=$this->POINTS->cols-1;
}
weight 0.1;
rule PROJECTIVE_AMBIENT_DIM : DOME.VERTICES {
$this->PROJECTIVE_AMBIENT_DIM=$this->DOME->VERTICES->cols-2;
}
weight 0.1;
# checking feasibility via a tropical linear program
rule FEASIBLE, VALID_POINT : INEQUALITIES {
my $feasibility_pair = H_trop_input_feasible($this);
$this->VALID_POINT = $feasibility_pair->first;
$this->FEASIBLE = $feasibility_pair->second;
}
weight 3.1;
# A Polytope defined by a non-empty set of [[VERTICES]] or [[POINTS]] is always [[FEASIBLE]].
rule FEASIBLE, VALID_POINT : VERTICES | POINTS {
my $p=$this->give("VERTICES | POINTS");
if ($p->rows > 0) {
$this->VALID_POINT(temporary) = $p->row(0);
}
$this->FEASIBLE = $this->give("VERTICES | POINTS")->rows > 0;
}
weight 0.1;
rule VERTICES : INEQUALITIES {
$this->VERTICES = V_trop_input($this);
}
weight 6.10;
rule VERTICES, VERTICES_IN_POINTS : POINTS {
discard_non_vertices($this);
}
weight 1.20;
rule ENVELOPE.INEQUALITIES, ENVELOPE.EQUATIONS : POINTS {
$this->ENVELOPE = envelope($this->POINTS);
}
rule DOME.INEQUALITIES, DOME.FEASIBLE, DOME.BOUNDED : POINTS {
$this->DOME = dome_hyperplane_arrangement($this->POINTS);
}
rule DOME.MAXIMAL_COVECTOR_CELLS : DOME.VERTICES, DOME.VERTICES_IN_FACETS, DOME.FAR_FACE {
my $dome = $this->DOME;
my $V = $dome->VERTICES;
my $vif = new Set<Set<Int>>(rows($dome->VERTICES_IN_FACETS));
my $ff = $dome->FAR_FACE;
$dome->MAXIMAL_COVECTOR_CELLS = new IncidenceMatrix($vif - $ff);
}
rule PSEUDOVERTICES : DOME.VERTICES, DOME.FAR_FACE {
my $V = $this->DOME->VERTICES;
$this->PSEUDOVERTICES = $V->minor(~$this->DOME->FAR_FACE, ~scalar2set(0));
}
rule PSEUDOVERTEX_COVECTORS : PSEUDOVERTICES, POINTS {
$this->PSEUDOVERTEX_COVECTORS = covectors($this->PSEUDOVERTICES, $this->POINTS);
}
weight 1.10;
rule PSEUDOVERTEX_COARSE_COVECTORS : PSEUDOVERTICES, POINTS {
$this->PSEUDOVERTEX_COARSE_COVECTORS=coarse_covectors($this->PSEUDOVERTICES, $this->POINTS);
}
weight 1.10;
rule DOME.TROPICAL_POLYTOPE_VERTICES : DOME.VERTEX_COVECTORS {
my $pv = new Set();
for (my $i=0; $i < $this->DOME->VERTEX_COVECTORS->size; $i++) {
$pv += $i
if (0 == grep {$_->size==0} @{rows($this->DOME->VERTEX_COVECTORS->[$i])});
}
$this->DOME->TROPICAL_POLYTOPE_VERTICES = $pv;
}
rule TORUS_COVECTOR_DECOMPOSITION, MAXIMAL_COVECTORS : POINTS, DOME.VERTICES, DOME.VERTEX_COVECTORS, DOME.MAXIMAL_COVECTOR_CELLS, POLYTOPE_COVECTOR_DECOMPOSITION {
compute_covector_decomposition($this, compute_only_tropical_span=>0);
}
weight 6.10;
rule POLYTOPE_COVECTOR_DECOMPOSITION, DOME.TROPICAL_SPAN_MAXIMAL_COVECTOR_CELLS, POLYTOPE_MAXIMAL_COVECTORS : POINTS, DOME.VERTICES, DOME.VERTEX_COVECTORS, DOME.MAXIMAL_COVECTOR_CELLS {
compute_covector_decomposition($this, compute_only_tropical_span=>1);
}
weight 6.10;
rule MAXIMAL_COVECTORS : DOME.MAXIMAL_COVECTOR_CELLS, DOME.VERTICES, POINTS {
compute_maximal_covectors($this);
}
weight 2.10;
rule DOME.VERTEX_COVECTORS : DOME.VERTICES, POINTS {
$this->DOME->VERTEX_COVECTORS = covectors_of_scalar_vertices($this->DOME->VERTICES, $this->POINTS);
}
weight 1.10;
# In case [[VERTICES]] are known but [[POINTS]] are not, we set [[POINTS]] = [[VERTICES]].
# This allows to visualize a Polytope that was initialized via [[INEQUALIES]] with its coarsets [[POLYTOPE_COVECTOR_DECOMPOSITION]].
rule POINTS = VERTICES;
}
# Local Variables:
# mode: perl
# c-basic-offset:3
# End:
|