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

Error running default InvManagement-v2, KeyError: 'user_D' #2

Open
ashleyabraham opened this issue Dec 3, 2020 · 1 comment
Open

Comments

@ashleyabraham
Copy link

I am running the default InvManagement-v2 from this or-gym fork, and I get the KeyError, do I need to pass a dictionary with user_D for the default? shouldn't the default work without passing any env configuration?

# or-gym/tests/inv_mgmnt.py /

import or_gym

env_name = 'InvManagement-v2'
env = or_gym.make(env_name)
action = env.action_space.sample()
env.step(action)
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-17-f0c1f6f27b70> in <module>
      4 env = or_gym.make(env_name)
      5 action = env.action_space.sample()
----> 6 env.step(action)

~/or_gym/envs/supply_network/inventory_management.py in step(self, action)
    418             for k in self.market:
    419                 #read user specified demand. if all zeros, use demand_dist instead.
--> 420                 Demand = self.graph.edges[(j,k)]['user_D']
    421                 if np.sum(Demand) > 0:
    422                     self.D.loc[t,(j,k)] = Demand[t]

KeyError: 'user_D'
@ashleyabraham
Copy link
Author

I replaced lines 420 - 425 with the following code to fix the error temporarily in my copy, the code sets the default first, then checks to see if the key user_D exists before accessing it

                Demand = self.graph.edges[(j,k)]['demand_dist']
                self.D.loc[t,(j,k)] = Demand.rvs(**self.graph.edges[(j,k)]['dist_param'])

                if 'user_D' in self.graph.edges[(j,k)]:
                    Demand = self.graph.edges[(j,k)]['user_D']
                    if np.sum(Demand) > 0:
                        self.D.loc[t,(j,k)] = Demand[t]

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