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

#include <models.h>

Inheritance diagram for Models::EPEC:
Game::EPEC

Public Member Functions

 EPEC ()=delete
 
 EPEC (GRBEnv *env, arma::sp_mat TranspCosts={})
 
void testLCP (const unsigned int i)
 
EPECaddCountry (LeadAllPar Params, const unsigned int addnlLeadVars=0)
 Models a Standard Nash-Cournot game within a country More...
 
EPECaddTranspCosts (const arma::sp_mat &costs)
 Adds intercountry transportation costs matrix. More...
 
unsigned int getPosition (const unsigned int countryCount, const LeaderVars var=LeaderVars::FollowerStart) const
 Gets position of a variable in a country. More...
 
unsigned int getPosition (const std::string countryCount, const LeaderVars var=LeaderVars::FollowerStart) const
 
EPECunlock ()
 Unlocks an EPEC model. More...
 
std::unique_ptr< GRBModel > Respond (const std::string name, const arma::vec &x) const
 
Game::NashGameget_LowerLevelNash (const unsigned int i) const
 Returns a non-owning pointer to the i -th country's lower level NashGame. More...
 
Game::LCPplayCountry (std::vector< Game::LCP *> countries)
 
void write (const std::string filename, const unsigned int i, bool append=true) const
 
void write (const std::string filename, bool append=true) const
 
void readSolutionJSON (const std::string filename)
 
void writeSolutionJSON (std::string filename, const arma::vec x, const arma::vec z) const
 
void writeSolution (const int writeLevel, std::string filename) const
 
const EPECInstance getInstance () const
 Get the current EPECInstance loaded. More...
 
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
 

Data Fields

bool quadraticTax = {false}
 

Protected Member Functions

bool warmstart (const arma::vec x)
 Warmstarts EPEC with a solution. More...
 
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 make_obj_leader (const unsigned int i, Game::QP_objective &QP_obj) final
 
virtual void updateLocs () override
 
virtual void prefinalize () override
 Empty function - optionally reimplementable in derived class. More...
 
virtual void postfinalize () override
 Empty function - optionally reimplementable in derived class. More...
 
bool dataCheck (const bool chkAllLeadPars=true, const bool chkcountriesLL=true, const bool chkMC_QP=true, const bool chkLeadConses=true, const bool chkLeadRHSes=true, const bool chknImportMarkets=true, const bool chkLocations=true, const bool chkLeaderLocations=true, const bool chkLeadObjec=true) const
 
bool ParamValid (const LeadAllPar &Param) const
 Checks the Validity of Models::LeadAllPar object. More...
 
void make_LL_QP (const LeadAllPar &Params, const unsigned int follower, Game::QP_Param *Foll, const LeadLocs &Loc) const noexcept
 Makes the lower level quadratic program object for each follower. More...
 
void make_LL_LeadCons (arma::sp_mat &LeadCons, arma::vec &LeadRHS, const LeadAllPar &Param, const Models::LeadLocs &Loc={}, const unsigned int import_lim_cons=1, const unsigned int export_lim_cons=1, const unsigned int price_lim_cons=1, const unsigned int activeTaxCaps=0) const noexcept
 Makes the leader constraint matrix and RHS. More...
 
void add_Leaders_tradebalance_constraints (const unsigned int i)
 Adds leaders' trade balance constraints for import-exports. More...
 
void make_MC_leader (const unsigned int i)
 Makes the market clearing constraint for country i. More...
 
void make_MC_cons (arma::sp_mat &MCLHS, arma::vec &MCRHS) const override
 Returns leader's Market clearing constraints in matrix form. More...
 
void WriteCountry (const unsigned int i, const std::string filename, const arma::vec x, const bool append=true) const
 
void WriteFollower (const unsigned int i, const unsigned int j, const std::string filename, const arma::vec x) const
 

Private Attributes

std::vector< LeadAllParAllLeadPars
 The parameters of each leader in the EPEC game. More...
 
std::vector< std::shared_ptr< Game::QP_Param > > MC_QP
 
arma::sp_mat TranspCosts
 Transportation costs between pairs of countries. More...
 
std::vector< unsigned int > nImportMarkets
 Number of countries from which the i-th country imports. More...
 
std::vector< LeadLocsLocations
 Location of variables for each country. More...
 
std::map< std::string, unsigned int > name2nos = {}
 
unsigned int taxVars = {0}
 
std::vector< arma::sp_mat > LeadConses {}
 Stores each leader's constraint LHS. More...
 
std::vector< arma::vec > LeadRHSes {}
 Stores each leader's constraint RHS. More...
 

Detailed Description

Definition at line 167 of file models.h.

Constructor & Destructor Documentation

◆ EPEC() [1/2]

Models::EPEC::EPEC ( )
delete

◆ EPEC() [2/2]

Models::EPEC::EPEC ( GRBEnv *  env,
arma::sp_mat  TranspCosts = {} 
)
inline

Definition at line 244 of file models.h.

Member Function Documentation

◆ add_Leaders_tradebalance_constraints()

void Models::EPEC::add_Leaders_tradebalance_constraints ( const unsigned int  i)
private

Adds leaders' trade balance constraints for import-exports.

Does the following job:

  • Counts the number of import markets for the country i to store in Models::EPEC::nImportMarkets - Adds the trade balance constraint. Total quantity imported by country i = Sum of Total quantity exported by each country to country i. - Updates the LeadLocs in Models::EPEC::Locations.at(i)

Definition at line 711 of file Models.cpp.

◆ addCountry()

Models::EPEC & Models::EPEC::addCountry ( Models::LeadAllPar  Params,
const unsigned int  addnlLeadVars = 0 
)

Models a Standard Nash-Cournot game within a country

A Nash cournot game is played among the followers, for the leader-decided values of import export, caps and taxations on all players. The total quantity used in the demand equation is the sum of quantity produced by all followers + any import - any export.

Use $l_i$ to denote the $i$-th element in costs_lin and $q_i$ for the $i$-th element in costs_quad. Then to produce quantity $x_i$, the $i$-th producer's cost will be

\[ l_ix_i + \frac{1}{2}q_ix_i^2 \]

In addition to this, the leader may impose "tax", which could increase $l_i$ for each player.

Total quantity in the market is given by sum of quantities produced by all producers adjusted by imports and exports

\[{Total\quad Quantity} = \sum_i x_i + x_{imp} - x_{exp} \]

The demand curve in the market is given by

\[{Price} = a-b({Total\quad Quantity})\]

Each follower is also constrained by a maximum production capacity her infrastructure allows. And each follower is constrained by a cap on their production, that is imposed by the leader.

Each follower decides $x_i$ noncooperatively maximizing profits.

The leader decides quantity imported $q_{imp}$, quantity exported $q_{exp}$, cap on each player, $\tilde{x_i}$, and the tax for each player $t_i$.

The leader is also constrained to not export or import anything more than the limits set by export_limit and import_limit. A negative value to these input variables imply that there is no such limit.

Similarly the leader cannot also impose tax on any player greater than what is dictated by the input variable max_tax.

Returns
Pointer to LCP object dynamically created using new.
Parameters
ParamsThe Parameter structure for the leader
addnlLeadVarsCreate columns with 0s in it. To handle additional dummy leader variables.

Definition at line 445 of file Models.cpp.

◆ addTranspCosts()

Models::EPEC & Models::EPEC::addTranspCosts ( const arma::sp_mat &  costs)

Adds intercountry transportation costs matrix.

Adds the transportation cost matrix. Entry in row i and column j of this matrix corresponds to the unit transportation costs for sending fuel from country i to country j.

Parameters
costsThe transportation cost matrix

Definition at line 639 of file Models.cpp.

◆ dataCheck()

bool Models::EPEC::dataCheck ( const bool  chkAllLeadPars = true,
const bool  chkcountries_LL = true,
const bool  chkMC_QP = true,
const bool  chkLeadConses = true,
const bool  chkLeadRHSes = true,
const bool  chknImportMarkets = true,
const bool  chkLocations = true,
const bool  chkLeaderLocations = true,
const bool  chkLeadObjec = true 
) const
private

Checks the data in Models::EPEC object, based on checking flags, n is the number of countries in the Models::EPEC object.

Parameters
chkAllLeadParsChecks if Models::EPEC::AllLeadPars has size n
chkcountries_LLChecks if Models::EPEC::countries_LL has size n
chkMC_QPChecks if Models::EPEC::MC_QP has size n
chkLeadConsesChecks if Models::EPEC::LeadConses has size n
chkLeadRHSesChecks if Models::EPEC::LeadRHSes has size n
chknImportMarketsChecks if Models::EPEC::nImportMarkets has size n
chkLocationsChecks if Models::EPEC::Locations has size n
chkLeaderLocationsChecks if Models::EPEC::LeaderLocations has size n and Models::EPEC::nVarinEPEC is set
chkLeadObjecChecks if Models::EPEC::LeadObjec has size n

Definition at line 864 of file Models.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.

◆ get_LowerLevelNash()

Game::NashGame * Models::EPEC::get_LowerLevelNash ( const unsigned int  i) const

Returns a non-owning pointer to the i -th country's lower level NashGame.

Definition at line 933 of file Models.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.

◆ getInstance()

const EPECInstance Models::EPEC::getInstance ( ) const
inline

Get the current EPECInstance loaded.

Definition at line 291 of file models.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() [1/2]

unsigned int Models::EPEC::getPosition ( const unsigned int  countryCount,
const LeaderVars  var = LeaderVars::FollowerStart 
) const

Gets position of a variable in a country.

Definition at line 911 of file Models.cpp.

◆ getPosition() [2/2]

unsigned int Models::EPEC::getPosition ( const std::string  countryCount,
const LeaderVars  var = LeaderVars::FollowerStart 
) const

◆ 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_LL_LeadCons()

void Models::EPEC::make_LL_LeadCons ( arma::sp_mat &  LeadCons,
arma::vec &  LeadRHS,
const LeadAllPar Params,
const Models::LeadLocs Loc = {},
const unsigned int  import_lim_cons = 1,
const unsigned int  export_lim_cons = 1,
const unsigned int  price_lim_cons = 1,
const unsigned int  activeTaxCaps = 0 
) const
privatenoexcept

Makes the leader constraint matrix and RHS.

Makes the leader level constraints for a country. The constraints added are as follows:

\begin{eqnarray} t_i^{I} &\leq& \bar{t_i^{I}}\\ q^{import} - q^{export} &\leq& \bar{q^{import}}\\ q^{export} - q^{import} &\leq& \bar{q^{export}}\\ \alpha - \beta\left(q^{import} - q^{export} + \sum_i q_i \right) &\leq& *\bar{\pi}\\ q^{export} &\leq& \sum_i q_i +q^{import} \end{eqnarray}

Here $\bar{q^{import}}$ and $\bar{q^{export}}$ denote the net import limit and export limit respectively. $\bar\pi$ is the maximum local price that the government desires to have.

The first two constraints above limit net imports and exports respectively. The third constraint limits local price. These constraints are added only if the RHS parameters are given as non-negative value. A default value of -1 to any of these parameters (given in Models::LeadAllPar Params object) ensures that these constraints are not added. The last constraint is always added. It ensures that the country does not export more than what it has produced + imported!

Parameters
LeadConsThe LHS matrix of leader constraints (for output)
LeadRHSRHS vector for leader constraints (for output)
ParamsAll country specific parameters
LocLocation of variables
import_lim_consDoes a constraint on import limit exist or no limit?
export_lim_consDoes a constraint on export limit exist or no limit?
price_lim_consDoes a constraint on price limit exist or no limit?
activeTaxCapsNumber of active Tax Caps constraints. If strictly positive, tax cap constraint(s) will be enforced

Definition at line 284 of file Models.cpp.

◆ make_LL_QP()

void Models::EPEC::make_LL_QP ( const LeadAllPar Params,
const unsigned int  follower,
Game::QP_Param Foll,
const LeadLocs Loc 
) const
privatenoexcept

Makes the lower level quadratic program object for each follower.

Makes Lower Level Quadratic Programs.

Sets the constraints and objective for the lower level problem (i.e., the follower)

Parameters
ParamsThe Parameters object
followerWhich follower's QP has to be made?
FollNon-owning pointer to the Follower QP_Param object
LocLeadLocs object for accessing different leader locations.

Definition at line 221 of file Models.cpp.

◆ make_MC_cons()

void Models::EPEC::make_MC_cons ( arma::sp_mat &  MCLHS,
arma::vec &  MCRHS 
) const
overrideprivatevirtual

Returns leader's Market clearing constraints in matrix form.

Reimplemented from Game::EPEC.

Definition at line 763 of file Models.cpp.

◆ make_MC_leader()

void Models::EPEC::make_MC_leader ( const unsigned int  i)
private

Makes the market clearing constraint for country i.

Writes the market clearing constraint as a Game::QP_Param and stores it in Models::EPEC::MC_QP

Definition at line 801 of file Models.cpp.

◆ make_obj_leader()

void Models::EPEC::make_obj_leader ( const unsigned int  i,
Game::QP_objective QP_obj 
)
finalprivatevirtual

Makes the objective function of each country.

Parameters
iThe location of the country whose objective is to be made
QP_objThe object where the objective parameters are to be stored.

Implements Game::EPEC.

Definition at line 955 of file Models.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.

◆ ParamValid()

bool Models::EPEC::ParamValid ( const LeadAllPar Params) const
private

Checks the Validity of Models::LeadAllPar object.

Checks that the parameter given to add a country is valid. Does not have obvious errors

Checks the following:

  • Size of FollowerParam.costs_lin, FollowerParam.costs_quad, FollowerParam.capacities, FollowerParam.emission_costs are all equal to Params.n_followers - DemandParam.alpha and DemandParam.beta are greater than zero - name is not empty - name does not match with the name of any other existing countries in the EPEC object.
Parameters
ParamsObject whose validity is to be tested

Definition at line 188 of file Models.cpp.

◆ playCountry()

Game::LCP* Models::EPEC::playCountry ( std::vector< Game::LCP *>  countries)

◆ postfinalize()

virtual void Models::EPEC::postfinalize ( )
inlineoverrideprivatevirtual

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 from Game::EPEC.

Definition at line 173 of file models.h.

◆ prefinalize()

void Models::EPEC::prefinalize ( )
overrideprivatevirtual

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

Does the following:

  1. Adds the trade balance constraint for all leaders. i.e., total import must equal sum of import from each country
  2. Stores the number of import markets for each country in Models::EPEC::nImportMarkets

Reimplemented from Game::EPEC.

Definition at line 679 of file Models.cpp.

◆ readSolutionJSON()

void Models::EPEC::readSolutionJSON ( const std::string  filename)

Reads the solution file and load it in the current EPEC instance

Definition at line 1195 of file Models.cpp.

◆ reset()

void Game::EPEC::reset ( )
inlineinherited

Definition at line 596 of file games.h.

◆ Respond() [1/2]

std::unique_ptr<GRBModel> Models::EPEC::Respond ( const std::string  name,
const arma::vec &  x 
) const

◆ Respond() [2/2]

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
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.

◆ testLCP()

void Models::EPEC::testLCP ( const unsigned int  i)

Definition at line 1595 of file Models.cpp.

◆ unlock()

Models::EPEC & Models::EPEC::unlock ( )

Unlocks an EPEC model.

A finalized model cannot be edited unless it is unlocked first.

EPEC::finalize() performs "finalizing" acts on an object.

Warning
Exclusively for debugging purposes for developers. Don't call this function, unless you know what you are doing.

Definition at line 942 of file Models.cpp.

◆ updateLocs()

void Models::EPEC::updateLocs ( )
overrideprivatevirtual

This function is called after make_country_QP()

Implements Game::EPEC.

Definition at line 1018 of file Models.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.

◆ write() [1/2]

void Models::EPEC::write ( const std::string  filename,
const unsigned int  i,
bool  append = true 
) const

◆ write() [2/2]

void Models::EPEC::write ( const std::string  filename,
bool  append = true 
) const

◆ WriteCountry()

void Models::EPEC::WriteCountry ( const unsigned int  i,
const std::string  filename,
const arma::vec  x,
const bool  append = true 
) const
private

Definition at line 1456 of file Models.cpp.

◆ WriteFollower()

void Models::EPEC::WriteFollower ( const unsigned int  i,
const unsigned int  j,
const std::string  filename,
const arma::vec  x 
) const
private

Definition at line 1520 of file Models.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.

◆ writeSolution()

void Models::EPEC::writeSolution ( const int  writeLevel,
std::string  filename 
) const

Writes the computed Nash Equilibrium in the EPEC instance writeLevel is an integer representing the write configuration. 0: only Json solution; 1: only human readable solution; 2:both

Definition at line 1237 of file Models.cpp.

◆ writeSolutionJSON()

void Models::EPEC::writeSolutionJSON ( std::string  filename,
const arma::vec  x,
const arma::vec  z 
) const

Writes the computed Nash Equilibrium in the standard JSON solution file filename dictates the name of the .JSON solution file

Definition at line 1122 of file Models.cpp.

Field Documentation

◆ AllLeadPars

std::vector<LeadAllPar> Models::EPEC::AllLeadPars
private
Initial value:
=
{}

The parameters of each leader in the EPEC game.

Definition at line 179 of file models.h.

◆ 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.

◆ 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.

◆ LeadConses

std::vector<arma::sp_mat> Models::EPEC::LeadConses {}
private

Stores each leader's constraint LHS.

Definition at line 194 of file models.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.

◆ LeadRHSes

std::vector<arma::vec> Models::EPEC::LeadRHSes {}
private

Stores each leader's constraint RHS.

Definition at line 195 of file models.h.

◆ Locations

std::vector<LeadLocs> Models::EPEC::Locations
private
Initial value:
=
{}

Location of variables for each country.

Definition at line 188 of file models.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.

◆ MC_QP

std::vector<std::shared_ptr<Game::QP_Param> > Models::EPEC::MC_QP
private
Initial value:
=
{}

The QP corresponding to the market clearing condition of each player

Definition at line 181 of file models.h.

◆ n_MCVar

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

Definition at line 513 of file games.h.

◆ name2nos

std::map<std::string, unsigned int> Models::EPEC::name2nos = {}
private

Definition at line 191 of file models.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.

◆ nImportMarkets

std::vector<unsigned int> Models::EPEC::nImportMarkets
private
Initial value:
=
{}

Number of countries from which the i-th country imports.

Definition at line 186 of file models.h.

◆ quadraticTax

bool Models::EPEC::quadraticTax = {false}

If set to true, a term for the quadratic tax is added to each leader objective

Definition at line 237 of file models.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.

◆ taxVars

unsigned int Models::EPEC::taxVars = {0}
private

Definition at line 192 of file models.h.

◆ TranspCosts

arma::sp_mat Models::EPEC::TranspCosts
private
Initial value:
=
{}

Transportation costs between pairs of countries.

Definition at line 184 of file models.h.


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