Skip to content

Lp lcp#698

Closed
StephenPasteris wants to merge 36 commits intomasterfrom
LP_LCP
Closed

Lp lcp#698
StephenPasteris wants to merge 36 commits intomasterfrom
LP_LCP

Conversation

@StephenPasteris
Copy link
Copy Markdown
Collaborator

Updated LP and LCP solvers, in doing so fixing a bug involving internal and missing outcomes (Issue #654). Sequence form object has been updated so that payoffs are on terminal nodes. Sequence form is now an attribute of a Game object. In addition, several tests have been added.

Copy link
Copy Markdown
Member

@tturocy tturocy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from (or perhaps related to) the specific comments, I'm concerned this is mixing together logically different changes. This will make it hard to review, but also down the road makes it harder to debug if these changes introduce bugs.

For example, having sequence-related functions in the game and making them available in Python is logically distinct from touching the LP/LCP solvers.

@cython.cfunc
def rat_to_py(r: c_Rational):
"""Convert a C++ Rational number to a Python Rational."""
return Rational(to_string(r).decode("ascii"))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I like this change. A rational will never decode to an empty string, so if this happens there is an error somewhere. This change will just hide that error.


virtual std::shared_ptr<BehaviorSupportProfile> GetFullSupport()
{
throw std::runtime_error("Sequence form can only be generated for extensive form games");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a not implemented exception which is used for this purpose.

mutable std::set<GameInfosetRep *> m_absentMindedInfosets;
mutable std::shared_ptr<BehaviorSupportProfile> m_fullSupport;

std::shared_ptr<BehaviorSupportProfile> GetFullSupport() override
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the way to do this. We should be cacheing a sequence form, not a full support.

auto player2 = p_game->GetPlayer(2);
auto sequences1 = p_game->GetSequences(player1);
auto sequences2 = p_game->GetSequences(player2);
for (auto seq : sequences1) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely where the refactoring work is starting to pay off, as this is getting closer to being much easier to read/understand!

@@ -67,22 +67,26 @@ void GameSequenceForm::BuildSequences()
}

void GameSequenceForm::FillTableau(const GameNode &n, const Rational &prob,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely need to deal with this recursion and convert it to a stack-based method. But that is outside the scope of this task.

Sequences::iterator Sequences::begin() const { return {m_support->GetSequenceForm(), false}; }
Sequences::iterator Sequences::end() const { return {m_support->GetSequenceForm(), true}; }

Sequences::iterator::iterator(const std::shared_ptr<GameSequenceForm> p_sfg, bool p_end)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a NestedElementCollection which implements exactly this generically - see how Infosets and Strategies are implemented.

@tturocy tturocy closed this Dec 18, 2025
@StephenPasteris StephenPasteris deleted the LP_LCP branch January 4, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants