Skip to content
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

MDP actions handles dict and list, but not set #1259

Open
ptoche opened this issue Aug 14, 2022 · 0 comments
Open

MDP actions handles dict and list, but not set #1259

ptoche opened this issue Aug 14, 2022 · 0 comments

Comments

@ptoche
Copy link

ptoche commented Aug 14, 2022

In mdp4e.py, there is the following:

        if isinstance(actlist, list):
            # if actlist is a list, all states have the same actions
            self.actlist = actlist

        elif isinstance(actlist, dict):
            # if actlist is a dict, different actions for each state
            self.actlist = actlist

In test_mdp4e.py, there is this:

actlist={"plan1", "plan2", "plan3"}

This is a set, not a dictionary, and is not handled by the code above. And Perhaps an error handling was intended after the elif?

Moreover (unrelatedly) I found the notation actlist confusing (since the object can be a dictionary or a set) and inconsistent with the textbook notation. I suggest replacing every instance of actions with A (consistent with the Rand T notation) and every instance of actlist with actions. Below I think is closer to the intention of the conditional above:


        if isinstance(actions, list):
            # if actions is a list, all states have the same actions
            self.actions = actions

        elif isinstance(actions, dict):
            # if actions is a dict, different actions for each state
            self.actions = {k: v for k,v in actions.items()}
        
        elif isinstance(actions, set):  # This line added
            # if actions is a set, convert to list
            self.actions = list(actions)

        else:
        # throw an error
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

No branches or pull requests

1 participant