Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

LPSolver.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Array.h>
35 #include <ogdf/external/coin.h>
36 
37 
38 namespace ogdf {
39 
41 {
42 public:
43  enum class OptimizationGoal { Minimize, Maximize };
44  enum class Status { Optimal, Infeasible, Unbounded };
45 
46  // Constructor
47  LPSolver();
48  ~LPSolver() { delete osi; }
49 
50  double infinity() const;
51 
52  // Call of LP solver
53  //
54  // Input is an optimization goal, an objective function, a matrix in sparse format, an
55  // equation-sense, and a right-hand side.
56  // The arrays have to be allocated as follows:
57  //
58  // double obj [numCols]
59  // int matrixBegin [numCols]
60  // int matrixCount [numCols]
61  // int matrixIndex [numNonzeroes]
62  // double matrixValue [numNonzeroes]
63  // double rightHandSide [numRows]
64  // char equationSense [numRows]
65  // double lowerBound [numCols]
66  // double upperBound [numCols]
67  // double x [numCols]
68  //
69  // The return value indicates the status of the solution. If an optimum solitions has
70  // been found, the result is Optimal
71 
72  Status optimize(
73  OptimizationGoal goal, // goal of optimization (minimize or maximize)
74  Array<double> &obj, // objective function vector
75  Array<int> &matrixBegin, // matrixBegin[i] = begin of column i
76  Array<int> &matrixCount, // matrixCount[i] = number of nonzeroes in column i
77  Array<int> &matrixIndex, // matrixIndex[n] = index of matrixValue[n] in its column
78  Array<double> &matrixValue, // matrixValue[n] = non-zero value in matrix
79  Array<double> &rightHandSide, // right-hand side of LP constraints
80  Array<char> &equationSense, // 'E' == 'G' >= 'L' <=
81  Array<double> &lowerBound, // lower bound of x[i]
82  Array<double> &upperBound, // upper bound of x[i]
83  double &optimum, // optimum value of objective function (if result is Optimal)
84  Array<double> &x // x-vector of optimal solution (if result is Optimal)
85  );
86 
87  bool checkFeasibility(
88  const Array<int> &matrixBegin, // matrixBegin[i] = begin of column i
89  const Array<int> &matrixCount, // matrixCount[i] = number of nonzeroes in column i
90  const Array<int> &matrixIndex, // matrixIndex[n] = index of matrixValue[n] in its column
91  const Array<double> &matrixValue, // matrixValue[n] = non-zero value in matrix
92  const Array<double> &rightHandSide, // right-hand side of LP constraints
93  const Array<char> &equationSense, // 'E' == 'G' >= 'L' <=
94  const Array<double> &lowerBound, // lower bound of x[i]
95  const Array<double> &upperBound, // upper bound of x[i]
96  const Array<double> &x // x-vector of optimal solution (if result is Optimal)
97  ) const;
98 
99 private:
100  OsiSolverInterface* osi;
101 };
102 
103 
104 }
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
Declaration and implementation of Array class and Array algorithms.
OsiSolverInterface * osi
Definition: LPSolver.h:100
Definition of ogdf::CoinManager.
The namespace for all OGDF objects.