EPEC solve
Solving Equilibrium Problems with Equilibrium Constraints (EPECs)
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
My_EPEC_Prob Class Reference
Inheritance diagram for My_EPEC_Prob:
Game::EPEC

Public Member Functions

 My_EPEC_Prob (GRBEnv *e)
 
void addLeader (std::shared_ptr< Game::NashGame > N, const unsigned int i)
 
void finalize ()
 Finalizes the creation of a Game::EPEC object. More...
 
void findNashEq ()
 
std::unique_ptr< GRBModel > Respond (const unsigned int i, const arma::vec &x) const
 
double RespondSol (arma::vec &sol, unsigned int player, const arma::vec &x, const arma::vec &prevDev) const
 
bool isSolved (unsigned int *countryNumber, arma::vec *ProfDevn, double tol=51e-4) const
 
bool isSolved (double tol=51e-4) const
 
const arma::vec getx () const
 
void reset ()
 
const arma::vec getz () const
 
const EPECStatistics getStatistics () const
 Get the EPECStatistics object for the current instance. More...
 
void setAlgorithm (Game::EPECalgorithm algorithm)
 
Game::EPECalgorithm getAlgorithm () const
 
void setRecoverStrategy (Game::EPECRecoverStrategy strategy)
 
Game::EPECRecoverStrategy getRecoverStrategy () const
 
void setAggressiveness (unsigned int a)
 
unsigned int getAggressiveness () const
 
void setNumThreads (unsigned int t)
 
unsigned int getNumThreads () const
 
void setAddPolyMethodSeed (unsigned int t)
 
unsigned int getAddPolyMethodSeed () const
 
void setIndicators (bool val)
 
bool getIndicators () const
 
void setPureNE (bool val)
 
bool getPureNE () const
 
void setBoundPrimals (bool val)
 
bool getBoundPrimals () const
 
void setBoundBigM (double val)
 
double getBoundBigM () const
 
void setTimeLimit (double val)
 
double getTimeLimit () const
 
void setAddPolyMethod (Game::EPECAddPolyMethod add)
 
Game::EPECAddPolyMethod getAddPolyMethod () const
 
unsigned int getnVarinEPEC () const noexcept
 
unsigned int getNcountries () const noexcept
 
unsigned int getPosition_LeadFoll (const unsigned int i, const unsigned int j) const
 
unsigned int getPosition_LeadLead (const unsigned int i, const unsigned int j) const
 
unsigned int getPosition_LeadFollPoly (const unsigned int i, const unsigned int j, const unsigned int k) const
 
unsigned int getPosition_LeadLeadPoly (const unsigned int i, const unsigned int j, const unsigned int k) const
 
unsigned int getNPoly_Lead (const unsigned int i) const
 
unsigned int getPosition_Probab (const unsigned int i, const unsigned int k) const
 
double getVal_LeadFoll (const unsigned int i, const unsigned int j) const
 
double getVal_LeadLead (const unsigned int i, const unsigned int j) const
 
double getVal_LeadFollPoly (const unsigned int i, const unsigned int j, const unsigned int k, const double tol=1e-5) const
 
double getVal_LeadLeadPoly (const unsigned int i, const unsigned int j, const unsigned int k, const double tol=1e-5) const
 
double getVal_Probab (const unsigned int i, const unsigned int k) const
 
bool isPureStrategy (const unsigned int i, const double tol=1e-5) const
 
bool isPureStrategy (const double tol=1e-5) const
 
std::vector< unsigned int > mixedStratPoly (const unsigned int i, const double tol=1e-5) const
 
const LCPgetLcpDescr () const
 
const GRBModel & getLcpModel () const
 
void writeLcpModel (std::string filename) const
 

Protected Member Functions

bool warmstart (const arma::vec x)
 Warmstarts EPEC with a solution. More...
 
virtual void prefinalize ()
 Empty function - optionally reimplementable in derived class. More...
 
virtual void postfinalize ()
 Empty function - optionally reimplementable in derived class. More...
 
virtual void make_MC_cons (arma::sp_mat &MC, arma::vec &RHS) const
 
bool hasLCP () const
 

Protected Attributes

std::vector< std::shared_ptr< Game::NashGame > > countries_LL {}
 
std::vector< std::unique_ptr< Game::LCP > > countries_LCP {}
 
std::vector< std::shared_ptr< Game::QP_Param > > country_QP {}
 The QP corresponding to each player. More...
 
std::vector< std::shared_ptr< Game::QP_objective > > LeadObjec {}
 Objective of each leader. More...
 
std::vector< std::shared_ptr< Game::QP_objective > > LeadObjec_ConvexHull {}
 
std::unique_ptr< Game::NashGamenashgame
 The EPEC nash game. More...
 
std::vector< unsigned int > LeaderLocations {}
 
std::vector< const unsigned int * > LocEnds {}
 
std::vector< unsigned int > convexHullVariables {}
 
unsigned int n_MCVar {0}
 
GRBEnv * env
 
bool finalized {false}
 
bool nashEq {false}
 
std::chrono::high_resolution_clock::time_point initTime
 
EPECStatistics Stats {}
 Store run time information. More...
 
arma::vec sol_z
 Solution equation values. More...
 
arma::vec sol_x
 Solution variable values. More...
 

Private Member Functions

void updateLocs () override
 
void make_obj_leader (const unsigned int i, Game::QP_objective &QP_obj) override
 Can be instantiated by a derived class only! More...
 

Private Attributes

unsigned int ends [2]
 

Detailed Description

Definition at line 7 of file example.cpp.

Constructor & Destructor Documentation

◆ My_EPEC_Prob()

My_EPEC_Prob::My_EPEC_Prob ( GRBEnv *  e)
inline

Definition at line 9 of file example.cpp.

Member Function Documentation

◆ addLeader()

void My_EPEC_Prob::addLeader ( std::shared_ptr< Game::NashGame N,
const unsigned int  i 
)
inline

Definition at line 10 of file example.cpp.

◆ finalize()

void Game::EPEC::finalize ( )
inherited

Finalizes the creation of a Game::EPEC object.

Performs a bunch of job after all data for a Game::EPEC object are given, namely. Models::EPEC::computeLeaderLocations - Adds the required dummy variables to each leader's problem so that a game among the leaders can be defined. Calls Game::EPEC::add_Dummy_Lead

  • Makes the market clearing constraint in each country. Calls

Game::EPEC::prefinalize() can be overridden, and that code will run before calling Game::EPEC::finalize()

Game::EPEC::postfinalize() can be overridden, and that code will run after calling Game::EPEC::finalize()

Definition at line 1226 of file Games.cpp.

◆ findNashEq()

void Game::EPEC::findNashEq ( )
inherited

Computes Nash equilibrium using the algorithm set in Game::EPEC::algorithm

Checks the value of Game::EPEC::algorithm and delegates the task to appropriate algorithm wrappers.

Definition at line 2182 of file Games.cpp.

◆ getAddPolyMethod()

Game::EPECAddPolyMethod Game::EPEC::getAddPolyMethod ( ) const
inlineinherited

Definition at line 644 of file games.h.

◆ getAddPolyMethodSeed()

unsigned int Game::EPEC::getAddPolyMethodSeed ( ) const
inlineinherited

Definition at line 624 of file games.h.

◆ getAggressiveness()

unsigned int Game::EPEC::getAggressiveness ( ) const
inlineinherited

Definition at line 611 of file games.h.

◆ getAlgorithm()

Game::EPECalgorithm Game::EPEC::getAlgorithm ( ) const
inlineinherited

Definition at line 601 of file games.h.

◆ getBoundBigM()

double Game::EPEC::getBoundBigM ( ) const
inlineinherited

Definition at line 638 of file games.h.

◆ getBoundPrimals()

bool Game::EPEC::getBoundPrimals ( ) const
inlineinherited

Definition at line 634 of file games.h.

◆ getIndicators()

bool Game::EPEC::getIndicators ( ) const
inlineinherited

Definition at line 628 of file games.h.

◆ getLcpDescr()

const LCP& Game::EPEC::getLcpDescr ( ) const
inlineinherited

Get the Game::LCP object solved in the last iteration either to solve the problem or to prove non-existence of Nash equilibrium. Object is returned using constant reference.

Definition at line 689 of file games.h.

◆ getLcpModel()

const GRBModel& Game::EPEC::getLcpModel ( ) const
inlineinherited

Get the GRBModel solved in the last iteration to solve the problem or to prove non-existence of Nash equilibrium. Object is returned using constant reference.

Definition at line 693 of file games.h.

◆ getNcountries()

unsigned int Game::EPEC::getNcountries ( ) const
inlinenoexceptinherited

Definition at line 651 of file games.h.

◆ getNPoly_Lead()

unsigned int Game::EPEC::getNPoly_Lead ( const unsigned int  i) const
inherited

Get the number of polyhedra used in the inner approximation of the feasible region of the i-th leader.*

Definition at line 2341 of file Games.cpp.

◆ getNumThreads()

unsigned int Game::EPEC::getNumThreads ( ) const
inlineinherited

Definition at line 618 of file games.h.

◆ getnVarinEPEC()

unsigned int Game::EPEC::getnVarinEPEC ( ) const
inlinenoexceptinherited

Definition at line 650 of file games.h.

◆ getPosition_LeadFoll()

unsigned int Game::EPEC::getPosition_LeadFoll ( const unsigned int  i,
const unsigned int  j 
) const
inherited

Get the position of the j-th Follower variable in the i-th leader Querying Game::EPEC::lcpmodel for x[return-value] variable gives the appropriate variable

Definition at line 2291 of file Games.cpp.

◆ getPosition_LeadFollPoly()

unsigned int Game::EPEC::getPosition_LeadFollPoly ( const unsigned int  i,
const unsigned int  j,
const unsigned int  k 
) const
inherited

Get the position of the k-th follower variable of the i-th leader, in the j-th feasible polyhedron.

Indeed it should hold that $ j < $ Game::EPEC::getNPoly_Lead(i)

Definition at line 2313 of file Games.cpp.

◆ getPosition_LeadLead()

unsigned int Game::EPEC::getPosition_LeadLead ( const unsigned int  i,
const unsigned int  j 
) const
inherited

Get the position of the j-th Follower variable in the i-th leader Querying Game::EPEC::lcpmodel for x[return-value] variable gives the appropriate variable

Definition at line 2302 of file Games.cpp.

◆ getPosition_LeadLeadPoly()

unsigned int Game::EPEC::getPosition_LeadLeadPoly ( const unsigned int  i,
const unsigned int  j,
const unsigned int  k 
) const
inherited

Get the position of the k-th leader variable of the i-th leader, in the j-th feasible polyhedron.

Indeed it should hold that $ j < $ Game::EPEC::getNPoly_Lead(i)

Definition at line 2327 of file Games.cpp.

◆ getPosition_Probab()

unsigned int Game::EPEC::getPosition_Probab ( const unsigned int  i,
const unsigned int  k 
) const
inherited

Get the position of the probability associated with the k-th polyhedron (k-th pure strategy) of the i-th leader. However, if the leader has an inner approximation with exactly 1 polyhedron, it returns 0;

Definition at line 2349 of file Games.cpp.

◆ getPureNE()

bool Game::EPEC::getPureNE ( ) const
inlineinherited

Definition at line 630 of file games.h.

◆ getRecoverStrategy()

Game::EPECRecoverStrategy Game::EPEC::getRecoverStrategy ( ) const
inlineinherited

Definition at line 605 of file games.h.

◆ getStatistics()

const EPECStatistics Game::EPEC::getStatistics ( ) const
inlineinherited

Get the EPECStatistics object for the current instance.

Definition at line 599 of file games.h.

◆ getTimeLimit()

double Game::EPEC::getTimeLimit ( ) const
inlineinherited

Definition at line 640 of file games.h.

◆ getVal_LeadFoll()

double Game::EPEC::getVal_LeadFoll ( const unsigned int  i,
const unsigned int  j 
) const
inherited

Definition at line 2418 of file Games.cpp.

◆ getVal_LeadFollPoly()

double Game::EPEC::getVal_LeadFollPoly ( const unsigned int  i,
const unsigned int  j,
const unsigned int  k,
const double  tol = 1e-5 
) const
inherited

Definition at line 2438 of file Games.cpp.

◆ getVal_LeadLead()

double Game::EPEC::getVal_LeadLead ( const unsigned int  i,
const unsigned int  j 
) const
inherited

Definition at line 2428 of file Games.cpp.

◆ getVal_LeadLeadPoly()

double Game::EPEC::getVal_LeadLeadPoly ( const unsigned int  i,
const unsigned int  j,
const unsigned int  k,
const double  tol = 1e-5 
) const
inherited

Definition at line 2456 of file Games.cpp.

◆ getVal_Probab()

double Game::EPEC::getVal_Probab ( const unsigned int  i,
const unsigned int  k 
) const
inherited

Definition at line 2409 of file Games.cpp.

◆ getx()

const arma::vec Game::EPEC::getx ( ) const
inlineinherited

Definition at line 595 of file games.h.

◆ getz()

const arma::vec Game::EPEC::getz ( ) const
inlineinherited

Definition at line 597 of file games.h.

◆ hasLCP()

bool Game::EPEC::hasLCP ( ) const
inlineprotectedinherited

Definition at line 571 of file games.h.

◆ isPureStrategy() [1/2]

bool Game::EPEC::isPureStrategy ( const unsigned int  i,
const double  tol = 1e-5 
) const
inherited

Checks if the returned strategy leader is a pure strategy for the leader i. The strategy is considered a pure strategy, if it is played with a probability greater than 1 - tol;

Definition at line 2376 of file Games.cpp.

◆ isPureStrategy() [2/2]

bool Game::EPEC::isPureStrategy ( const double  tol = 1e-5) const
inherited

Checks if the returned strategy leader is a pure strategy for the leader i. The strategy is considered a pure strategy, if it is played with a probability greater than 1 - tol;

Definition at line 2363 of file Games.cpp.

◆ isSolved() [1/2]

bool Game::EPEC::isSolved ( unsigned int *  countryNumber,
arma::vec *  ProfDevn,
double  tol = 51e-4 
) const
inherited

Checks if Game::EPEC is solved, else returns proof of unsolvedness.

Analogous to Game::NashGame::isSolved but checks if the given Game::EPEC is solved. If it is solved, then retruns true. If not, it returns the country which has a profitable deviation in countryNumber and the profitable deviation in ProfDevn. tol is the tolerance for the check. If the improved objective after the deviation is less than tol, then it is not considered as a profitable deviation.

Thus we check if the given point is an $\epsilon$-equilibrium. Value of $\epsilon $ can be chosen sufficiently close to 0.

Warning
Setting tol = 0 might even reject a real solution as not solved. This is due to numerical issues arising from the LCP solver (Gurobi).

Definition at line 1450 of file Games.cpp.

◆ isSolved() [2/2]

bool Game::EPEC::isSolved ( double  tol = 51e-4) const
inherited

Definition at line 1491 of file Games.cpp.

◆ make_MC_cons()

virtual void Game::EPEC::make_MC_cons ( arma::sp_mat &  MC,
arma::vec &  RHS 
) const
inlineprotectedvirtualinherited

Reimplemented in Models::EPEC.

Definition at line 567 of file games.h.

◆ make_obj_leader()

void My_EPEC_Prob::make_obj_leader ( const unsigned int  i,
Game::QP_objective QP_obj 
)
inlineoverrideprivatevirtual

Can be instantiated by a derived class only!

Implements Game::EPEC.

Definition at line 22 of file example.cpp.

◆ mixedStratPoly()

std::vector< unsigned int > Game::EPEC::mixedStratPoly ( const unsigned int  i,
const double  tol = 1e-5 
) const
inherited

Returns the indices of polyhedra feasible for the leader, from which strategies are played with probability greater than tol.

Definition at line 2391 of file Games.cpp.

◆ postfinalize()

void Game::EPEC::postfinalize ( )
protectedvirtualinherited

Empty function - optionally reimplementable in derived class.

This function can be optionally implemented by the derived class. Code in this class will be run after calling Game::EPEC::finalize().

Reimplemented in Models::EPEC.

Definition at line 1203 of file Games.cpp.

◆ prefinalize()

void Game::EPEC::prefinalize ( )
protectedvirtualinherited

Empty function - optionally reimplementable in derived class.

This function can be optionally implemented by the derived class. Code in this class will be run before calling Game::EPEC::finalize().

Reimplemented in Models::EPEC.

Definition at line 1194 of file Games.cpp.

◆ reset()

void Game::EPEC::reset ( )
inlineinherited

Definition at line 596 of file games.h.

◆ Respond()

unique_ptr< GRBModel > Game::EPEC::Respond ( const unsigned int  i,
const arma::vec &  x 
) const
inherited

Definition at line 1366 of file Games.cpp.

◆ RespondSol()

double Game::EPEC::RespondSol ( arma::vec &  sol,
unsigned int  player,
const arma::vec &  x,
const arma::vec &  prevDev = {} 
) const
inherited

Returns the optimal objective value that is obtainable for the player player given the decision x of all other players.

Calls Game::EPEC::Respond and obtains the unique_ptr to GRBModel of best response by player player. Then solves the model and returns the appropriate objective value.

