no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | user_guide:tutorials:latest:matching_polytopes [2023/11/06 10:57] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== Matching Polytopes ===== | ||
+ | |||
+ | In this tutorial we will use '' | ||
+ | |||
+ | First we construct a graph, the complete graph on four nodes: | ||
+ | |||
+ | <code perl> | ||
+ | > $K4=new GraphAdjacency(4); | ||
+ | > for (my $i=0; $i<4; ++$i) { | ||
+ | > for (my $j=$i+1; $j<4; ++$j) { | ||
+ | > | ||
+ | > } | ||
+ | > } | ||
+ | </ | ||
+ | (See also the [[apps_graph|Tutorial on Graphs]] for more on the construction of graphs.) | ||
+ | |||
+ | Next we like to have the node-edge-incidence matrix of our graph. Since the latest release of '' | ||
+ | |||
+ | <code perl> | ||
+ | > sub node_edge_incidences { | ||
+ | > my $g=shift; | ||
+ | > my $A=new Matrix< | ||
+ | > my $k=0; | ||
+ | > for (my $i=0; $i< | ||
+ | > foreach (@{$g-> | ||
+ | > if ($_>$i) { | ||
+ | > $A-> | ||
+ | > $A-> | ||
+ | > ++$k; | ||
+ | > } | ||
+ | > } | ||
+ | > } | ||
+ | > return $A; | ||
+ | > } | ||
+ | </ | ||
+ | Now we can construct the node-edge-incidence matrix of our graph '' | ||
+ | |||
+ | <code perl> | ||
+ | > $A=node_edge_incidences($K4); | ||
+ | > print $A; | ||
+ | 1 1 1 0 0 0 | ||
+ | 1 0 0 1 1 0 | ||
+ | 0 1 0 1 0 1 | ||
+ | 0 0 1 0 1 1 | ||
+ | </ | ||
+ | With this we can now construct the constraint matrix consisting of an upper part for the nonnegativity constraints $x_e \ge 0$ ... | ||
+ | |||
+ | <code perl> | ||
+ | > $I=new Matrix< | ||
+ | > $Block1=new Matrix< | ||
+ | </ | ||
+ | ... and a lower part for the constraints $\Sigma_e x_e \le 1$ for each vertex $v \in V$, where the sum is over all edges e containing v: | ||
+ | |||
+ | <code perl> | ||
+ | > $Block2=new Matrix< | ||
+ | </ | ||
+ | Now we can put both parts together and define the polytope: | ||
+ | |||
+ | <code perl> | ||
+ | > $Ineqs=new Matrix< | ||
+ | > $P=new Polytope< | ||
+ | </ | ||
+ | The matching polytope of '' | ||
+ | |||
+ | <code perl> | ||
+ | > $P_I=new Polytope< | ||
+ | </ | ||
+ | We can analyse some elementary properties of '' | ||
+ | |||
+ | <code perl> | ||
+ | > print $P_I-> | ||
+ | 1 0 0 0 0 0 0 | ||
+ | 1 0 0 0 0 0 1 | ||
+ | 1 0 0 0 0 1 0 | ||
+ | 1 0 0 0 1 0 0 | ||
+ | 1 0 0 1 0 0 0 | ||
+ | 1 0 0 1 1 0 0 | ||
+ | 1 0 1 0 0 0 0 | ||
+ | 1 0 1 0 0 1 0 | ||
+ | 1 1 0 0 0 0 0 | ||
+ | 1 1 0 0 0 0 1 | ||
+ | > print $P_I-> | ||
+ | 0 0 0 0 0 0 1 | ||
+ | 0 0 0 0 0 1 0 | ||
+ | 1 -1 -1 -1 0 0 0 | ||
+ | 1 -1 -1 0 -1 0 0 | ||
+ | 0 0 0 0 1 0 0 | ||
+ | 0 0 0 1 0 0 0 | ||
+ | 0 0 1 0 0 0 0 | ||
+ | 1 -1 0 -1 0 -1 0 | ||
+ | 1 -1 0 0 -1 -1 0 | ||
+ | 1 0 0 -1 0 -1 -1 | ||
+ | 1 0 0 0 -1 -1 -1 | ||
+ | 0 1 0 0 0 0 0 | ||
+ | 1 0 -1 -1 0 0 -1 | ||
+ | 1 0 -1 0 -1 0 -1 | ||
+ | > print $P_I-> | ||
+ | 14 | ||
+ | </ | ||
+ | ... and compare them with the according properties of the defining polytope '' | ||
+ | |||
+ | <code perl> | ||
+ | > print $P-> | ||
+ | 1 0 0 1 1 0 0 | ||
+ | 1 1 0 0 0 0 1 | ||
+ | 1 0 0 0 1/2 1/2 1/2 | ||
+ | 1 0 0 0 0 0 1 | ||
+ | 1 0 1/2 1/2 0 0 1/2 | ||
+ | 1 0 0 1 0 0 0 | ||
+ | 1 1/2 1/2 0 1/2 0 0 | ||
+ | 1 0 0 0 1 0 0 | ||
+ | 1 0 1 0 0 0 0 | ||
+ | 1 1 0 0 0 0 0 | ||
+ | 1 0 0 0 0 0 0 | ||
+ | 1 0 1 0 0 1 0 | ||
+ | 1 0 0 0 0 1 0 | ||
+ | 1 1/2 0 1/2 0 1/2 0 | ||
+ | > print $P-> | ||
+ | 1/72 | ||
+ | > print $P_I-> | ||
+ | 1/90 | ||
+ | </ | ||
+ | Next we analyse the combinatorics of '' | ||
+ | |||
+ | <code perl> | ||
+ | > print $P_I-> | ||
+ | 6 6 | ||
+ | > print $P_I-> | ||
+ | 10 39 78 86 51 14 | ||
+ | > print $P_I-> | ||
+ | 8 8 6 6 8 8 8 6 6 6 6 8 6 6 | ||
+ | > $facet0=facet($P_I, | ||
+ | > print $facet0-> | ||
+ | 6 5 | ||
+ | > print rows_labeled($facet0-> | ||
+ | 0:0 2 3 4 5 7 | ||
+ | 1:3 4 5 6 7 | ||
+ | 2:2 4 5 6 7 | ||
+ | 3:0 1 3 5 6 7 | ||
+ | 4:0 1 2 5 6 7 | ||
+ | 5:0 1 2 3 4 7 | ||
+ | 6:1 3 4 6 7 | ||
+ | 7:1 2 4 6 7 | ||
+ | 8:0 1 2 3 4 5 6 | ||
+ | > $facet0-> | ||
+ | </ | ||
+ | The Gale diagram of '' | ||
+ | |||