Skip to content

Commit

Permalink
More towards working with sequences as objects not numbers.
Browse files Browse the repository at this point in the history
  • Loading branch information
tturocy committed Sep 18, 2024
1 parent 6c42be5 commit 44145b2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
15 changes: 9 additions & 6 deletions src/solvers/enumpoly/efgpoly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,17 @@ gPoly<double> BuildSequenceVariable(ProblemData &p_data, const GamePlayer &p_pla
return gPoly<double>(p_data.Space, p_data.var[p_player->GetNumber()][seq], 1, p_data.Lex);
}

int isetrow = p_data.SF.InfosetRowNumber(p_player, seq);
gPoly<double> equation(p_data.Space, p_data.Lex);
for (int j = 1; j < seq; j++) {
if (p_data.SF.GetConstraintEntry(p_player, isetrow, j) == Rational(-1)) {
equation -= BuildSequenceVariable(p_data, p_player, p_data.SF.GetSequence(p_player, j));
for (auto seq = p_data.SF.cbegin_sequences(p_player); seq != p_data.SF.cend_sequences(p_player);
seq++) {
if (*seq == p_action) {
break;
}
else if (p_data.SF.GetConstraintEntry(p_player, isetrow, j) == Rational(1)) {
equation += BuildSequenceVariable(p_data, p_player, p_data.SF.GetSequence(p_player, j));
if (p_data.SF.GetConstraintEntry(infoset, *seq) == Rational(-1)) {
equation -= BuildSequenceVariable(p_data, p_player, *seq);
}
else if (p_data.SF.GetConstraintEntry(infoset, *seq) == Rational(1)) {
equation += BuildSequenceVariable(p_data, p_player, *seq);
}
}
return equation;
Expand Down
6 changes: 3 additions & 3 deletions src/solvers/enumpoly/sfg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Rational &Sfg::GetMatrixEntry(const PureSequenceProfile &profile, const GamePlay
return SF.at(index, player->GetNumber());
}

Rational &Sfg::GetConstraintEntry(const GameInfoset &infoset, const GameAction &action)
Rational &Sfg::GetConstraintEntryPrivate(const GameInfoset &infoset, const GameAction &action)
{
return E.at(infoset->GetPlayer())(infoset_row[infoset->GetPlayer()][infoset],
m_sequenceColumns[infoset->GetPlayer()][action]);
Expand Down Expand Up @@ -116,15 +116,15 @@ void Sfg::FillTableau(const GameNode &n, const Rational &prob,
}
}
else {
GetConstraintEntry(n->GetInfoset(), previousActions.at(n->GetPlayer())) = Rational(1);
GetConstraintEntryPrivate(n->GetInfoset(), previousActions.at(n->GetPlayer())) = Rational(1);
for (auto action : support.GetActions(n->GetInfoset())) {
if (m_sequenceColumns[n->GetPlayer()].find(action) ==
m_sequenceColumns[n->GetPlayer()].end()) {
m_sequenceColumns[n->GetPlayer()][action] = m_sequenceColumns[n->GetPlayer()].size() + 1;
m_sequences[n->GetPlayer()].push_back(action);
}
previousActions[n->GetPlayer()] = action;
GetConstraintEntry(n->GetInfoset(), action) = Rational(-1);
GetConstraintEntryPrivate(n->GetInfoset(), action) = Rational(-1);
FillTableau(n->GetChild(action), prob, previousActions);
previousActions[n->GetPlayer()] = m_actionParents[n->GetPlayer()][action];
}
Expand Down
9 changes: 8 additions & 1 deletion src/solvers/enumpoly/sfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Sfg {
void FillTableau(const GameNode &, const Rational &, PureSequenceProfile &);

Rational &GetMatrixEntry(const PureSequenceProfile &, const GamePlayer &);
Rational &GetConstraintEntry(const GameInfoset &, const GameAction &);
Rational &GetConstraintEntryPrivate(const GameInfoset &, const GameAction &);

public:
explicit Sfg(const BehaviorSupportProfile &);
Expand Down Expand Up @@ -111,6 +111,13 @@ class Sfg {
return E.at(p_player)(infoset_row, seq_col);
}

const Rational &GetConstraintEntry(const GameInfoset &p_infoset,
const GameAction &p_action) const
{
return E.at(p_infoset->GetPlayer())(infoset_row.at(p_infoset->GetPlayer()).at(p_infoset),
GetSequenceNumber(p_infoset->GetPlayer(), p_action));
}

int InfosetRowNumber(const GamePlayer &p_player, int sequence) const
{
if (sequence == 1) {
Expand Down

0 comments on commit 44145b2

Please sign in to comment.