deba@458: /* -*- mode: C++; indent-tabs-mode: nil; -*- deba@458: * deba@458: * This file is a part of LEMON, a generic C++ optimization library. deba@458: * deba@458: * Copyright (C) 2003-2008 deba@458: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport deba@458: * (Egervary Research Group on Combinatorial Optimization, EGRES). deba@458: * deba@458: * Permission to use, modify and distribute this software is granted deba@458: * provided that this copyright notice appears in all copies. For deba@458: * precise terms see the accompanying LICENSE file. deba@458: * deba@458: * This software is provided "AS IS" with no warranty of any kind, deba@458: * express or implied, and with no claim as to its suitability for any deba@458: * purpose. deba@458: * deba@458: */ deba@458: deba@529: #ifndef LEMON_LP_SKELETON_H deba@529: #define LEMON_LP_SKELETON_H deba@458: deba@458: #include deba@458: deba@458: ///\file alpar@540: ///\brief Skeleton file to implement LP/MIP solver interfaces alpar@540: /// alpar@540: ///The classes in this file do nothing, but they can serve as skeletons when alpar@540: ///implementing an interface to new solvers. deba@458: namespace lemon { deba@458: alpar@540: ///A skeleton class to implement LP/MIP solver base interface alpar@540: alpar@540: ///This class does nothing, but it can serve as a skeleton when alpar@540: ///implementing an interface to new solvers. deba@459: class SkeletonSolverBase : public virtual LpBase { deba@458: int col_num,row_num; deba@458: deba@458: protected: deba@458: deba@459: SkeletonSolverBase() deba@459: : col_num(-1), row_num(-1) {} deba@459: deba@458: /// \e deba@458: virtual int _addCol(); deba@458: /// \e deba@458: virtual int _addRow(); deba@458: /// \e deba@458: virtual void _eraseCol(int i); deba@458: /// \e deba@458: virtual void _eraseRow(int i); deba@459: deba@458: /// \e deba@459: virtual void _getColName(int col, std::string& name) const; deba@458: /// \e deba@459: virtual void _setColName(int col, const std::string& name); deba@458: /// \e deba@458: virtual int _colByName(const std::string& name) const; deba@458: deba@458: /// \e deba@459: virtual void _getRowName(int row, std::string& name) const; deba@458: /// \e deba@459: virtual void _setRowName(int row, const std::string& name); deba@458: /// \e deba@459: virtual int _rowByName(const std::string& name) const; deba@459: deba@458: /// \e deba@459: virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e); deba@459: /// \e deba@459: virtual void _getRowCoeffs(int i, InsertIterator b) const; deba@459: /// \e deba@459: virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e); deba@459: /// \e deba@459: virtual void _getColCoeffs(int i, InsertIterator b) const; deba@458: deba@458: /// Set one element of the coefficient matrix deba@458: virtual void _setCoeff(int row, int col, Value value); deba@458: deba@458: /// Get one element of the coefficient matrix deba@458: virtual Value _getCoeff(int row, int col) const; deba@458: deba@458: /// The lower bound of a variable (column) have to be given by an deba@458: /// extended number of type Value, i.e. a finite number of type deba@458: /// Value or -\ref INF. deba@458: virtual void _setColLowerBound(int i, Value value); deba@458: /// \e deba@458: deba@458: /// The lower bound of a variable (column) is an deba@458: /// extended number of type Value, i.e. a finite number of type deba@458: /// Value or -\ref INF. deba@458: virtual Value _getColLowerBound(int i) const; deba@458: deba@458: /// The upper bound of a variable (column) have to be given by an deba@458: /// extended number of type Value, i.e. a finite number of type deba@458: /// Value or \ref INF. deba@458: virtual void _setColUpperBound(int i, Value value); deba@458: /// \e deba@458: deba@458: /// The upper bound of a variable (column) is an deba@458: /// extended number of type Value, i.e. a finite number of type deba@458: /// Value or \ref INF. deba@458: virtual Value _getColUpperBound(int i) const; deba@458: deba@459: /// The lower bound of a constraint (row) have to be given by an deba@458: /// extended number of type Value, i.e. a finite number of type deba@459: /// Value or -\ref INF. deba@459: virtual void _setRowLowerBound(int i, Value value); deba@458: /// \e deba@458: deba@459: /// The lower bound of a constraint (row) is an deba@459: /// extended number of type Value, i.e. a finite number of type deba@459: /// Value or -\ref INF. deba@459: virtual Value _getRowLowerBound(int i) const; deba@458: deba@459: /// The upper bound of a constraint (row) have to be given by an deba@459: /// extended number of type Value, i.e. a finite number of type deba@459: /// Value or \ref INF. deba@459: virtual void _setRowUpperBound(int i, Value value); deba@458: /// \e deba@458: deba@459: /// The upper bound of a constraint (row) is an deba@459: /// extended number of type Value, i.e. a finite number of type deba@459: /// Value or \ref INF. deba@459: virtual Value _getRowUpperBound(int i) const; deba@458: deba@458: /// \e deba@459: virtual void _setObjCoeffs(ExprIterator b, ExprIterator e); deba@459: /// \e deba@459: virtual void _getObjCoeffs(InsertIterator b) const; deba@459: deba@458: /// \e deba@458: virtual void _setObjCoeff(int i, Value obj_coef); deba@458: /// \e deba@458: virtual Value _getObjCoeff(int i) const; deba@458: deba@458: ///\e deba@459: virtual void _setSense(Sense); deba@459: ///\e deba@459: virtual Sense _getSense() const; deba@459: deba@459: ///\e deba@459: virtual void _clear(); deba@459: deba@576: ///\e deba@576: virtual void _messageLevel(MessageLevel); deba@459: }; deba@459: alpar@540: /// \brief Skeleton class for an LP solver interface deba@459: /// alpar@540: ///This class does nothing, but it can serve as a skeleton when alpar@540: ///implementing an interface to new solvers. alpar@540: deba@459: ///\ingroup lp_group alpar@540: class LpSkeleton : public LpSolver, public SkeletonSolverBase { deba@459: public: alpar@540: ///\e alpar@540: LpSkeleton() : LpSolver(), SkeletonSolverBase() {} alpar@540: ///\e alpar@540: virtual LpSkeleton* newSolver() const; alpar@540: ///\e alpar@540: virtual LpSkeleton* cloneSolver() const; deba@459: protected: deba@459: deba@459: ///\e deba@459: virtual SolveExitStatus _solve(); deba@459: deba@459: ///\e deba@459: virtual Value _getPrimal(int i) const; deba@459: ///\e deba@459: virtual Value _getDual(int i) const; deba@459: deba@459: ///\e deba@459: virtual Value _getPrimalValue() const; deba@459: deba@459: ///\e deba@459: virtual Value _getPrimalRay(int i) const; deba@459: ///\e deba@459: virtual Value _getDualRay(int i) const; deba@459: deba@459: ///\e deba@459: virtual ProblemType _getPrimalType() const; deba@459: ///\e deba@459: virtual ProblemType _getDualType() const; deba@459: deba@459: ///\e deba@459: virtual VarStatus _getColStatus(int i) const; deba@459: ///\e deba@459: virtual VarStatus _getRowStatus(int i) const; deba@459: deba@459: ///\e deba@459: virtual const char* _solverName() const; deba@459: deba@459: }; deba@459: alpar@540: /// \brief Skeleton class for a MIP solver interface deba@459: /// alpar@540: ///This class does nothing, but it can serve as a skeleton when alpar@540: ///implementing an interface to new solvers. deba@459: ///\ingroup lp_group alpar@540: class MipSkeleton : public MipSolver, public SkeletonSolverBase { deba@459: public: alpar@540: ///\e alpar@540: MipSkeleton() : MipSolver(), SkeletonSolverBase() {} alpar@540: ///\e alpar@540: virtual MipSkeleton* newSolver() const; alpar@540: ///\e alpar@540: virtual MipSkeleton* cloneSolver() const; deba@459: deba@459: protected: deba@459: ///\e deba@458: virtual SolveExitStatus _solve(); deba@458: deba@458: ///\e deba@459: virtual Value _getSol(int i) const; deba@458: deba@458: ///\e deba@459: virtual Value _getSolValue() const; deba@458: deba@458: ///\e deba@459: virtual ProblemType _getType() const; deba@458: deba@458: ///\e deba@459: virtual const char* _solverName() const; deba@458: }; deba@458: deba@458: } //namespace lemon deba@458: deba@529: #endif