1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/lemon/lp_skeleton.h Tue Dec 02 21:40:33 2008 +0100
1.3 @@ -0,0 +1,183 @@
1.4 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
1.5 + *
1.6 + * This file is a part of LEMON, a generic C++ optimization library.
1.7 + *
1.8 + * Copyright (C) 2003-2008
1.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 + *
1.12 + * Permission to use, modify and distribute this software is granted
1.13 + * provided that this copyright notice appears in all copies. For
1.14 + * precise terms see the accompanying LICENSE file.
1.15 + *
1.16 + * This software is provided "AS IS" with no warranty of any kind,
1.17 + * express or implied, and with no claim as to its suitability for any
1.18 + * purpose.
1.19 + *
1.20 + */
1.21 +
1.22 +#ifndef LEMON_LP_SKELETON
1.23 +#define LEMON_LP_SKELETON
1.24 +
1.25 +#include <lemon/lp_base.h>
1.26 +
1.27 +///\file
1.28 +///\brief A skeleton file to implement LP solver interfaces
1.29 +namespace lemon {
1.30 +
1.31 + ///A skeleton class to implement LP solver interfaces
1.32 + class LpSkeleton :public LpSolverBase {
1.33 + int col_num,row_num;
1.34 +
1.35 + protected:
1.36 +
1.37 + ///\e
1.38 + virtual LpSolverBase* _newLp();
1.39 + ///\e
1.40 + virtual LpSolverBase* _copyLp();
1.41 + /// \e
1.42 + virtual int _addCol();
1.43 + /// \e
1.44 + virtual int _addRow();
1.45 + /// \e
1.46 + virtual void _eraseCol(int i);
1.47 + /// \e
1.48 + virtual void _eraseRow(int i);
1.49 + /// \e
1.50 + virtual void _getColName(int col, std::string & name) const;
1.51 + /// \e
1.52 + virtual void _setColName(int col, const std::string & name);
1.53 + /// \e
1.54 + virtual int _colByName(const std::string& name) const;
1.55 +
1.56 + /// \e
1.57 + virtual void _setRowCoeffs(int i, ConstRowIterator b, ConstRowIterator e);
1.58 + /// \e
1.59 + virtual void _getRowCoeffs(int i, RowIterator b) const;
1.60 + /// \e
1.61 + virtual void _setColCoeffs(int i, ConstColIterator b, ConstColIterator e);
1.62 + /// \e
1.63 + virtual void _getColCoeffs(int i, ColIterator b) const;
1.64 +
1.65 + /// Set one element of the coefficient matrix
1.66 + virtual void _setCoeff(int row, int col, Value value);
1.67 +
1.68 + /// Get one element of the coefficient matrix
1.69 + virtual Value _getCoeff(int row, int col) const;
1.70 +
1.71 + /// The lower bound of a variable (column) have to be given by an
1.72 + /// extended number of type Value, i.e. a finite number of type
1.73 + /// Value or -\ref INF.
1.74 + virtual void _setColLowerBound(int i, Value value);
1.75 + /// \e
1.76 +
1.77 + /// The lower bound of a variable (column) is an
1.78 + /// extended number of type Value, i.e. a finite number of type
1.79 + /// Value or -\ref INF.
1.80 + virtual Value _getColLowerBound(int i) const;
1.81 +
1.82 + /// The upper bound of a variable (column) have to be given by an
1.83 + /// extended number of type Value, i.e. a finite number of type
1.84 + /// Value or \ref INF.
1.85 + virtual void _setColUpperBound(int i, Value value);
1.86 + /// \e
1.87 +
1.88 + /// The upper bound of a variable (column) is an
1.89 + /// extended number of type Value, i.e. a finite number of type
1.90 + /// Value or \ref INF.
1.91 + virtual Value _getColUpperBound(int i) const;
1.92 +
1.93 +// /// The lower bound of a linear expression (row) have to be given by an
1.94 +// /// extended number of type Value, i.e. a finite number of type
1.95 +// /// Value or -\ref INF.
1.96 +// virtual void _setRowLowerBound(int i, Value value);
1.97 +// /// \e
1.98 +
1.99 +// /// The upper bound of a linear expression (row) have to be given by an
1.100 +// /// extended number of type Value, i.e. a finite number of type
1.101 +// /// Value or \ref INF.
1.102 +// virtual void _setRowUpperBound(int i, Value value);
1.103 +
1.104 + /// The lower and upper bound of a linear expression (row) have to be
1.105 + /// given by an
1.106 + /// extended number of type Value, i.e. a finite number of type
1.107 + /// Value or +/-\ref INF.
1.108 + virtual void _setRowBounds(int i, Value lb, Value ub);
1.109 + /// \e
1.110 +
1.111 +
1.112 + /// The lower and the upper bound of
1.113 + /// a constraint (row) are
1.114 + /// extended numbers of type Value, i.e. finite numbers of type
1.115 + /// Value, -\ref INF or \ref INF.
1.116 + virtual void _getRowBounds(int i, Value &lb, Value &ub) const;
1.117 + /// \e
1.118 +
1.119 +
1.120 + /// \e
1.121 + virtual void _clearObj();
1.122 + /// \e
1.123 + virtual void _setObjCoeff(int i, Value obj_coef);
1.124 +
1.125 + /// \e
1.126 + virtual Value _getObjCoeff(int i) const;
1.127 +
1.128 + ///\e
1.129 +
1.130 + ///\bug Wrong interface
1.131 + ///
1.132 + virtual SolveExitStatus _solve();
1.133 +
1.134 + ///\e
1.135 +
1.136 + ///\bug Wrong interface
1.137 + ///
1.138 + virtual Value _getPrimal(int i) const;
1.139 +
1.140 + ///\e
1.141 +
1.142 + ///\bug Wrong interface
1.143 + ///
1.144 + virtual Value _getDual(int i) const;
1.145 +
1.146 + ///\e
1.147 +
1.148 + ///\bug Wrong interface
1.149 + ///
1.150 + virtual Value _getPrimalValue() const;
1.151 +
1.152 + ///\e
1.153 +
1.154 + ///\bug Wrong interface
1.155 + ///
1.156 + virtual SolutionStatus _getPrimalStatus() const;
1.157 +
1.158 + ////e
1.159 + virtual SolutionStatus _getDualStatus() const;
1.160 +
1.161 +
1.162 + ///\e
1.163 + virtual ProblemTypes _getProblemType() const;
1.164 +
1.165 + ///\e
1.166 + virtual void _setMax();
1.167 + ///\e
1.168 + virtual void _setMin();
1.169 +
1.170 + ///\e
1.171 + virtual bool _isMax() const;
1.172 +
1.173 +
1.174 +
1.175 + ///\e
1.176 + virtual bool _isBasicCol(int i) const;
1.177 +
1.178 +
1.179 +
1.180 + public:
1.181 + LpSkeleton() : LpSolverBase(), col_num(0), row_num(0) {}
1.182 + };
1.183 +
1.184 +} //namespace lemon
1.185 +
1.186 +#endif // LEMON_LP_SKELETON