OpenMS
2.6.0
|
#include <OpenMS/DATASTRUCTURES/LPWrapper.h>
Classes | |
struct | SolverParam |
Struct that holds the parameters of the LP solver. More... | |
Public Types | |
enum | Type { UNBOUNDED = 1, LOWER_BOUND_ONLY, UPPER_BOUND_ONLY, DOUBLE_BOUNDED, FIXED } |
enum | VariableType { CONTINUOUS = 1, INTEGER, BINARY } |
enum | Sense { MIN = 1, MAX } |
enum | WriteFormat { FORMAT_LP = 0, FORMAT_MPS, FORMAT_GLPK } |
enum | SOLVER { SOLVER_GLPK = 0 } |
enum | SolverStatus { UNDEFINED = 1, OPTIMAL = 5, FEASIBLE = 2, NO_FEASIBLE_SOL = 4 } |
Public Member Functions | |
LPWrapper () | |
virtual | ~LPWrapper () |
Int | addRow (const std::vector< Int > &row_indices, const std::vector< double > &row_values, const String &name) |
adds a row to the LP matrix, returns index More... | |
Int | addColumn () |
adds an empty column to the LP matrix, returns index More... | |
Int | addColumn (const std::vector< Int > &column_indices, const std::vector< double > &column_values, const String &name) |
adds a column to the LP matrix, returns index More... | |
Int | addRow (const std::vector< Int > &row_indices, const std::vector< double > &row_values, const String &name, double lower_bound, double upper_bound, Type type) |
Adds a row with boundaries to the LP matrix, returns index. More... | |
Int | addColumn (const std::vector< Int > &column_indices, const std::vector< double > &column_values, const String &name, double lower_bound, double upper_bound, Type type) |
Adds a column with boundaries to the LP matrix, returns index. More... | |
void | deleteRow (Int index) |
delete index-th row More... | |
void | setColumnName (Int index, const String &name) |
sets name of the index-th column More... | |
String | getColumnName (Int index) |
gets name of the index-th column More... | |
String | getRowName (Int index) |
sets name of the index-th row More... | |
Int | getRowIndex (const String &name) |
gets index of the row with name More... | |
Int | getColumnIndex (const String &name) |
gets index of the column with name More... | |
double | getColumnUpperBound (Int index) |
gets column's upper bound More... | |
double | getColumnLowerBound (Int index) |
gets column's lower bound More... | |
double | getRowUpperBound (Int index) |
gets row's upper bound More... | |
double | getRowLowerBound (Int index) |
gets row's lower bound More... | |
void | setRowName (Int index, const String &name) |
sets name of the index-th row More... | |
void | setColumnBounds (Int index, double lower_bound, double upper_bound, Type type) |
Set column bounds. More... | |
void | setRowBounds (Int index, double lower_bound, double upper_bound, Type type) |
Set row bounds. More... | |
void | setColumnType (Int index, VariableType type) |
Set column/variable type. More... | |
VariableType | getColumnType (Int index) |
Get column/variable type. More... | |
void | setObjective (Int index, double obj_value) |
set objective value for column with index More... | |
double | getObjective (Int index) |
get objective value for column with index More... | |
void | setObjectiveSense (Sense sense) |
Set objective direction. More... | |
Sense | getObjectiveSense () |
Int | getNumberOfColumns () |
get number of columns More... | |
Int | getNumberOfRows () |
get number of rows More... | |
void | setElement (Int row_index, Int column_index, double value) |
double | getElement (Int row_index, Int column_index) |
void | readProblem (const String &filename, const String &format) |
Read LP from file. More... | |
void | writeProblem (const String &filename, const WriteFormat format) const |
Write LP formulation to a file. More... | |
Int | solve (SolverParam &solver_param, const Size verbose_level=0) |
solve problems, parameters like enabled heuristics can be given via solver_param More... | |
SolverStatus | getStatus () |
Get solution status. More... | |
double | getObjectiveValue () |
double | getColumnValue (Int index) |
Int | getNumberOfNonZeroEntriesInRow (Int idx) |
void | getMatrixRow (Int idx, std::vector< Int > &indexes) |
SOLVER | getSolver () const |
get currently active solver More... | |
Protected Attributes | |
glp_prob * | lp_problem_ = nullptr |
SOLVER | solver_ |
enum Sense |
enum SOLVER |
enum SolverStatus |
enum Type |
enum VariableType |
enum WriteFormat |
LPWrapper | ( | ) |
|
virtual |
Int addColumn | ( | ) |
adds an empty column to the LP matrix, returns index
Int addColumn | ( | const std::vector< Int > & | column_indices, |
const std::vector< double > & | column_values, | ||
const String & | name | ||
) |
adds a column to the LP matrix, returns index
Int addColumn | ( | const std::vector< Int > & | column_indices, |
const std::vector< double > & | column_values, | ||
const String & | name, | ||
double | lower_bound, | ||
double | upper_bound, | ||
Type | type | ||
) |
Adds a column with boundaries to the LP matrix, returns index.
column_indices | |
column_values | |
name | |
lower_bound | |
upper_bound | |
type | 1 - unbounded, 2 - only lower bound, 3 - only upper bound, 4 - double-bounded variable, 5 - fixed variable |
Int addRow | ( | const std::vector< Int > & | row_indices, |
const std::vector< double > & | row_values, | ||
const String & | name | ||
) |
adds a row to the LP matrix, returns index
Int addRow | ( | const std::vector< Int > & | row_indices, |
const std::vector< double > & | row_values, | ||
const String & | name, | ||
double | lower_bound, | ||
double | upper_bound, | ||
Type | type | ||
) |
Adds a row with boundaries to the LP matrix, returns index.
If you have a fixed variable, GLPK requires to use the "fixed" type, instead of "double-bounded" with equal bounds.
row_indices | |
row_values | |
name | |
lower_bound | |
upper_bound | |
type | Type of the row 1 - unbounded, 2 - only lower bound, 3 - only upper bound, 4 - double-bounded variable, 5 - fixed variable |
void deleteRow | ( | Int | index | ) |
delete index-th row
VariableType getColumnType | ( | Int | index | ) |
Get column/variable type.
index |
Int getNumberOfColumns | ( | ) |
get number of columns
Int getNumberOfRows | ( | ) |
get number of rows
Sense getObjectiveSense | ( | ) |
double getObjectiveValue | ( | ) |
SOLVER getSolver | ( | ) | const |
get currently active solver
SolverStatus getStatus | ( | ) |
Get solution status.
Read LP from file.
filename | Filename where to store the LP problem. |
format | LP, MPS or GLPK. |
Set column bounds.
index | |
lower_bound | |
upper_bound | |
type | 1 - unbounded, 2 - only lower bound, 3 - only upper bound, 4 - double-bounded variable, 5 - fixed variable |
void setColumnType | ( | Int | index, |
VariableType | type | ||
) |
Set column/variable type.
index | |
type | 1- continuous, 2- integer, 3- binary variable |
void setObjectiveSense | ( | Sense | sense | ) |
Set objective direction.
sense | 1- minimize, 2- maximize |
Set row bounds.
index | |
lower_bound | |
upper_bound | |
type | 1 - unbounded, 2 - only lower bound, 3 - only upper bound, 4 - double-bounded variable, 5 - fixed constraint |
Int solve | ( | SolverParam & | solver_param, |
const Size | verbose_level = 0 |
||
) |
solve problems, parameters like enabled heuristics can be given via solver_param
The verbose level (0,1,2) determines if the solver prints status messages and internals.
solver_param | |
verbose_level |
void writeProblem | ( | const String & | filename, |
const WriteFormat | format | ||
) | const |
Write LP formulation to a file.
filename | output filename, if the filename ends with '.gz' it will be compressed |
format | MPS-format is supported by GLPK and COIN-OR; LP and GLPK-formats only by GLPK |
|
protected |
|
protected |