EPEC solve
Solving Equilibrium Problems with Equilibrium Constraints (EPECs)
Public Member Functions | Data Fields | Private Types | Private Member Functions | Private Attributes
Game::LCP Class Reference

Class to handle and solve linear complementarity problems. More...

#include <lcptolp.h>

Public Member Functions

 LCP ()=delete
 Class has no default constructors. More...
 
 LCP (GRBEnv *e)
 
 LCP (GRBEnv *env, arma::sp_mat M, arma::vec q, unsigned int LeadStart, unsigned LeadEnd, arma::sp_mat A={}, arma::vec b={})
 This constructor flor loading LCP from a file. More...
 
 LCP (GRBEnv *env, arma::sp_mat M, arma::vec q, perps Compl, arma::sp_mat A={}, arma::vec b={})
 
 LCP (GRBEnv *env, const Game::NashGame &N)
 Constructer given a NashGame. More...
 
 ~LCP ()
 Destructor of LCP. More...
 
arma::sp_mat getM ()
 Read-only access to LCP::M. More...
 
arma::sp_mat * getMstar ()
 Reference access to LCP::M. More...
 
arma::vec getq ()
 Read-only access to LCP::q. More...
 
arma::vec * getqstar ()
 Reference access to LCP::q. More...
 
unsigned int getLStart ()
 Read-only access to LCP::LeadStart. More...
 
unsigned int getLEnd ()
 Read-only access to LCP::LeadEnd. More...
 
perps getCompl ()
 Read-only access to LCP::Compl. More...
 
void print (std::string end="\)
 Print a summary of the LCP. More...
 
unsigned int getNcol ()
 
unsigned int getNrow ()
 
bool extractSols (GRBModel *model, arma::vec &z, arma::vec &x, bool extractZ=false) const
 Extracts variable and equation values from a solved Gurobi model for LCP. More...
 
std::unique_ptr< GRBModel > LCPasQP (bool solve=false)
 Solves the LCP as a QP using Gurobi. More...
 
std::unique_ptr< GRBModel > LCPasMIP (bool solve=false)
 Helps solving an LCP as an MIP using bigM constraints. More...
 
std::unique_ptr< GRBModel > MPECasMILP (const arma::sp_mat &C, const arma::vec &c, const arma::vec &x_minus_i, bool solve=false)
 Helps solving an LCP as an MIP. More...
 
std::unique_ptr< GRBModel > MPECasMIQP (const arma::sp_mat &Q, const arma::sp_mat &C, const arma::vec &c, const arma::vec &x_minus_i, bool solve=false)
 Helps solving an LCP as an MIQPs. More...
 
unsigned int ConvexHull (arma::sp_mat &A, arma::vec &b)
 
unsigned int conv_Npoly () const
 
unsigned int conv_PolyPosition (const unsigned long int i) const
 
unsigned int conv_PolyWt (const unsigned long int i) const
 
std::set< unsigned long int > getAllPolyhedra () const
 
unsigned long int getNumTheoreticalPoly () const noexcept
 
LCPmakeQP (Game::QP_objective &QP_obj, Game::QP_Param &QP)
 
std::set< std::vector< short int > > addAPoly (unsigned long int nPoly=1, Game::EPECAddPolyMethod method=Game::EPECAddPolyMethod::sequential, std::set< std::vector< short int >> Polys={})
 
bool addThePoly (const unsigned long int &decimalEncoding)
 
bool checkPolyFeas (const unsigned long int &decimalEncoding)
 
bool checkPolyFeas (const std::vector< short int > &Fix)
 
void clearPolyhedra ()
 
LCPaddPolyFromX (const arma::vec &x, bool &ret)
 
LCPEnumerateAll (bool solveLP=true)
 Brute force computation of LCP feasible region. More...
 
std::string feas_detail_str () const
 
unsigned int getFeasiblePolyhedra () const
 
void write (std::string filename, bool append=true) const
 
void save (std::string filename, bool erase=true) const
 
long int load (std::string filename, long int pos=0)
 

Data Fields

long double bigM {1e7}
 bigM used to rewrite the LCP as MIP More...
 
long double eps
 The threshold for optimality and feasability tollerances. More...
 
long double eps_int {1e-8}
 
bool useIndicators
 constraints. BigM formulation otherwise More...
 
long int addPolyMethodSeed
 

Private Types

using spmat_Vec = std::vector< std::unique_ptr< arma::sp_mat > >
 
using vec_Vec = std::vector< std::unique_ptr< arma::vec > >
 

Private Member Functions

bool errorCheck (bool throwErr=true) const
 
void defConst (GRBEnv *env)
 Assign default values to LCP attributes. More...
 
void makeRelaxed ()
 Makes a Gurobi object that relaxes complementarity constraints in an LCP. More...
 
void initializeNotProcessed ()
 
std::unique_ptr< GRBModel > LCPasMIP (std::vector< unsigned int > FixEq={}, std::vector< unsigned int > FixVar={}, bool solve=false)
 
std::unique_ptr< GRBModel > LCPasMIP (std::vector< short int > Fixes, bool solve)
 
std::unique_ptr< GRBModel > LCP_Polyhed_fixed (std::vector< unsigned int > FixEq={}, std::vector< unsigned int > FixVar={})
 
std::unique_ptr< GRBModel > LCP_Polyhed_fixed (arma::Col< int > FixEq, arma::Col< int > FixVar)
 
template<class T >
bool isZero (const T val) const
 
std::vector< short int > solEncode (GRBModel *model) const
 Given a Gurobi model, extracts variable values and equation values, encodes it in 0/+1/-1 format and returns it. More...
 
std::vector< short int > solEncode (const arma::vec &x) const
 Given variable values, encodes it in 0/+1/-1 format and returns it. More...
 
std::vector< short int > solEncode (const arma::vec &z, const arma::vec &x) const
 Given variable values and equation values, encodes it in 0/+1/-1 format and returns it. More...
 
bool FixToPoly (const std::vector< short int > Fix, bool checkFeas=false, bool custom=false, spmat_Vec *custAi={}, vec_Vec *custbi={})
 Computes the equation of the feasibility polyhedron corresponding to the given Fix. More...
 
LCPFixToPolies (const std::vector< short int > Fix, bool checkFeas=false, bool custom=false, spmat_Vec *custAi={}, vec_Vec *custbi={})
 Computes the equation of the feasibility polyhedron corresponding to the given Fix. More...
 
unsigned long int getNextPoly (Game::EPECAddPolyMethod method)
 

Private Attributes

GRBEnv * env
 Gurobi env. More...
 
arma::sp_mat M
 M in $Mx+q$ that defines the LCP. More...
 
arma::vec q
 q in $Mx+q$ that defines the LCP More...
 
perps Compl
 Compl stores data in <Eqn, Var> form. More...
 
unsigned int LeadStart {1}
 
unsigned int LeadEnd {0}
 
unsigned int nLeader {0}
 
arma::sp_mat _A = {}
 
arma::vec _b = {}
 
bool madeRlxdModel {false}
 Keep track if LCP::RlxdModel is made. More...
 
unsigned int nR
 
unsigned int nC
 
int polyCounter {0}
 
unsigned int feasiblePolyhedra {0}
 
unsigned int sequentialPolyCounter {0}
 
int reverseSequentialPolyCounter {0}
 
std::set< unsigned long int > AllPolyhedra
 Decimal encoding of polyhedra that have been enumerated. More...
 
std::set< unsigned long int > feasiblePoly
 Decimal encoding of polyhedra that have been enumerated. More...
 
std::set< unsigned long int > knownInfeas
 Decimal encoding of polyhedra known to be infeasible. More...
 
unsigned long int maxTheoreticalPoly {0}
 
std::unique_ptr< spmat_VecAi
 Vector to contain the LHS of inner approx polyhedra. More...
 
std::unique_ptr< vec_Vecbi
 Vector to contain the RHS of inner approx polyhedra. More...
 
GRBModel RlxdModel
 

Detailed Description

Class to handle and solve linear complementarity problems.

A class to handle linear complementarity problems (LCP) especially as MIPs with bigM constraints Also provides the convex hull of the feasible space, restricted feasible space etc.

Definition at line 41 of file lcptolp.h.

Member Typedef Documentation

◆ spmat_Vec

using Game::LCP::spmat_Vec = std::vector<std::unique_ptr<arma::sp_mat> >
private

Definition at line 42 of file lcptolp.h.

◆ vec_Vec

using Game::LCP::vec_Vec = std::vector<std::unique_ptr<arma::vec> >
private

Definition at line 43 of file lcptolp.h.

Constructor & Destructor Documentation

◆ LCP() [1/5]

Game::LCP::LCP ( )
delete

Class has no default constructors.

Constructors

◆ LCP() [2/5]

Game::LCP::LCP ( GRBEnv *  e)
inline

Definition at line 132 of file lcptolp.h.

◆ LCP() [3/5]

Game::LCP::LCP ( GRBEnv *  env,
arma::sp_mat  M,
arma::vec  q,
unsigned int  LeadStart,
unsigned  LeadEnd,
arma::sp_mat  A = {},
arma::vec  b = {} 
)

This constructor flor loading LCP from a file.

Warning
This might be deprecated to support LCP functioning without sticking to the output format of NashGame
Parameters
envGurobi environment required
MM in $Mx+q$
qq in $Mx+q$
LeadStartPosition where variables which are not complementary to any equation starts
LeadEndPosition where variables which are not complementary to any equation ends
AAny equations without a complemntarity variable
bRHS of equations without complementarity variables

Definition at line 101 of file LCPtoLP.cpp.

◆ LCP() [4/5]

Game::LCP::LCP ( GRBEnv *  env,
arma::sp_mat  M,
arma::vec  q,
perps  Compl,
arma::sp_mat  A = {},
arma::vec  b = {} 
)
Parameters
envGurobi environment required
MM in $Mx+q$
qq in $Mx+q$
ComplPairing equations and variables for complementarity
AAny equations without a complemntarity variable
bRHS of equations without complementarity variables

Definition at line 73 of file LCPtoLP.cpp.

◆ LCP() [5/5]

Game::LCP::LCP ( GRBEnv *  env,
const Game::NashGame N 
)

Constructer given a NashGame.

Given a NashGame, computes the KKT of the lower levels, and makes the appropriate LCP object.

This constructor is the most suited for highlevel usage.
@note Most preferred constructor for user interface.

Definition at line 135 of file LCPtoLP.cpp.

◆ ~LCP()

Game::LCP::~LCP ( )

Destructor of LCP.

Destructor - to delete the objects created with new operator

LCP object owns the pointers to definitions of its polyhedra that it owns It has to be deleted and freed.

Definition at line 174 of file LCPtoLP.cpp.

Member Function Documentation

◆ addAPoly()

std::set< std::vector< short int > > Game::LCP::addAPoly ( unsigned long int  nPoly = 1,
Game::EPECAddPolyMethod  method = Game::EPECAddPolyMethod::sequential,
std::set< std::vector< short int >>  Polys = {} 
)

Tries to add at most nPoly number of polyhedra to the inner approximation representation of the current LCP. The set of added polyhedra (+1/-1 encoding) is appended to Polys and returned. The only reason fewer polyhedra might be added is that the fewer polyhedra already represent the feasible region of the LCP. method is casted from Game::EPEC::EPECAddPolyMethod

Definition at line 1169 of file LCPtoLP.cpp.

◆ addPolyFromX()

LCP & Game::LCP::addPolyFromX ( const arma::vec &  x,
bool &  ret 
)

Given a feasible point x, checks if any polyhedron that contains x is already a part of this->Ai and this-> bi. If it is, then this does nothing, except for printing a log message. If not, it adds a polyhedron containing this vector.

Definition at line 859 of file LCPtoLP.cpp.

◆ addThePoly()

bool Game::LCP::addThePoly ( const unsigned long int &  decimalEncoding)

Definition at line 1224 of file LCPtoLP.cpp.

◆ checkPolyFeas() [1/2]

bool Game::LCP::checkPolyFeas ( const unsigned long int &  decimalEncoding)
Parameters
decimalEncodingDecimal encoding for the polyhedron

Definition at line 990 of file LCPtoLP.cpp.

◆ checkPolyFeas() [2/2]

bool Game::LCP::checkPolyFeas ( const std::vector< short int > &  Fix)

◆ clearPolyhedra()

void Game::LCP::clearPolyhedra ( )
inline

Definition at line 207 of file lcptolp.h.

◆ conv_Npoly()

unsigned int Game::LCP::conv_Npoly ( ) const

To be used in interaction with Game::LCP::ConvexHull. Gives the number of polyhedra in the current inner approximation of the LCP feasible region.

Definition at line 1518 of file LCPtoLP.cpp.

◆ conv_PolyPosition()

unsigned int Game::LCP::conv_PolyPosition ( const unsigned long int  i) const

For the convex hull of the LCP feasible region computed, a bunch of variables are added for extended formulation and the added variables c

Definition at line 1527 of file LCPtoLP.cpp.

◆ conv_PolyWt()

unsigned int Game::LCP::conv_PolyWt ( const unsigned long int  i) const

To be used in interaction with Game::LCP::ConvexHull. Gives the position of the variable, which assigns the convex weight to the i-th polyhedron.

However, if the inner approximation has exactly one polyhedron, then returns 0.

Definition at line 1543 of file LCPtoLP.cpp.

◆ ConvexHull()

unsigned int Game::LCP::ConvexHull ( arma::sp_mat &  A,
arma::vec &  b 
)

Computes the convex hull of the feasible region of the LCP

Parameters
AConvex hull inequality description LHS to be stored here
bConvex hull inequality description RHS to be stored here

Definition at line 484 of file LCPtoLP.cpp.

◆ defConst()

void Game::LCP::defConst ( GRBEnv *  env)
private

Assign default values to LCP attributes.

Internal member that can be called from multiple constructors to assign default values to some attributes of the class.

Definition at line 58 of file LCPtoLP.cpp.

◆ EnumerateAll()

Game::LCP & Game::LCP::EnumerateAll ( bool  solveLP = true)

Brute force computation of LCP feasible region.

Computes all $2^n$ polyhedra defining the LCP feasible region. Th ese are always added to LCP::Ai and LCP::bi

Parameters
solveLPShould the poyhedra added be checked for feasibility?

Definition at line 1237 of file LCPtoLP.cpp.

◆ errorCheck()

bool Game::LCP::errorCheck ( bool  throwErr = true) const
private

Checks if the M and q given to create the LCP object are of compatible size, given the number of leader variables

Parameters
throwErrIf this is true, function throws an error, else, it just returns false

Definition at line 455 of file LCPtoLP.cpp.

◆ extractSols()

bool Game::LCP::extractSols ( GRBModel *  model,
arma::vec &  z,
arma::vec &  x,
bool  extractZ = false 
) const

Extracts variable and equation values from a solved Gurobi model for LCP.

Warning
This solves the model if the model is not already solve
Returns
false if the model is not solved to optimality. true otherwise
Parameters
modelThe Gurobi Model that was solved (perhaps using Game::LCP::LCPasMIP)
zOutput variable - where the equation values are stored
xOutput variable - where the variable values are stored
extractZz values are filled only if this is true

Definition at line 771 of file LCPtoLP.cpp.

◆ feas_detail_str()

std::string Game::LCP::feas_detail_str ( ) const

Definition at line 1506 of file LCPtoLP.cpp.

◆ FixToPolies()

Game::LCP & Game::LCP::FixToPolies ( const std::vector< short int >  Fix,
bool  checkFeas = false,
bool  custom = false,
spmat_Vec custAi = {},
vec_Vec custbi = {} 
)
private

Computes the equation of the feasibility polyhedron corresponding to the given Fix.

The computed polyhedron are always pushed into a vector of arma::sp_mat and arma::vec If custom is false, this is the internal attribute of LCP, which are LCP::Ai and LCP::bi. Otherwise, the vectors can be provided as arguments. true value to checkFeas ensures that each polyhedron that is pushed is feasible. not meant for high level code. Instead use LCP::FixToPolies.

Note
A value of 0 in *Fix implies that polyhedron corresponding to fixing the corresponding variable as well as the equation become candidates to pushed into the vector. Hence this is preferred over LCP::FixToPoly for high-level usage.

Definition at line 1061 of file LCPtoLP.cpp.

◆ FixToPoly()

bool Game::LCP::FixToPoly ( const std::vector< short int >  Fix,
bool  checkFeas = false,
bool  custom = false,
spmat_Vec custAi = {},
vec_Vec custbi = {} 
)
private

Computes the equation of the feasibility polyhedron corresponding to the given Fix.

The computed polyhedron is always pushed into a vector of arma::sp_mat and arma::vec If custom is false, this is the internal attribute of LCP, which are LCP::Ai and LCP::bi. Otherwise, the vectors can be provided as arguments. true value to checkFeas ensures that the polyhedron is pushed only if it is feasible.

Returns
true if successfully added, else false
Warning
Does not entertain 0 in the elements of *Fix. Only +1/-1 are allowed to not encounter undefined behavior. As a result, not meant for high level code. Instead use LCP::FixToPolies.

Definition at line 900 of file LCPtoLP.cpp.

◆ getAllPolyhedra()

std::set<unsigned long int> Game::LCP::getAllPolyhedra ( ) const
inline

Definition at line 191 of file lcptolp.h.

◆ getCompl()

perps Game::LCP::getCompl ( )
inline

Read-only access to LCP::Compl.

Definition at line 164 of file lcptolp.h.

◆ getFeasiblePolyhedra()

unsigned int Game::LCP::getFeasiblePolyhedra ( ) const
inline

Definition at line 215 of file lcptolp.h.

◆ getLEnd()

unsigned int Game::LCP::getLEnd ( )
inline

Read-only access to LCP::LeadEnd.

Definition at line 161 of file lcptolp.h.

◆ getLStart()

unsigned int Game::LCP::getLStart ( )
inline

Read-only access to LCP::LeadStart.

Definition at line 158 of file lcptolp.h.

◆ getM()

arma::sp_mat Game::LCP::getM ( )
inline

Read-only access to LCP::M.

Return data and address

Definition at line 150 of file lcptolp.h.

◆ getMstar()

arma::sp_mat* Game::LCP::getMstar ( )
inline

Reference access to LCP::M.

Definition at line 151 of file lcptolp.h.

◆ getNcol()

unsigned int Game::LCP::getNcol ( )
inline

Definition at line 168 of file lcptolp.h.

◆ getNextPoly()

unsigned long int Game::LCP::getNextPoly ( Game::EPECAddPolyMethod  method)
private

Returns a polyhedron (in its decimal encoding) that is neither already known to be infeasible, nor already added in the inner approximation representation.

Definition at line 1109 of file LCPtoLP.cpp.

◆ getNrow()

unsigned int Game::LCP::getNrow ( )
inline

Definition at line 170 of file lcptolp.h.

◆ getNumTheoreticalPoly()

unsigned long int Game::LCP::getNumTheoreticalPoly ( ) const
inlinenoexcept

Definition at line 194 of file lcptolp.h.

◆ getq()

arma::vec Game::LCP::getq ( )
inline

Read-only access to LCP::q.

Definition at line 154 of file lcptolp.h.

◆ getqstar()

arma::vec* Game::LCP::getqstar ( )
inline

Reference access to LCP::q.

Definition at line 155 of file lcptolp.h.

◆ initializeNotProcessed()

void Game::LCP::initializeNotProcessed ( )
inlineprivate

Definition at line 82 of file lcptolp.h.

◆ isZero()

template<class T >
bool Game::LCP::isZero ( const T  val) const
inlineprivate

Definition at line 99 of file lcptolp.h.

◆ LCP_Polyhed_fixed() [1/2]

std::unique_ptr<GRBModel> Game::LCP::LCP_Polyhed_fixed ( std::vector< unsigned int >  FixEq = {},
std::vector< unsigned int >  FixVar = {} 
)
private

◆ LCP_Polyhed_fixed() [2/2]

unique_ptr< GRBModel > Game::LCP::LCP_Polyhed_fixed ( arma::Col< int >  FixEq,
arma::Col< int >  FixVar 
)
private

Returs a model created from a given model The returned model has constraints corresponding to the non-zero elements of FixEq set to equality and variables corresponding to the non-zero elements of FixVar set to equality (=0)

Note
This model returned could either be a relaxation or a restriction or neither. If FixEq + FixVar is at least 1 (element-wise), then it is a restriction.
LCP::LCP_Polyhed_fixed({0,...,0},{0,...,0}) is equivalent to accessing LCP::RlxdModel
Warning
Note that the model returned by this function has to be explicitly deleted using the delete operator.
Returns
unique pointer to a GRBModel
Parameters
FixEqIf non zero, equality imposed on variable
FixVarIf non zero, equality imposed on equation

Definition at line 286 of file LCPtoLP.cpp.

◆ LCPasMIP() [1/3]

std::unique_ptr<GRBModel> Game::LCP::LCPasMIP ( std::vector< unsigned int >  FixEq = {},
std::vector< unsigned int >  FixVar = {},
bool  solve = false 
)
private

◆ LCPasMIP() [2/3]

std::unique_ptr<GRBModel> Game::LCP::LCPasMIP ( std::vector< short int >  Fixes,
bool  solve 
)
private

◆ LCPasMIP() [3/3]

unique_ptr< GRBModel > Game::LCP::LCPasMIP ( bool  solve = false)

Helps solving an LCP as an MIP using bigM constraints.

Returns
A unique_ptr to GRBModel that has the equivalent MIP

The MIP problem that is returned by this function is equivalent to the LCP problem provided the value of bigM is large enough.

Note
This solves just the feasibility problem. Should you need a leader's objective function, use LCP::MPECasMILP or LCP::MPECasMIQP

Definition at line 1343 of file LCPtoLP.cpp.

◆ LCPasQP()

unique_ptr< GRBModel > Game::LCP::LCPasQP ( bool  solve = false)

Solves the LCP as a QP using Gurobi.

Removes all complementarity constraints from the QP's constraints. Instead, the sum of products of complementarity pairs is minimized. If the optimal value turns out to be 0, then it is actually a solution of the LCP. Else the LCP is infeasible.

Warning
Solves the LCP feasibility problem. Not the MPEC optimization problem.

Definition at line 1295 of file LCPtoLP.cpp.

◆ load()

long int Game::LCP::load ( std::string  filename,
long int  pos = 0 
)

Definition at line 1463 of file LCPtoLP.cpp.

◆ makeQP()

Game::LCP & Game::LCP::makeQP ( Game::QP_objective QP_obj,
Game::QP_Param QP 
)
Parameters
QP_objThe objective function of the QP to be returned.
Warning
Size of this parameter might change!
Parameters
QPThe output parameter where the final Game::QP_Param object is stored

Definition at line 1265 of file LCPtoLP.cpp.

◆ makeRelaxed()

void Game::LCP::makeRelaxed ( )
private

Makes a Gurobi object that relaxes complementarity constraints in an LCP.

A Gurobi object is stored in the LCP object, that has all complementarity constraints removed. A copy of this object is used by other member functions

Definition at line 180 of file LCPtoLP.cpp.

◆ MPECasMILP()

unique_ptr< GRBModel > Game::LCP::MPECasMILP ( const arma::sp_mat &  C,
const arma::vec &  c,
const arma::vec &  x_minus_i,
bool  solve = false 
)

Helps solving an LCP as an MIP.

Returns
A unique_ptr to GRBModel that has the equivalent MIP

The MIP problem that is returned by this function is equivalent to the LCP problem. The function differs from LCP::LCPasMIP by the fact that, this explicitly takes a leader objective, and returns an object with this objective.

Note
The leader's objective has to be linear here. For quadratic objectives, refer LCP::MPECasMIQP

Definition at line 1357 of file LCPtoLP.cpp.

◆ MPECasMIQP()

unique_ptr< GRBModel > Game::LCP::MPECasMIQP ( const arma::sp_mat &  Q,
const arma::sp_mat &  C,
const arma::vec &  c,
const arma::vec &  x_minus_i,
bool  solve = false 
)

Helps solving an LCP as an MIQPs.

Returns
A unique_ptr to GRBModel that has the equivalent MIQP

The MIQP problem that is returned by this function is equivalent to the LCP problem provided the value of bigM is large enough. The function differs from LCP::LCPasMIP by the fact that, this explicitly takes a leader objective, and returns an object with this objective. This allows quadratic leader objective. If you are aware that the leader's objective is linear, use the faster method LCP::MPECasMILP

Note that if the matrix Q is a zero matrix, then this returns a Gurobi MILP model as opposed to MIQP model. This enables Gurobi to use its much advanced MIP solver

Definition at line 1399 of file LCPtoLP.cpp.

◆ print()

void Game::LCP::print ( std::string  end = "\n")

Print a summary of the LCP.

Definition at line 478 of file LCPtoLP.cpp.

◆ save()

void Game::LCP::save ( std::string  filename,
bool  erase = true 
) const

Definition at line 1449 of file LCPtoLP.cpp.

◆ solEncode() [1/3]

vector< short int > Game::LCP::solEncode ( GRBModel *  model) const
inlineprivate

Given a Gurobi model, extracts variable values and equation values, encodes it in 0/+1/-1 format and returns it.

Warning
Note that the vector returned by this function might have to be explicitly deleted using the delete operator. For specific uses in LCP::BranchAndPrune, this delete is handled by the class destructor.

Definition at line 845 of file LCPtoLP.cpp.

◆ solEncode() [2/3]

std::vector< short int > Game::LCP::solEncode ( const arma::vec &  x) const
private

Given variable values, encodes it in 0/+1/-1 format and returns it.

Gives the 0/+1/-1 notation. The notation is defined as follows. Note that, if the input is feasible, then in each complementarity pair (Eqn, Var), at least one of the two is zero.

  • If the equation is zero in a certain index and the variable is non-zero, then that index is noted by +1.
  • If the variable is zero in a certain index and the equation is non-zero, then that index is noted by +1.
  • If both the variable and equation are zero, then that index is noted by 0.

Definition at line 803 of file LCPtoLP.cpp.

◆ solEncode() [3/3]

vector< short int > Game::LCP::solEncode ( const arma::vec &  z,
const arma::vec &  x 
) const
private

Given variable values and equation values, encodes it in 0/+1/-1 format and returns it.

Parameters
zEquation values
xVariable values

Definition at line 819 of file LCPtoLP.cpp.

◆ write()

void Game::LCP::write ( std::string  filename,
bool  append = true 
) const

Definition at line 1431 of file LCPtoLP.cpp.

Field Documentation

◆ _A

arma::sp_mat Game::LCP::_A = {}
private

Definition at line 52 of file lcptolp.h.

◆ _b

arma::vec Game::LCP::_b = {}
private

Apart from $0 \le x \perp Mx+q\ge 0$, one needs $ < Ax\le b$ too!

Definition at line 53 of file lcptolp.h.

◆ addPolyMethodSeed

long int Game::LCP::addPolyMethodSeed
Initial value:
= {
-1}

Seeds the random generator for the random polyhedra selection. Should be a positive value

Definition at line 124 of file lcptolp.h.

◆ Ai

std::unique_ptr<spmat_Vec> Game::LCP::Ai
private

Vector to contain the LHS of inner approx polyhedra.

Definition at line 73 of file lcptolp.h.

◆ AllPolyhedra

std::set<unsigned long int> Game::LCP::AllPolyhedra
private
Initial value:
=
{}

Decimal encoding of polyhedra that have been enumerated.

LCP feasible region is a union of polyhedra. Keeps track which of those inequalities are fixed to equality to get the individual polyhedra

Definition at line 65 of file lcptolp.h.

◆ bi

std::unique_ptr<vec_Vec> Game::LCP::bi
private

Vector to contain the RHS of inner approx polyhedra.

Definition at line 75 of file lcptolp.h.

◆ bigM

long double Game::LCP::bigM {1e7}

bigM used to rewrite the LCP as MIP

Definition at line 116 of file lcptolp.h.

◆ Compl

perps Game::LCP::Compl
private

Compl stores data in <Eqn, Var> form.

Definition at line 50 of file lcptolp.h.

◆ env

GRBEnv* Game::LCP::env
private

Gurobi env.

Definition at line 47 of file lcptolp.h.

◆ eps

long double Game::LCP::eps
Initial value:
{
1e-6}

The threshold for optimality and feasability tollerances.

Definition at line 117 of file lcptolp.h.

◆ eps_int

long double Game::LCP::eps_int {1e-8}

The threshold, below which a number would be considered to be zero.

Definition at line 119 of file lcptolp.h.

◆ feasiblePoly

std::set<unsigned long int> Game::LCP::feasiblePoly
private
Initial value:
=
{}

Decimal encoding of polyhedra that have been enumerated.

Definition at line 67 of file lcptolp.h.

◆ feasiblePolyhedra

unsigned int Game::LCP::feasiblePolyhedra {0}
private

Definition at line 60 of file lcptolp.h.

◆ knownInfeas

std::set<unsigned long int> Game::LCP::knownInfeas
private
Initial value:
=
{}

Decimal encoding of polyhedra known to be infeasible.

Definition at line 69 of file lcptolp.h.

◆ LeadEnd

unsigned int Game::LCP::LeadEnd {0}
private

Definition at line 51 of file lcptolp.h.

◆ LeadStart

unsigned int Game::LCP::LeadStart {1}
private

Definition at line 51 of file lcptolp.h.

◆ M

arma::sp_mat Game::LCP::M
private

M in $Mx+q$ that defines the LCP.

Definition at line 48 of file lcptolp.h.

◆ madeRlxdModel

bool Game::LCP::madeRlxdModel {false}
private

Keep track if LCP::RlxdModel is made.

Definition at line 56 of file lcptolp.h.

◆ maxTheoreticalPoly

unsigned long int Game::LCP::maxTheoreticalPoly {0}
private

Definition at line 71 of file lcptolp.h.

◆ nC

unsigned int Game::LCP::nC
private

Definition at line 57 of file lcptolp.h.

◆ nLeader

unsigned int Game::LCP::nLeader {0}
private

Definition at line 51 of file lcptolp.h.

◆ nR

unsigned int Game::LCP::nR
private

Definition at line 57 of file lcptolp.h.

◆ polyCounter

int Game::LCP::polyCounter {0}
private

Definition at line 59 of file lcptolp.h.

◆ q

arma::vec Game::LCP::q
private

q in $Mx+q$ that defines the LCP

Definition at line 49 of file lcptolp.h.

◆ reverseSequentialPolyCounter

int Game::LCP::reverseSequentialPolyCounter {0}
private

Definition at line 62 of file lcptolp.h.

◆ RlxdModel

GRBModel Game::LCP::RlxdModel
private

A gurobi model with all complementarity constraints removed.

Definition at line 76 of file lcptolp.h.

◆ sequentialPolyCounter

unsigned int Game::LCP::sequentialPolyCounter {0}
private

Definition at line 61 of file lcptolp.h.

◆ useIndicators

bool Game::LCP::useIndicators
Initial value:
{
true}

constraints. BigM formulation otherwise

If true, complementarities will be handled with indicator

Definition at line 121 of file lcptolp.h.


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