#  Copyright (c) 1997-2010
#  Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Darmstadt, Germany)
#  http://www.polymake.de
#
#  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.
#-------------------------------------------------------------------------------
#  $Project: polymake $$Id: polarize.rules 9502 2010-02-24 00:26:29Z gawrilow $

object Polytope {

# @category Polarization
# Relatively interior point of the polyhedron.

property REL_INT_POINT : Vector<Scalar>;


# @category Polarization
# Valid strict inequality for all affine points of the polyhedron.

property FAR_HYPERPLANE : Vector<Scalar>;


rule REL_INT_POINT : AMBIENT_DIM {
   $this->REL_INT_POINT=unit_vector<Scalar>($this->AMBIENT_DIM+1,0);
}
precondition : CENTERED;
weight 0.10;

rule FAR_HYPERPLANE : AMBIENT_DIM {
   $this->FAR_HYPERPLANE= "1".(" 0" x $this->AMBIENT_DIM);
}
precondition : BOUNDED;
weight 0.10;

rule REL_INT_POINT : VERTEX_BARYCENTER {
   $this->REL_INT_POINT=$this->VERTEX_BARYCENTER;
}
precondition : BOUNDED;
weight 0.10;


rule REL_INT_POINT : CENTROID {
   $this->REL_INT_POINT=$this->CENTROID;
}
precondition : BOUNDED;
weight 0.10;

rule REL_INT_POINT : VERTICES | POINTS {
   $this->REL_INT_POINT=inner_point($this->VERTICES | POINTS);
}

rule FAR_HYPERPLANE : FACETS | INEQUALITIES {
   $this->FAR_HYPERPLANE=inner_point($this->FACETS | INEQUALITIES);
}

rule DIM, REL_INT_POINT : FACETS | INEQUALITIES, AFFINE_HULL, ONE_VERTEX {
   rel_int_point($this,1,1);
}
weight 3.35;

rule DIM, REL_INT_POINT, AFFINE_HULL : FACETS | INEQUALITIES, ONE_VERTEX {
   rel_int_point($this,1,0);
}
weight 3.40;

rule DIM, REL_INT_POINT : FACETS | INEQUALITIES, AFFINE_HULL, ONE_VERTEX {
   rel_int_point($this,0,1);
}
precondition : BOUNDED;
weight 3.25;

rule DIM, REL_INT_POINT, AFFINE_HULL : FACETS | INEQUALITIES, ONE_VERTEX {
   rel_int_point($this,0,0);
}
precondition : BOUNDED;
weight 3.30;

rule REL_INT_POINT : FACETS | INEQUALITIES, LINEALITY_SPACE {
   my $p;
   if (defined (my $AH = $this->lookup("AFFINE_HULL | EQUATIONS"))) {
      $p=new Polytope(INEQUALITIES=>$this->FACETS | INEQUALITIES,EQUATIONS=>$this->LINEALITY_SPACE/$AH);
   }
   else {
      $p=new Polytope(INEQUALITIES=>$this->FACETS | INEQUALITIES,EQUATIONS=>$this->LINEALITY_SPACE);
   }
   $this->REL_INT_POINT = $p->REL_INT_POINT;
}
precondition : !POINTED;
weight 3.40;

}


# Local Variables:
# mode: perl
# c-basic-offset:3
# End:
