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 
36 #include <ogdf/external/coin.h>
37 
38 namespace ogdf {
39 
41 public:
42  enum class OptimizationGoal { Minimize, Maximize };
43  enum class Status { Optimal, Infeasible, Unbounded };
44 
45  // Constructor
46  LPSolver();
47 
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(OptimizationGoal goal, // goal of optimization (minimize or maximize)
73  Array<double>& obj, // objective function vector
74  Array<int>& matrixBegin, // matrixBegin[i] = begin of column i
75  Array<int>& matrixCount, // matrixCount[i] = number of nonzeroes in column i
76  Array<int>& matrixIndex, // matrixIndex[n] = index of matrixValue[n] in its column
77  Array<double>& matrixValue, // matrixValue[n] = non-zero value in matrix
78  Array<double>& rightHandSide, // right-hand side of LP constraints
79  Array<char>& equationSense, // 'E' == 'G' >= 'L' <=
80  Array<double>& lowerBound, // lower bound of x[i]
81  Array<double>& upperBound, // upper bound of x[i]
82  double& optimum, // optimum value of objective function (if result is Optimal)
83  Array<double>& x // x-vector of optimal solution (if result is Optimal)
84  );
85 
86  bool checkFeasibility(const Array<int>& matrixBegin, // matrixBegin[i] = begin of column i
87  const Array<int>& matrixCount, // matrixCount[i] = number of nonzeroes in column i
88  const Array<int>& matrixIndex, // matrixIndex[n] = index of matrixValue[n] in its column
89  const Array<double>& matrixValue, // matrixValue[n] = non-zero value in matrix
90  const Array<double>& rightHandSide, // right-hand side of LP constraints
91  const Array<char>& equationSense, // 'E' == 'G' >= 'L' <=
92  const Array<double>& lowerBound, // lower bound of x[i]
93  const Array<double>& upperBound, // upper bound of x[i]
94  const Array<double>& x // x-vector of optimal solution (if result is Optimal)
95  ) const;
96 
97 private:
98  OsiSolverInterface* osi;
99 };
100 
101 
102 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::LPSolver::Status
Status
Definition: LPSolver.h:43
ogdf::matching_blossom::infinity
TWeight infinity()
Helper function to get the maximum value for a given weight type.
Definition: utils.h:43
ogdf::LPSolver::~LPSolver
~LPSolver()
Definition: LPSolver.h:48
ogdf::LPSolver
Definition: LPSolver.h:40
coin.h
Definition of ogdf::CoinManager.
ogdf::Array< double >
ogdf::LPSolver::osi
OsiSolverInterface * osi
Definition: LPSolver.h:98
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:42