#  Copyright (c) 1997-2015
#  Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
#  http://www.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 Symmetry
# A symmetric polytope defined as the convex hull of the orbit of a single point
# under a permutation group acting on coordinates.
# currently only for [[Polytope<Rational>]]

declare object_specialization PointOrbit = Polytope<Rational> {

    precondition : GROUP.COORDINATE_ACTION.N_POINTS_GENERATORS {
       $this->GROUP->COORDINATE_ACTION->N_POINTS_GENERATORS==1;
    }

#------------------------------------------------------
# properties
#------------------------------------------------------

   property GROUP {

      property COORDINATE_ACTION  {

         # The NOP-graph of [[POINTS_GENERATORS]] with respect to the
         # [[GROUP]]. The nodes of the NOP-graph
         # correspond to the [[REPRESENTATIVE_CERTIFIERS]], 
         # which represent the different orbit polytopes
         # contained in the given orbit polytope.
         property NOP_GRAPH : objects::Graph<Directed>;

         # A matrix of representatives of all certifiers
         # for [[POINTS_GENERATORS]] with respect to the
         # [[GROUP]].
         # A certifier is an integer point in the
         # given orbit polytope. 
         # Note that the representative certifiers must be in 
         # the same order as the corresponding nodes
         # in the [[NOP_GRAPH]]. Further, the [[CP_INDICES]]
         # refer to row indices of this property.
         property REPRESENTATIVE_CERTIFIERS : Matrix<Rational>;


         # The number of [[REPRESENTATIVE_CERTIFIERS]].
         property N_REPRESENTATIVE_CERTIFIERS : Int;


         # The row indices of all core points among
         # the [[REPRESENTATIVE_CERTIFIERS]].
         property CP_INDICES : Set<Int>;


         # A matrix of representatives of all core points in
         # the given orbit polytope.
         # A core point is an integer point whose orbit
         # polytope is lattice-free (i.e. does not contain
         # integer points besides its vertices).
         property REPRESENTATIVE_CORE_POINTS : Matrix<Rational>;


         # The number of [[REPRESENTATIVE_CORE_POINTS]].
         property N_REPRESENTATIVE_CORE_POINTS : Int;

#------------------------------------------------------
# rules
#------------------------------------------------------

         rule N_REPRESENTATIVE_CERTIFIERS : REPRESENTATIVE_CERTIFIERS {
             $this->N_REPRESENTATIVE_CERTIFIERS = $this->REPRESENTATIVE_CERTIFIERS->rows;
         }


         rule N_REPRESENTATIVE_CORE_POINTS : REPRESENTATIVE_CORE_POINTS {
             $this->N_REPRESENTATIVE_CORE_POINTS = $this->REPRESENTATIVE_CORE_POINTS->rows;
         }

      }
      
   }

rule GROUP.COORDINATE_ACTION.NOP_GRAPH, GROUP.COORDINATE_ACTION.REPRESENTATIVE_CERTIFIERS, GROUP.COORDINATE_ACTION.REPRESENTATIVE_CORE_POINTS, GROUP.COORDINATE_ACTION.CP_INDICES : GROUP.COORDINATE_ACTION.POINTS_GENERATORS, POINTS, LATTICE_POINTS_GENERATORS {
    
    my @res=nestedOPGraph($this->GROUP->COORDINATE_ACTION->POINTS_GENERATORS->[0], $this->POINTS, $this->LATTICE_POINTS_GENERATORS->[0], $this->GROUP->COORDINATE_ACTION, 0);
    $this->GROUP->COORDINATE_ACTION->NOP_GRAPH = $res[0];
    $this->GROUP->COORDINATE_ACTION->REPRESENTATIVE_CERTIFIERS = $res[1];
    $this->GROUP->COORDINATE_ACTION->REPRESENTATIVE_CORE_POINTS = $res[3];
    $this->GROUP->COORDINATE_ACTION->CP_INDICES = $res[4];
}
precondition : BOUNDED;
precondition : FEASIBLE;

}



package Visual::Color;

# Color for the visualization of core points
custom $CorePointColor="236 101 0"; #tud8b

# Color for the visualization of non core points
custom $NonCorePointColor="0 131 204"; #tud2b


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

