Skip to content

Conversation

@hmgaudecker
Copy link
Member

This gets rid of having to specify consecutive integers in describing 1d spaces manually.

Simple enough, but I am not perfectly sure about the naming yet.

…ecutive integers in describing 1d spaces. Fixes #192.
@hmgaudecker
Copy link
Member Author

Sorry for the mess...

Copy link
Member

@timmens timmens left a comment

Choose a reason for hiding this comment

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

Very nice. I have mainly two comments:

  1. I think the naming style is very different compared to other parts of lcm. Maybe rather something like @lcm.space_dimension. Or we actually also differentiate between state and action here (just like in the type annotations) and do @lcm.state_space_dimension and @lcm.action_space_dimension.
  2. I am not a fan of removing the explicit enumeration. I think a big advantage of the explicit enumeration was that users could debug more easily. Now users need to count, which is of course error prone, if they need to check which dimension of their Markov array corresponds to which category, or if they debug lcm.

@hmgaudecker hmgaudecker linked an issue Jan 12, 2026 that may be closed by this pull request
@hmgaudecker
Copy link
Member Author

  1. Fair enough. I will try to come up with something better, currently working through the big pic.

    In the end, this is the grid description, maybe merging those is the way to go -- but not sure yet.

    In the docstring of DiscreteGrid, I find:

    Must be a dataclass with fields that have unique scalar int or float values.

    Can you remind me of a use case for floats? Or is this outdated?

  2. I am not sure whether I agree yet -- in my mind this was one of the main points of ENH: Single action sets and state spaces #192 -- but I see your point.

@timmens
Copy link
Member

timmens commented Jan 12, 2026

  1. This seems to be outdated. The dataclass should only allow ints. Also: The naming should not be a showstopper. We can always rename afterwards.
  2. I remember that I actually proposed to use something similar to enum.auto() to generate the indices automatically. Since then I changed my mind, and think that the indices might be helpful after all. But also here, we could go ahead and merge, and if users miss the indices we revert that change.

@hmgaudecker
Copy link
Member Author

Great. How about @categorical for the decorator?

This is explicitly similar to pandas' notion of categoricals since it is precisely the same idea.

A natural way of passing transition matrices would be a DataFrame with a MultiIndex of (typically) Age and the current states and actions / future states, each of which have CategoricalDtypes corresponding to the attributes of the dataclasses decorated with @categorical.

@hmgaudecker
Copy link
Member Author

I remember that I actually proposed to use something similar to enum.auto() to generate the indices automatically. Since then I changed my mind, and think that the indices might be helpful after all. But also here, we could go ahead and merge, and if users miss the indices we revert that change.

I'd prefer that. We won't have too many outcomes, typically. And it is near-trivial to look at the actual DiscreteGrid or a dataclass like LaborSupply by just importing file or setting a breakpoint in the user entry code.

Copy link
Member

@timmens timmens left a comment

Choose a reason for hiding this comment

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

I like this!

@hmgaudecker hmgaudecker merged commit 6ca328e into main Jan 13, 2026
7 checks passed
@hmgaudecker hmgaudecker deleted the fix-192 branch January 13, 2026 16:20
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.

ENH: Single action sets and state spaces

3 participants