Skip to content

Commit

Permalink
Final tidying for this stage.
Browse files Browse the repository at this point in the history
  • Loading branch information
tturocy committed Sep 20, 2024
1 parent 7ee7579 commit cbe90d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
30 changes: 13 additions & 17 deletions src/solvers/enumpoly/efgpoly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,20 @@ using namespace Gambit;

namespace {

// The set of polynomials is constructed incorporating these techniques:
//
// A class to organize the data needed to build the polynomials
//
// 1. The sum-to-one equations and sequence form constraints are substituted
// into the system, resuting in a reduction of the number of variables.
// This is accomplished by BuildSequenceVariable(), resulting in a
// mapping from each sequence to an expression - which may be a single
// variable for the probability of that sequence, or an expression of
// that probability in terms of the probabilities of other sequences.
// 2. The indifference conditions are implemented by computing the
// expected payoff polynomial for a player, and then taking the
// partial derivative of that with respect to each of the player's
// sequence probabilities (after the substitutions mentioned above)
// and setting those to zero.

class ProblemData {
public:
GameSequenceForm sfg;
Expand Down Expand Up @@ -90,17 +101,6 @@ ProblemData::ProblemData(const BehaviorSupportProfile &p_support)
}
}

//=======================================================================
// Constructing the equilibrium conditions
//=======================================================================

// The strategy is to develop the polynomial for each agent's expected
// payoff as a function of the behavior strategies on the support,
// eliminating the last action probability for each information set.
// The system is obtained by requiring that all the partial
// derivatives vanish, and that the sum of action probabilities at
// each information set be less than one.

gPoly<double> GetPayoff(ProblemData &p_data, const GamePlayer &p_player)
{
gPoly<double> equation(&p_data.Space, &p_data.Lex);
Expand Down Expand Up @@ -146,10 +146,6 @@ void LastActionProbPositiveInequalities(ProblemData &p_data, gPolyList<double> &
}
}

//=======================================================================
// Mapping solution vectors to sequences
//=======================================================================

std::map<GameSequence, double> ToSequenceProbs(const ProblemData &p_data, const Vector<double> &v)
{
std::map<GameSequence, double> x;
Expand Down
4 changes: 3 additions & 1 deletion src/solvers/enumpoly/gameseq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,16 @@ MixedBehaviorProfile<double>
GameSequenceForm::ToMixedBehaviorProfile(const std::map<GameSequence, double> &x) const
{
MixedBehaviorProfile<double> b(m_support);
b = 0;
for (auto sequence : GetSequences()) {
if (sequence->action == nullptr) {
continue;
}
if (double parent_prob = x.at(sequence->parent.lock()) > 0) {
b[sequence->action] = x.at(sequence) / parent_prob;
}
else {
b[sequence->action] = 0;
}
}
return b;
}
Expand Down

0 comments on commit cbe90d7

Please sign in to comment.