|
Project
|
External linear solver wrapper. More...
#include <LinearSolver.h>
Public Member Functions | |
| LinearSolver (AlternativesPerformance &ap, Config &conf, float delta=0.000001, std::string solver="GLOP") | |
| void | initializeSolver () |
| void | updateConstraints (std::vector< std::vector< std::vector< bool >>> x_matrix, std::vector< std::vector< std::vector< bool >>> y_matrix) |
| std::pair< float, std::vector< float > > | solve (std::vector< std::vector< std::vector< bool >>> x_matrix, std::vector< std::vector< std::vector< bool >>> y_matrix) |
| AlternativesPerformance & | getAlternativesPerformance () const |
| operations_research::MPSolver * | getSolver () const |
| std::vector< operations_research::MPVariable * > | getWeights () const |
| std::vector< operations_research::MPVariable * > | getXa () const |
| std::vector< operations_research::MPVariable * > | getXap () const |
| std::vector< operations_research::MPVariable * > | getYa () const |
| std::vector< operations_research::MPVariable * > | getYap () const |
| Config | getConf () const |
External linear solver wrapper.
The linear solver class is a wrapper that makes an abstraction between the weight updater and the resolution of the linear problem. Currently this wrapper uses ortools interface and only the ortools solver (GLOP) is implemented. Other solver could be used by following the instruction on how to install them for ortools and changing the initialisation of the solver to use the right one, however the implementation of the resolution shouldn't have to be changed.
The abstraction was made by receiving the constraint matrices according to the equations described in the thesis and returning the solution found for the new weights and lambda.
Link to ortools (google) : https://github.com/google/or-tools
| LinearSolver::LinearSolver | ( | AlternativesPerformance & | ap, |
| Config & | conf, | ||
| float | delta = 0.000001, |
||
| std::string | solver = "GLOP" |
||
| ) |
LinearSolver standard constructor.
| ap | AlternativesPerformance objet that represents the dataset of the problem |
| config | config setup from the app |
| solver | solver type to use. Currently only "GLOP" is implemented |
| AlternativesPerformance& LinearSolver::getAlternativesPerformance | ( | ) | const |
getAlternativesPerformance getter of the alternative performance
| Config LinearSolver::getConf | ( | ) | const |
getConf getter of the conf
| operations_research::MPSolver* LinearSolver::getSolver | ( | ) | const |
getSolver getter of the solver
| std::vector<operations_research::MPVariable *> LinearSolver::getWeights | ( | ) | const |
getWeights getter of the weights
| std::vector<operations_research::MPVariable *> LinearSolver::getXa | ( | ) | const |
getXa getter of the x_a variables
| std::vector<operations_research::MPVariable *> LinearSolver::getXap | ( | ) | const |
getXap getter of the x_ap variables
| std::vector<operations_research::MPVariable *> LinearSolver::getYa | ( | ) | const |
getYa getter of the y_a variables
| std::vector<operations_research::MPVariable *> LinearSolver::getYap | ( | ) | const |
getYap getter of the y_ap variables
| void LinearSolver::initializeSolver | ( | ) |
initializeSolver Initialise the solver given the alternative performance (dataset): add variables and constraints that are not changing given a particular model.
| std::pair<float, std::vector<float> > LinearSolver::solve | ( | std::vector< std::vector< std::vector< bool >>> | x_matrix, |
| std::vector< std::vector< std::vector< bool >>> | y_matrix | ||
| ) |
solve Solve the linear problem given the constraint matrix.
| x_matrix | matrix recapitulating the constraints to add to the linear problem for the x variables |
| y_matrix | matrix recapitulating the constraints to add to the linear problem for the y variables |
| void LinearSolver::updateConstraints | ( | std::vector< std::vector< std::vector< bool >>> | x_matrix, |
| std::vector< std::vector< std::vector< bool >>> | y_matrix | ||
| ) |
updateConstraints reset the previous constraints and add the new ones given by the matrixes
| x_matrix | matrix recapitulating the constraints to add to the linear problem for the x variables |
| y_matrix | matrix recapitulating the constraints to add to the linear problem for the y variables |