00001 /* 00002 * $Revision: 2299 $ 00003 * 00004 * last checkin: 00005 * $Author: gutwenger $ 00006 * $Date: 2012-05-07 15:57:08 +0200 (Mon, 07 May 2012) $ 00007 ***************************************************************/ 00008 00043 #ifdef _MSC_VER 00044 #pragma once 00045 #endif 00046 00047 00048 #ifndef OGDF_LPSOLVER_COIN_H 00049 #define OGDF_LPSOLVER_COIN_H 00050 00051 #include <ogdf/basic/Array.h> 00052 #include <ogdf/external/coin.h> 00053 00054 00055 namespace ogdf { 00056 00057 class OGDF_EXPORT LPSolver 00058 { 00059 public: 00060 enum OptimizationGoal { lpMinimize, lpMaximize }; 00061 enum Status { lpOptimal, lpInfeasible, lpUnbounded }; 00062 00063 // Constructor 00064 LPSolver(); 00065 ~LPSolver() { delete osi; } 00066 00067 double infinity() const; 00068 00069 // Call of LP solver 00070 // 00071 // Input is an optimization goal, an objective function, a matrix in sparse format, an 00072 // equation-sense, and a right-hand side. 00073 // The arrays have to be allocated as follows: 00074 // 00075 // double obj [numCols] 00076 // int matrixBegin [numCols] 00077 // int matrixCount [numCols] 00078 // int matrixIndex [numNonzeroes] 00079 // double matrixValue [numNonzeroes] 00080 // double rightHandSide [numRows] 00081 // char equationSense [numRows] 00082 // double lowerBound [numCols] 00083 // double upperBound [numCols] 00084 // double x [numCols] 00085 // 00086 // The return value indicates the status of the solution. If an optimum solitions has 00087 // been found, the result is lpOptimal 00088 00089 Status optimize( 00090 OptimizationGoal goal, // goal of optimization (minimize or maximize) 00091 Array<double> &obj, // objective function vector 00092 Array<int> &matrixBegin, // matrixBegin[i] = begin of column i 00093 Array<int> &matrixCount, // matrixCount[i] = number of nonzeroes in column i 00094 Array<int> &matrixIndex, // matrixIndex[n] = index of matrixValue[n] in its column 00095 Array<double> &matrixValue, // matrixValue[n] = non-zero value in matrix 00096 Array<double> &rightHandSide, // right-hand side of LP constraints 00097 Array<char> &equationSense, // 'E' == 'G' >= 'L' <= 00098 Array<double> &lowerBound, // lower bound of x[i] 00099 Array<double> &upperBound, // upper bound of x[i] 00100 double &optimum, // optimum value of objective function (if result is lpOptimal) 00101 Array<double> &x // x-vector of optimal solution (if result is lpOptimal) 00102 ); 00103 00104 bool checkFeasibility( 00105 const Array<int> &matrixBegin, // matrixBegin[i] = begin of column i 00106 const Array<int> &matrixCount, // matrixCount[i] = number of nonzeroes in column i 00107 const Array<int> &matrixIndex, // matrixIndex[n] = index of matrixValue[n] in its column 00108 const Array<double> &matrixValue, // matrixValue[n] = non-zero value in matrix 00109 const Array<double> &rightHandSide, // right-hand side of LP constraints 00110 const Array<char> &equationSense, // 'E' == 'G' >= 'L' <= 00111 const Array<double> &lowerBound, // lower bound of x[i] 00112 const Array<double> &upperBound, // upper bound of x[i] 00113 const Array<double> &x // x-vector of optimal solution (if result is lpOptimal) 00114 ); 00115 00116 private: 00117 OsiSolverInterface* osi; 00118 }; 00119 00120 00121 } 00122 00123 00124 #endif