#  Copyright (c) 1997-2021
#  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.
#-------------------------------------------------------------------------------

object Polytope<Rational> {

# @category Convex hull computation
# Run the [[wiki:external_software#porta]] program, implementing the Fourier-Motzkin elimination method.
# The essential drawback of this tool is that it employs a limited-precision arithmetic,
# and therefore can fail on numerically difficult problems.
label porta



rule porta.convex_hull.primal: FACETS, AFFINE_HULL : CONE_AMBIENT_DIM, CONE_DIM, VERTICES | POINTS {
   my ($f, $a) = porta_primal($this);
   $this->FACETS = $f;
   $this->AFFINE_HULL = $a;
}
weight 4.20;
precondition : CONE_DIM { $this->CONE_DIM > 1 }
precondition : POINTED;
incurs FacetPerm;


rule porta.convex_hull.dual: VERTICES, LINEALITY_SPACE : CONE_AMBIENT_DIM, FACETS | INEQUALITIES, VALID_POINT {
   my ($v, $l) = porta_dual($this);
   $this->VERTICES = $v;
   $this->LINEALITY_SPACE = $l;
}
weight 4.10;
precondition : POINTED;
incurs VertexPerm;


}
