Skip to content

Commit

Permalink
Convert back to sequence probabilities by using the variable definiti…
Browse files Browse the repository at this point in the history
…ons themselves.
  • Loading branch information
tturocy committed Sep 18, 2024
1 parent 44145b2 commit 3ca2bb5
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions src/solvers/enumpoly/efgpoly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,39 +197,15 @@ gPolyList<double> NashOnSupportEquationsAndInequalities(ProblemData &p_data)
// Mapping solution vectors to sequences
//=======================================================================

double NumProbOfSequence(const ProblemData &p_data, const GamePlayer &p_player, int seq,
const Vector<double> &x)
{
GameInfoset infoset = p_data.SF.GetInfoset(p_player, seq);

if (seq == 1) {
return 1.0;
}
else if (p_data.SF.ActionNumber(p_player, seq) < p_data.support.NumActions(infoset)) {
return x[p_data.var[p_player->GetNumber()][seq]];
}
else {
double value = 0.0;
int isetrow = p_data.SF.InfosetRowNumber(p_player, seq);
for (int j = 1; j < seq; j++) {
if (p_data.SF.GetConstraintEntry(p_player, isetrow, j) == Rational(-1)) {
value -= NumProbOfSequence(p_data, p_player, j, x);
}
else if (p_data.SF.GetConstraintEntry(p_player, isetrow, j) == Rational(1)) {
value += NumProbOfSequence(p_data, p_player, j, x);
}
}
return value;
}
}

PVector<double> SeqFormVectorFromSolFormVector(const ProblemData &p_data, const Vector<double> &v)
{
PVector<double> x(p_data.SF.NumSequences());

for (int i = 1; i <= p_data.support.GetGame()->NumPlayers(); i++) {
GamePlayer player = p_data.support.GetGame()->GetPlayer(i);
for (int j = 1; j <= p_data.SF.NumSequences()[i]; j++) {
x(i, j) = NumProbOfSequence(p_data, p_data.support.GetGame()->GetPlayer(i), j, v);
GameAction action = p_data.SF.GetSequence(player, j);
x(i, j) = p_data.variables.at(std::make_pair(player, action)).Evaluate(v);
}
}

Expand Down

0 comments on commit 3ca2bb5

Please sign in to comment.