Project
Public Member Functions | List of all members
LinearSolver Class Reference

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)
 
AlternativesPerformancegetAlternativesPerformance () 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
 

Detailed Description

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

Constructor & Destructor Documentation

◆ LinearSolver()

LinearSolver::LinearSolver ( AlternativesPerformance ap,
Config conf,
float  delta = 0.000001,
std::string  solver = "GLOP" 
)

LinearSolver standard constructor.

Parameters
apAlternativesPerformance objet that represents the dataset of the problem
configconfig setup from the app
solversolver type to use. Currently only "GLOP" is implemented

Member Function Documentation

◆ getAlternativesPerformance()

AlternativesPerformance& LinearSolver::getAlternativesPerformance ( ) const

getAlternativesPerformance getter of the alternative performance

Returns
ap

◆ getConf()

Config LinearSolver::getConf ( ) const

getConf getter of the conf

Returns
conf

◆ getSolver()

operations_research::MPSolver* LinearSolver::getSolver ( ) const

getSolver getter of the solver

Returns
solver

◆ getWeights()

std::vector<operations_research::MPVariable *> LinearSolver::getWeights ( ) const

getWeights getter of the weights

Returns
weights

◆ getXa()

std::vector<operations_research::MPVariable *> LinearSolver::getXa ( ) const

getXa getter of the x_a variables

Returns
x_a

◆ getXap()

std::vector<operations_research::MPVariable *> LinearSolver::getXap ( ) const

getXap getter of the x_ap variables

Returns
x_ap

◆ getYa()

std::vector<operations_research::MPVariable *> LinearSolver::getYa ( ) const

getYa getter of the y_a variables

Returns
y_a

◆ getYap()

std::vector<operations_research::MPVariable *> LinearSolver::getYap ( ) const

getYap getter of the y_ap variables

Returns
y_ap

◆ initializeSolver()

void LinearSolver::initializeSolver ( )

initializeSolver Initialise the solver given the alternative performance (dataset): add variables and constraints that are not changing given a particular model.

◆ solve()

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.

Parameters
x_matrixmatrix recapitulating the constraints to add to the linear problem for the x variables
y_matrixmatrix recapitulating the constraints to add to the linear problem for the y variables
Returns
results contained in a pair of (lambda, vector of weights)

◆ updateConstraints()

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

Parameters
x_matrixmatrix recapitulating the constraints to add to the linear problem for the x variables
y_matrixmatrix recapitulating the constraints to add to the linear problem for the y variables

The documentation for this class was generated from the following file: