Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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