Returns
The optimal objective value for the player player.
Parameters
[out]solOptimal response
playerPlayer whose optimal response is to be computed
xA vector of pure strategies (either for all players or all other players

Definition at line 1380 of file Games.cpp.

◆ setAddPolyMethod()

void Game::EPEC::setAddPolyMethod ( Game::EPECAddPolyMethod  add)
inlineinherited

Definition at line 641 of file games.h.

◆ setAddPolyMethodSeed()

void Game::EPEC::setAddPolyMethodSeed ( unsigned int  t)
inlineinherited

Definition at line 621 of file games.h.

◆ setAggressiveness()

void Game::EPEC::setAggressiveness ( unsigned int  a)
inlineinherited

Definition at line 608 of file games.h.

◆ setAlgorithm()

void Game::EPEC::setAlgorithm ( Game::EPECalgorithm  algorithm)
inherited

Decides the algorithm to be used for solving the given instance of the problem. The choice of algorithms are documented in Game::EPECalgorithm

Definition at line 2274 of file Games.cpp.

◆ setBoundBigM()

void Game::EPEC::setBoundBigM ( double  val)
inlineinherited

Definition at line 637 of file games.h.

◆ setBoundPrimals()

void Game::EPEC::setBoundPrimals ( bool  val)
inlineinherited

Definition at line 631 of file games.h.

◆ setIndicators()

void Game::EPEC::setIndicators ( bool  val)
inlineinherited

Definition at line 627 of file games.h.

◆ setNumThreads()

void Game::EPEC::setNumThreads ( unsigned int  t)
inlineinherited

Definition at line 614 of file games.h.

◆ setPureNE()

void Game::EPEC::setPureNE ( bool  val)
inlineinherited

Definition at line 629 of file games.h.

◆ setRecoverStrategy()

void Game::EPEC::setRecoverStrategy ( Game::EPECRecoverStrategy  strategy)
inherited

Decides the algorithm to be used for recovering a PNE out of the innerApproximation procedure.

Definition at line 2282 of file Games.cpp.

◆ setTimeLimit()

void Game::EPEC::setTimeLimit ( double  val)
inlineinherited

Definition at line 639 of file games.h.

◆ updateLocs()

void My_EPEC_Prob::updateLocs ( )
inlineoverrideprivatevirtual

Implements Game::EPEC.

Definition at line 18 of file example.cpp.

◆ warmstart()

bool Game::EPEC::warmstart ( const arma::vec  x)
protectedinherited

Warmstarts EPEC with a solution.

Todo:
Game::EPEC::warmstart - to complete implementation?

Definition at line 2060 of file Games.cpp.

◆ writeLcpModel()

void Game::EPEC::writeLcpModel ( std::string  filename) const
inlineinherited

Writes the GRBModel solved in the last iteration to solve the problem or to prove non-existence of Nash equilibrium to a file.

Definition at line 696 of file games.h.

Field Documentation

◆ convexHullVariables

std::vector<unsigned int> Game::EPEC::convexHullVariables {}
protectedinherited

Definition at line 512 of file games.h.

◆ countries_LCP

std::vector<std::unique_ptr<Game::LCP> > Game::EPEC::countries_LCP {}
protectedinherited

Definition at line 494 of file games.h.

◆ countries_LL

std::vector<std::shared_ptr<Game::NashGame> > Game::EPEC::countries_LL {}
protectedinherited

Definition at line 493 of file games.h.

◆ country_QP

std::vector<std::shared_ptr<Game::QP_Param> > Game::EPEC::country_QP {}
protectedinherited

The QP corresponding to each player.

Definition at line 497 of file games.h.

◆ ends

unsigned int My_EPEC_Prob::ends[2]
private

Definition at line 17 of file example.cpp.

◆ env

GRBEnv* Game::EPEC::env
protectedinherited

Definition at line 515 of file games.h.

◆ finalized

bool Game::EPEC::finalized {false}
protectedinherited

Definition at line 516 of file games.h.

◆ initTime

std::chrono::high_resolution_clock::time_point Game::EPEC::initTime
protectedinherited

Definition at line 518 of file games.h.

◆ LeaderLocations

std::vector<unsigned int> Game::EPEC::LeaderLocations {}
protectedinherited

Location of each leader

Definition at line 506 of file games.h.

◆ LeadObjec

std::vector<std::shared_ptr<Game::QP_objective> > Game::EPEC::LeadObjec {}
protectedinherited

Objective of each leader.

Definition at line 499 of file games.h.

◆ LeadObjec_ConvexHull

std::vector<std::shared_ptr<Game::QP_objective> > Game::EPEC::LeadObjec_ConvexHull {}
protectedinherited

Objective of each leader, given the convex hull computation

Definition at line 501 of file games.h.

◆ LocEnds

std::vector<const unsigned int *> Game::EPEC::LocEnds {}
protectedinherited

Number of variables in the current player, including any number of convex hull variables at the current moment. The used, i.e., the inheritor of Game::EPEC has the responsibility to keep this correct by implementing an override of Game::EPEC::updateLocs.

Definition at line 511 of file games.h.

◆ n_MCVar

unsigned int Game::EPEC::n_MCVar {0}
protectedinherited

Definition at line 513 of file games.h.

◆ nashEq

bool Game::EPEC::nashEq {false}
protectedinherited

Definition at line 517 of file games.h.

◆ nashgame

std::unique_ptr<Game::NashGame> Game::EPEC::nashgame
protectedinherited

The EPEC nash game.

Definition at line 504 of file games.h.

◆ sol_x

arma::vec Game::EPEC::sol_x
protectedinherited

Solution variable values.

Definition at line 520 of file games.h.

◆ sol_z

arma::vec Game::EPEC::sol_z
protectedinherited

Solution equation values.

Definition at line 520 of file games.h.

◆ Stats

EPECStatistics Game::EPEC::Stats {}
protectedinherited

Store run time information.

Definition at line 519 of file games.h.


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