/* Copyright (c) 1997-2004
   Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
   http://www.math.tu-berlin.de/polymake,  mailto:polymake@math.tu-berlin.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.
*/

#ifndef _POLYMAKE_LRS_INTERFACE_H
#define _POLYMAKE_LRS_INTERFACE_H "$Project: polymake $$Id: lrs_interface.h,v 1.11 2004/11/15 12:09:26 gawrilow Exp $"

#if defined(__GNUC__) && __GNUC_MINOR__<3 && !defined(__APPLE__)
#pragma interface
#endif

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

namespace polymake { namespace polytope { namespace lrs_interface {

class solver {
public:
   typedef Rational coord_type;

   solver();

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

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

   long
   count_facets(const Matrix<Rational>& Points)
      throw (std::bad_alloc, infeasible, unbounded);

   Matrix<Rational>
   enumerate_vertices(const Matrix<Rational>& Inequalities, const Matrix<Rational>& Equations)
      throw (std::bad_alloc, infeasible, not_pointed);

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

   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)
      throw (std::bad_alloc, infeasible);

   Vector<Rational>
   find_a_vertex(const Matrix<Rational>& Inequalities, const Matrix<Rational>& Equations)
      throw (std::bad_alloc, infeasible, not_pointed);

   typedef std::pair<bool, Vector<Rational> > feasibility_solution;

   feasibility_solution
   check_feasibility(const Matrix<Rational>& Inequalities, const Matrix<Rational>& Equations)
      throw (std::bad_alloc);

   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)
      throw (std::bad_alloc, infeasible, unbounded);

private:
   class initializer;
   struct dictionary;
};

} } }

#endif // _POLYMAKE_LRS_INTERFACE_H

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