File: propagated_polytope.rules

package info (click to toggle)
polymake 4.15-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 35,892 kB
  • sloc: cpp: 168,945; perl: 43,410; javascript: 31,575; ansic: 3,007; java: 2,654; python: 632; sh: 268; xml: 117; makefile: 61
file content (70 lines) | stat: -rw-r--r-- 2,825 bytes parent folder | download | duplicates (3)
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
#  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.
#-------------------------------------------------------------------------------

# Polytope propagation means to define a polytope inductively by assigning vectors to arcs
# of a directed graph.  At each node of such a graph a polytope arises as the joint convex hull
# of the polytopes at the translated sources of the inward pointing arcs.
#
# For details see 
#	Joswig: Polytope Propagation on Graphs.
#	Chapter 6 in Pachter/Sturmfels: Algebraic Statistics for Computational Biology, Cambridge 2005.
#
# @example
# We define an acyclic digraph on 8 nodes with a unique source and a unique sink.
# Each arc is equipped with a vector in Q^2.
# > $Gamma = new GraphAdjacency<Directed>(8);
# > $Vectors = new EdgeMap<Directed, Vector>($Gamma);
# > $Vectors->edge(0,1) = [1,0]; $Vectors->edge(0,2) = [0,0];
# > $Vectors->edge(1,3) = [1,0]; $Vectors->edge(1,4) = [0,1];
# > $Vectors->edge(2,3) = [0,0]; $Vectors->edge(2,4) = [0,2];
# > $Vectors->edge(3,5) = [1,0]; $Vectors->edge(3,6) = [0,1];
# > $Vectors->edge(4,5) = [0,0]; $Vectors->edge(4,6) = [0,2];
# > $Vectors->edge(5,7) = [0,0];
# > $Vectors->edge(6,7) = [0,0];
# Then we can define the propagated polytope implicitly:
# > $P = new PropagatedPolytope(CONE_AMBIENT_DIM=>3, "SUM_PRODUCT_GRAPH.ADJACENCY"=>$Gamma, "SUM_PRODUCT_GRAPH.TRANSLATIONS"=>$Vectors);
# > print $P->VERTICES;
# | 1 3 0
# | 1 1 0
# | 1 0 1
# | 1 1 3
# | 1 0 4
# Note that it is necessary to specify the dimension of the (homogeneous) ambient space by setting [[CONE_AMBIENT_DIM]].

declare object PropagatedPolytope<Scalar=Rational> : Polytope<Scalar> {

# Directed graph to define the propagated polytope.  There is a (translation) vector assigned to each arc.
# We assume that this graph is acyclic with a unique sink.

property SUM_PRODUCT_GRAPH : Graph<Directed> {

   # The translation vectors of the arcs.
   property TRANSLATIONS : EdgeMap<Directed,Vector<Scalar>> : construct(ADJACENCY);

}

rule VERTICES, VERTEX_NORMALS, LINEALITY_SPACE : SUM_PRODUCT_GRAPH, CONE_AMBIENT_DIM {
   sum_product($this);
}
incurs VertexPerm;

}

# Local Variables:
# mode: perl
# cperl-indent-level:3
# indent-tabs-mode:nil
# End: