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

Scenario with no meal in gym env #45

Open
maxime-louis opened this issue Jan 18, 2022 · 2 comments
Open

Scenario with no meal in gym env #45

maxime-louis opened this issue Jan 18, 2022 · 2 comments

Comments

@maxime-louis
Copy link

Hey,

Thank you for this awesome library.

I'm trying to run a gym env without any meal (ideally I would like a controller which can also suggest carb but from what I understood it's not supported).

I did the following:

start_time = datetime.now()
no_meal_scenario = CustomScenario(start_time=start_time, scenario=[])


register(
    id='env-v0',
    entry_point='simglucose.envs:T1DSimEnv',
    kwargs={'patient_name': 'adult#001',
           'custom_scenario': no_meal_scenario}
)


env = gym.make('env-v0')



min_insulin = env.action_space.low
max_insulin = env.action_space.high

observation = env.reset()
for t in range(100):
    env.render(mode='human')
    print(observation)
    action = np.random.uniform(min_insulin, max_insulin)
    
    
    print(action)
    observation, reward, done, info = env.step(action)
    if done:
        print("Episode finished after {} timesteps".format(t + 1))
        break

But I still het carbohydrates inputs sometimes:
image

What is the correct way to do that ?
Thank you !

@jingyi-y
Copy link

Same question here. It seems that custom scenario is not correctly handled in OpenAI Gym.

@jxx123
Copy link
Owner

jxx123 commented Feb 2, 2022

Yes, I did not expose the meal as an action here. I treat the random meal as a challenge for the control algorithm. You might want to implement the meal action yourself for now.

I will consider adding meal as an input in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants