6 * $Date: 2012-07-02 20:59:27 +0200 (Mon, 02 Jul 2012) $
7 ***************************************************************/
10 * \brief Coin implementation of class LPSolver
15 * This file is part of the Open Graph Drawing Framework (OGDF).
19 * See README.txt in the root directory of the OGDF installation for details.
22 * This program is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU General Public License
24 * Version 2 or 3 as published by the Free Software Foundation;
25 * see the file LICENSE.txt included in the packaging of this file
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public
36 * License along with this program; if not, write to the Free
37 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
38 * Boston, MA 02110-1301, USA.
40 * \see http://www.gnu.org/copyleft/gpl.html
41 ***************************************************************/
49 #ifndef OGDF_LPSOLVER_COIN_H
50 #define OGDF_LPSOLVER_COIN_H
52 #include <ogdf/basic/Array.h>
53 #include <ogdf/external/coin.h>
58 class OGDF_EXPORT LPSolver
61 enum OptimizationGoal
{ lpMinimize
, lpMaximize
};
62 enum Status
{ lpOptimal
, lpInfeasible
, lpUnbounded
};
66 ~LPSolver() { delete osi
; }
68 double infinity() const;
72 // Input is an optimization goal, an objective function, a matrix in sparse format, an
73 // equation-sense, and a right-hand side.
74 // The arrays have to be allocated as follows:
76 // double obj [numCols]
77 // int matrixBegin [numCols]
78 // int matrixCount [numCols]
79 // int matrixIndex [numNonzeroes]
80 // double matrixValue [numNonzeroes]
81 // double rightHandSide [numRows]
82 // char equationSense [numRows]
83 // double lowerBound [numCols]
84 // double upperBound [numCols]
87 // The return value indicates the status of the solution. If an optimum solitions has
88 // been found, the result is lpOptimal
91 OptimizationGoal goal
, // goal of optimization (minimize or maximize)
92 Array
<double> &obj
, // objective function vector
93 Array
<int> &matrixBegin
, // matrixBegin[i] = begin of column i
94 Array
<int> &matrixCount
, // matrixCount[i] = number of nonzeroes in column i
95 Array
<int> &matrixIndex
, // matrixIndex[n] = index of matrixValue[n] in its column
96 Array
<double> &matrixValue
, // matrixValue[n] = non-zero value in matrix
97 Array
<double> &rightHandSide
, // right-hand side of LP constraints
98 Array
<char> &equationSense
, // 'E' == 'G' >= 'L' <=
99 Array
<double> &lowerBound
, // lower bound of x[i]
100 Array
<double> &upperBound
, // upper bound of x[i]
101 double &optimum
, // optimum value of objective function (if result is lpOptimal)
102 Array
<double> &x
// x-vector of optimal solution (if result is lpOptimal)
105 bool checkFeasibility(
106 const Array
<int> &matrixBegin
, // matrixBegin[i] = begin of column i
107 const Array
<int> &matrixCount
, // matrixCount[i] = number of nonzeroes in column i
108 const Array
<int> &matrixIndex
, // matrixIndex[n] = index of matrixValue[n] in its column
109 const Array
<double> &matrixValue
, // matrixValue[n] = non-zero value in matrix
110 const Array
<double> &rightHandSide
, // right-hand side of LP constraints
111 const Array
<char> &equationSense
, // 'E' == 'G' >= 'L' <=
112 const Array
<double> &lowerBound
, // lower bound of x[i]
113 const Array
<double> &upperBound
, // upper bound of x[i]
114 const Array
<double> &x
// x-vector of optimal solution (if result is lpOptimal)
118 OsiSolverInterface
* osi
;