Skip to content

Adds Feature/action translation (pls squash and merge me) #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

Drazcmd
Copy link

@Drazcmd Drazcmd commented Mar 23, 2025

Implements Action Translation via the Randomized Psuedo-harmonic Mapping algorithm.

Note: cargo fmt automatically added src/transport/greedy.rs and src/transport/greenkhorn.rs. I tried removing them but then cargo test errors ¯_(ツ)_/¯ (so decided to just leave them in the PR).

For more details see “Action Translation in Extensive-Form Games with Large Action Spaces:
Axioms, Paradoxes, and the Pseudo-Harmonic Mapping∗” by Sam Ganzfried and Tuomas Sandholm
(https://www.ijcai.org/Proceedings/13/Papers/028.pdf)

Drazcmd added 22 commits March 18, 2025 21:03
Initial commit of some of the basic math + skeleton code.

Includes some of the most important math needed to perform the mapping, + a deliberately-wrong test case that performs some of the math and then fails.

Big remaining work includes:
- proper testing
- updating the public function to work with the actual types used in this project
- TBD changing the input / output types (maybe structs? I just started learning rust so still need to go look thid stuff up!)
(not related to my stuff but TLDR these get created when I run cargo fmt)
Verifies the "inner" harmonic mapping function operating on the "relative to pot" ratios replicates the "Table 1: Effect of increasing A while holding B = 1 and x = 0.25 fixed." results.

I.e. keeping opponenet bet (x) and larger translated bet (B) constant as you increase the smaller translated bet (A).
Adding a vector slice input containing the bet sizes (exact in Chips, not ratios) that we want to translate to. Currently TODO to actually use it properly.

TBD: Might want to instead make this take the action_abstraction as values as ratios *normalized to the pot size*, not 100% sure which will approach will be more user friendly in practice
Iterating through each window of 2 elements until we find the first one where we're bounded on both sides.

(Technically we only need to check that we're > the smaller size to immediately know we found it given all of the early returns above, but might as well check against the larger size too to make it a little clearer what we're actually doing here / be defensive in general)
Just making it a little more easy to read. Since more likely to compare opponent's bet against the action abstraction / be calling it a bunch of times with the pot size unchanged.
Also cleaned up the docstring a little bit
TLDR actually does need a comment - not about what it's doing, but WHY it's doing it
TLDR is a LOT of checks so visually hard to see without this
I think this is basically the MVP for psuedoharmonic action translation here. Going to probably add a couple more test cases and then wrap things up here.

(Side note: still need to double check whether the annotations on the struct are correct/expected; cursory search hasn't shown me a definitive answer yet on the best way to structure things when creating a struct just to serve as the return type like this in Rust)
Should be about ready to send pull request now!
Almost forgot - other important thing this test is exercising: specifically, scale invariance. If we were to naively impelment translate_actions where we plugged in the numbers without normalizing to pot size we'd get the wrong results.

(Specifically for

f(A,B, x) = ((B - x) * (1 + A)) / ((B - A) * (1 + x))

if we don't normalize properly and just directly plug in A=25, B=75, x=50 it equals 13/51 => ~0.25. Which is WAY off from the 5/12 => ~0.4167 that is actually correct.
TLDR cargo fmt added these, but I'm not intending to mess with these directories at all. (TLDR should hopefully make it less cluttered when we squash this down.)
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.

1 participant