/* -*- C++ -*-
 * src/lemon/lp_glpk.h - Part of LEMON, a generic C++ optimization library
 *
 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
 * (Egervary Combinatorial Optimization Research Group, EGRES).
 *
 * Permission to use, modify and distribute this software is granted
 * provided that this copyright notice appears in all copies. For
 * precise terms see the accompanying LICENSE file.
 *
 * This software is provided "AS IS" with no warranty of any kind,
 * express or implied, and with no claim as to its suitability for any
 * purpose.
 *
 */

#ifndef LEMON_LP_GLPK_H
#define LEMON_LP_GLPK_H

///\file
///\brief Header of the LEMON-GLPK lp solver interface.
///\ingroup gen_opt_group

#include "lp_base.h"
extern "C" {
#include <glpk.h>
}

namespace lemon {


  /// \brief Wrapper for GLPK solver
  /// 
  /// This class implements a lemon wrapper for GLPK.
  ///\ingroup gen_opt_group
  class LpGlpk : public LpSolverBase {
  protected:
    LPX* lp;
    
  public:
    
    typedef LpSolverBase Parent;
    
    LpGlpk();
    ~LpGlpk();
    
  protected:
    virtual int _addCol();
    virtual int _addRow();
    virtual void _setRowCoeffs(int i, 
			       int length,
                               const int   * indices, 
                               const Value   * values );
    virtual void _setColCoeffs(int i, 
			       int length,
                               const int   * indices, 
                               const Value   * values);
    virtual void _setColLowerBound(int i, Value value);
    virtual void _setColUpperBound(int i, Value value);
    virtual void _setRowLowerBound(int i, Value value);
    virtual void _setRowUpperBound(int i, Value value);
    virtual void _setObjCoeff(int i, Value obj_coef);
    ///\e
    
    ///\todo It should be clarified
    ///
    virtual SolveExitStatus _solve();
    virtual Value _getPrimal(int i);
    virtual Value _getPrimalValue();
    ///\e
    
    ///\todo It should be clarified
    ///
    virtual SolutionStatus _getPrimalStatus();
    virtual void _setMax();
    virtual void _setMin();

  public:
    ///Set the verbosity of the messages

    ///Set the verbosity of the messages
    ///
    ///\param m is the level of the messages output by the solver routines.
    ///The possible values are:
    ///- 0 --- no output (default value)
    ///- 1 --- error messages only
    ///- 2 --- normal output
    ///- 3 --- full output (includes informational messages)
    void messageLevel(int m);
    ///Turns on or off the presolver

    ///Turns on (\c b is \c true) or off (\c b is \c false) the presolver
    ///
    ///The presolver is off by default.
    void presolver(bool b);
    
  };
} //END OF NAMESPACE LEMON

#endif //LEMON_LP_GLPK_H

