alpar@484: /* -*- mode: C++; indent-tabs-mode: nil; -*- alpar@484: * alpar@484: * This file is a part of LEMON, a generic C++ optimization library. alpar@484: * alpar@1081: * Copyright (C) 2003-2011 alpar@484: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@484: * (Egervary Research Group on Combinatorial Optimization, EGRES). alpar@484: * alpar@484: * Permission to use, modify and distribute this software is granted alpar@484: * provided that this copyright notice appears in all copies. For alpar@484: * precise terms see the accompanying LICENSE file. alpar@484: * alpar@484: * This software is provided "AS IS" with no warranty of any kind, alpar@484: * express or implied, and with no claim as to its suitability for any alpar@484: * purpose. alpar@484: * alpar@484: */ alpar@484: alpar@484: #ifndef LEMON_CLP_H alpar@484: #define LEMON_CLP_H alpar@484: alpar@484: ///\file alpar@484: ///\brief Header of the LEMON-CLP lp solver interface. alpar@484: alpar@484: #include alpar@484: #include alpar@484: alpar@484: #include alpar@484: alpar@484: class ClpSimplex; alpar@484: alpar@484: namespace lemon { alpar@484: alpar@484: /// \ingroup lp_group alpar@484: /// alpar@484: /// \brief Interface for the CLP solver alpar@484: /// alpar@484: /// This class implements an interface for the Clp LP solver. The alpar@484: /// Clp library is an object oriented lp solver library developed at alpar@484: /// the IBM. The CLP is part of the COIN-OR package and it can be alpar@484: /// used with Common Public License. alpar@485: class ClpLp : public LpSolver { alpar@484: protected: alpar@484: alpar@484: ClpSimplex* _prob; alpar@484: alpar@484: std::map _col_names_ref; alpar@484: std::map _row_names_ref; alpar@484: alpar@484: public: alpar@484: alpar@484: /// \e alpar@485: ClpLp(); alpar@484: /// \e alpar@485: ClpLp(const ClpLp&); alpar@484: /// \e alpar@485: ~ClpLp(); alpar@484: alpar@587: /// \e alpar@587: virtual ClpLp* newSolver() const; alpar@587: /// \e alpar@587: virtual ClpLp* cloneSolver() const; alpar@587: alpar@484: protected: alpar@484: alpar@484: mutable double* _primal_ray; alpar@484: mutable double* _dual_ray; alpar@484: alpar@484: void _init_temporals(); alpar@484: void _clear_temporals(); alpar@484: alpar@484: protected: alpar@484: alpar@484: virtual const char* _solverName() const; alpar@484: alpar@484: virtual int _addCol(); alpar@484: virtual int _addRow(); alpar@484: alpar@484: virtual void _eraseCol(int i); alpar@484: virtual void _eraseRow(int i); alpar@484: alpar@484: virtual void _eraseColId(int i); alpar@484: virtual void _eraseRowId(int i); alpar@484: alpar@484: virtual void _getColName(int col, std::string& name) const; alpar@484: virtual void _setColName(int col, const std::string& name); alpar@484: virtual int _colByName(const std::string& name) const; alpar@484: alpar@484: virtual void _getRowName(int row, std::string& name) const; alpar@484: virtual void _setRowName(int row, const std::string& name); alpar@484: virtual int _rowByName(const std::string& name) const; alpar@484: alpar@484: virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e); alpar@484: virtual void _getRowCoeffs(int i, InsertIterator b) const; alpar@484: alpar@484: virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e); alpar@484: virtual void _getColCoeffs(int i, InsertIterator b) const; alpar@484: alpar@484: virtual void _setCoeff(int row, int col, Value value); alpar@484: virtual Value _getCoeff(int row, int col) const; alpar@484: alpar@484: virtual void _setColLowerBound(int i, Value value); alpar@484: virtual Value _getColLowerBound(int i) const; alpar@484: virtual void _setColUpperBound(int i, Value value); alpar@484: virtual Value _getColUpperBound(int i) const; alpar@484: alpar@484: virtual void _setRowLowerBound(int i, Value value); alpar@484: virtual Value _getRowLowerBound(int i) const; alpar@484: virtual void _setRowUpperBound(int i, Value value); alpar@484: virtual Value _getRowUpperBound(int i) const; alpar@484: alpar@484: virtual void _setObjCoeffs(ExprIterator, ExprIterator); alpar@484: virtual void _getObjCoeffs(InsertIterator) const; alpar@484: alpar@484: virtual void _setObjCoeff(int i, Value obj_coef); alpar@484: virtual Value _getObjCoeff(int i) const; alpar@484: alpar@484: virtual void _setSense(Sense sense); alpar@484: virtual Sense _getSense() const; alpar@484: alpar@484: virtual SolveExitStatus _solve(); alpar@484: alpar@484: virtual Value _getPrimal(int i) const; alpar@484: virtual Value _getDual(int i) const; alpar@484: alpar@484: virtual Value _getPrimalValue() const; alpar@484: alpar@484: virtual Value _getPrimalRay(int i) const; alpar@484: virtual Value _getDualRay(int i) const; alpar@484: alpar@484: virtual VarStatus _getColStatus(int i) const; alpar@484: virtual VarStatus _getRowStatus(int i) const; alpar@484: alpar@484: virtual ProblemType _getPrimalType() const; alpar@484: virtual ProblemType _getDualType() const; alpar@484: alpar@484: virtual void _clear(); alpar@484: deba@623: virtual void _messageLevel(MessageLevel); alpar@1081: alpar@484: public: alpar@484: alpar@484: ///Solves LP with primal simplex method. alpar@484: SolveExitStatus solvePrimal(); alpar@484: alpar@484: ///Solves LP with dual simplex method. alpar@484: SolveExitStatus solveDual(); alpar@484: alpar@484: ///Solves LP with barrier method. alpar@484: SolveExitStatus solveBarrier(); alpar@484: alpar@484: ///Returns the constraint identifier understood by CLP. alpar@484: int clpRow(Row r) const { return rows(id(r)); } alpar@484: alpar@484: ///Returns the variable identifier understood by CLP. alpar@484: int clpCol(Col c) const { return cols(id(c)); } alpar@484: alpar@484: }; alpar@484: alpar@484: } //END OF NAMESPACE LEMON alpar@484: alpar@484: #endif //LEMON_CLP_H alpar@484: