Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
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
39namespace ogdf {
40
42public:
43 enum class OptimizationGoal { Minimize, Maximize };
44 enum class Status { Optimal, Infeasible, Unbounded };
45
46 // Constructor
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
98private:
99 OsiSolverInterface* osi;
100};
101
102
103}
Declaration and implementation of Array class and Array algorithms.
Basic declarations, included by all source files.
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:219
Status optimize(OptimizationGoal goal, Array< double > &obj, Array< int > &matrixBegin, Array< int > &matrixCount, Array< int > &matrixIndex, Array< double > &matrixValue, Array< double > &rightHandSide, Array< char > &equationSense, Array< double > &lowerBound, Array< double > &upperBound, double &optimum, Array< double > &x)
OsiSolverInterface * osi
Definition LPSolver.h:99
bool checkFeasibility(const Array< int > &matrixBegin, const Array< int > &matrixCount, const Array< int > &matrixIndex, const Array< double > &matrixValue, const Array< double > &rightHandSide, const Array< char > &equationSense, const Array< double > &lowerBound, const Array< double > &upperBound, const Array< double > &x) const
double infinity() const
Definition of ogdf::CoinManager.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
The namespace for all OGDF objects.