/* Copyright (c) 1997-2009
   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: lrs_interface.h 9298 2009-09-02 23:10:56Z gawrilow $
*/

#ifndef _POLYMAKE_LRS_INTERFACE_H
#define _POLYMAKE_LRS_INTERFACE_H

#include <Rational.h>
#include <Matrix.h>
#include <Vector.h>
#include <Bitset.h>
#include <linsolver.h>

namespace polymake { namespace polytope { namespace lrs_interface {

class solver {
public:
   typedef Rational coord_type;

   typedef std::pair< Matrix<Rational>, Matrix<Rational> > matrix_pair;

   /// @retval first: facets, second: affine hull
   matrix_pair
   enumerate_facets(const Matrix<Rational>& Points);

   long
   count_facets(const Matrix<Rational>& Points);

   Matrix<Rational>
   enumerate_vertices(const Matrix<Rational>& Inequalities, const Matrix<Rational>& Equations, bool accept_non_pointed=false);

   std::pair<long, long>
   count_vertices(const Matrix<Rational>& Inequalities, const Matrix<Rational>& Equations,
		  bool only_bounded=false);

   typedef std::pair<Bitset, Matrix<Rational> > non_redundant;

   /// @retval first: indices of vertices, second: affine hull
   non_redundant find_vertices_among_points(const Matrix<Rational>& Points);

   Vector<Rational>
   find_a_vertex(const Matrix<Rational>& Inequalities, const Matrix<Rational>& Equations);

   bool check_feasibility(const Matrix<Rational>& Inequalities, const Matrix<Rational>& Equations);
   bool check_feasibility(const Matrix<Rational>& Inequalities, const Matrix<Rational>& Equations, Vector<Rational>& ValidPoint);

   typedef std::pair<Rational, Vector<Rational> > lp_solution;

   /// @retval first: objective value, second: solution
   lp_solution
   solve_lp(const Matrix<Rational>& Inequalities, const Matrix<Rational>& Equations,
	    const Vector<Rational>& Objective, bool maximize, int* linearity_dim_p = 0);

private:
   struct dictionary;
};

} } }

#endif // _POLYMAKE_LRS_INTERFACE_H

// Local Variables:
// mode:C++
// c-basic-offset:3
// End:
