# Class PolyBase

## Class Documentation

class PolyBase

Public Functions

inline PolyBase(GRBEnv *env, Game::EPEC *EPECObject)

The standard constructor for a PolyBase algorithm. It creates local MathOpt::PolyLCP objects to work with.

Parameters
• env – The pointer to the Gurobi environment

• EPECObject – The pointer to the Game::EPEC object

virtual void solve() = 0

A general method to solve problems.

bool isSolved(unsigned int *player, arma::vec *profitableDeviation, double tol = -1e-5) const

Checks if Game::EPEC is solved, otherwise it returns a proof.

Analogous to Game::NashGame::isSolved but checks if the given Game::EPEC is solved. If it is, then returns true. If not, it returns the country which has a profitable deviation in player and the profitable deviation in profitableDeviation. Tolerance is the tolerance for the check. If the improved objective after the deviation is less than Tolerance, 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 Tolerance = 0 might even reject a real solution as not solved. This is due to Numerical issues arising from the LCP solver (Gurobi).

Parameters
• player – The id of the player

• profitableDeviation – An output (possibly non-changed) vector containing the profitable deviation for the given player

• tol – A numerical tolerance

Returns

True if there is no profitable deviation, namely the player is optimal

virtual bool isSolved(double tol = 1e-5)

A method to check whether the EPEC is solved or not, given a numerical tolerance.

Checks whether the current Game::EPEC instance is solved for any player, up to a numerical tolerance.

Parameters

tol – The numerical tolerance

Returns

True if the game is solved

void makeThePureLCP()

Creates an LCP for the inner-full approximation schemes of MathOpt::PolyLCP that explicitly searches for pure-strategy equilibria. The original LCP is moved to Game::EPEC::LCPModelBase.

double getValLeadFollPoly(unsigned int i, unsigned int j, unsigned int k, double tol = 1e-5) const

For the i -th leader, gets the k -th pure strategy at position j.

Parameters
• i – The leader index

• j – The position index

• k – The pure strategy index

• tol – A numerical tolerance

Returns

The queried attribute

double getValLeadLeadPoly(unsigned int i, unsigned int j, unsigned int k, double tol = 1e-5) const

For the i -th leader, gets the k -th pure strategy at leader position j.

Parameters
• i – The leader index

• j – The position index

• k – The pure strategy index

• tol – A numerical tolerance

Returns

The queried attribute

double getValProbab(unsigned int i, unsigned int k) const

The probability associated with the k -th polyhedron of the i -th leader.

Parameters
• i – The index of the player

• k – The index of the polyhedron

Returns

The queried attribute

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

Checks whether the current strategy for the i player is a pure strategy.

Parameters
• i – The index of the player

• tol – A numerical tolerance

Returns

True if it is a pure equilibrium strategy

bool isPureStrategy(double tol = 1e-5) const

Checks if the current equilibrium strategy in Game::EPEC is a pure strategy.

Parameters

tol – A numerical tolerance

Returns

True if it is a pure equilibrium strategy

std::vector<unsigned int> mixedStrategyPoly(unsigned int i, double tol = 1e-5) const

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

Parameters
• i – The index of the player

• tol – A numerical tolerance

Returns

The indices of polyhedra with active probabilities

unsigned int getPositionLeadFollPoly(unsigned int i, unsigned int j, unsigned int k) const

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

Parameters
• i – The leader index

• j – The polyhedron index

• k – The follower variable index

Returns

The position for the queried attribute

unsigned int getPositionLeadLeadPoly(unsigned int i, unsigned int j, unsigned int k) const

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

Parameters
• i – The leader index

• j – The polyhedron index

• k – The leader variable index

Returns

The position for the queried attribute

unsigned long int getNumPolyLead(unsigned int i) const

Get the number of polyhedra used in the approximation for the i leader.

Parameters

Returns

The queried number of polyhedra

unsigned int getPositionProbab(unsigned int i, unsigned int k) const

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

Parameters
• i – The leader index

• k – The polyhedron index

Returns

The probability position associated with the queried values

Protected Functions

inline void after()

This method is called after the PolyBase::solve operation. It fills statistics and can be forcefully overridden by inheritors. The responsibility for calling this method is left to the inheritor.

Protected Attributes

GRBEnv *Env

This is the abstract class manages the algorithms for Game::EPEC. Since they are all based on MathOpt::PolyLCP, the class keeps a local copy of objects of that class. It provides a constructor where the Gurobi environment and the EPEC are passed.

A pointer to the Gurobi Environment

Game::EPEC *EPECObject

A pointer to the Game::EPEC instance.

std::vector<std::shared_ptr<MathOpt::PolyLCP>> PolyLCP = {}

Local MathOpt::PolyLCP objects.