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

Fix random init state #80

Merged
merged 4 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*.pyc

# results foler
/results/
/examples/results

# Setuptools distribution folder.
/dist/
Expand Down
Binary file removed examples/results/2017-12-31_17-46-32/BG_trace.png
Binary file not shown.
Binary file removed examples/results/2017-12-31_17-46-32/CVGA.png
Binary file not shown.
2 changes: 0 additions & 2 deletions examples/results/2017-12-31_17-46-32/CVGA_stats.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adolescent#001.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adolescent#002.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adolescent#003.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adolescent#004.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adolescent#005.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adolescent#006.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adolescent#007.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adolescent#008.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adolescent#009.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adolescent#010.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adult#001.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adult#002.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adult#003.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adult#004.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adult#005.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adult#006.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adult#007.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adult#008.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adult#009.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/adult#010.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/child#001.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/child#002.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/child#003.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/child#004.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/child#005.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/child#006.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/child#007.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/child#008.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/child#009.csv

This file was deleted.

482 changes: 0 additions & 482 deletions examples/results/2017-12-31_17-46-32/child#010.csv

This file was deleted.

31 changes: 0 additions & 31 deletions examples/results/2017-12-31_17-46-32/performance_stats.csv

This file was deleted.

Binary file removed examples/results/2017-12-31_17-46-32/risk_stats.png
Binary file not shown.
91 changes: 0 additions & 91 deletions examples/results/2017-12-31_17-46-32/risk_trace.csv

This file was deleted.

Binary file removed examples/results/2017-12-31_17-46-32/zone_stats.png
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/run_gymnasium.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
register(
id="simglucose/adolescent2-v0",
entry_point="simglucose.envs:T1DSimGymnaisumEnv",
max_episode_steps=10,
max_episode_steps=1000,
kwargs={"patient_name": "adolescent#002"},
)

Expand Down
42 changes: 42 additions & 0 deletions examples/run_mpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import pandas as pd
from datetime import timedelta, datetime
from simglucose.controller.mpc_ctrller import PatientModel, MPCController
from simglucose.simulation.user_interface import simulate
from simglucose.simulation.scenario_gen import RandomScenario

RESULT_PATH = './results/sysid_results/adolescent#001.csv'
df_result = pd.read_csv(RESULT_PATH)
df_result = df_result.iloc[:-1, :]
patient_name = 'adolescent#001'
na = 3
nb = 5
nc = 5
X = df_result.loc[:, ['insulin', 'CHO']].values
y = df_result['CGM'].values
mdl = PatientModel(patient_name, na, nb, nc, X, y)

# print(mdl.params)
# print(mdl.alpha)
# print(mdl.beta)

N = 60 # horizon 5hr
Q = 1 #
QN = 10 # final cost
R = 1000 # input penality

ctrller = MPCController(patient_name, mdl, N, Q, QN, R, insulin_max=1)

SIM_RESULT_PATH = './results/mpc_results'
start_time = datetime.combine(datetime.now().date(),
datetime.min.time()) + timedelta(hours=7)
simulate(sim_time=timedelta(hours=24),
scenario=RandomScenario(start_time=start_time, seed=1),
patient_names=['adolescent#001'],
cgm_name='Dexcom',
cgm_seed=1,
insulin_pump_name='Insulet',
controller=ctrller,
start_time=start_time,
save_path=SIM_RESULT_PATH,
animate=True,
parallel=False)
22 changes: 22 additions & 0 deletions examples/run_sys_id_experiments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from datetime import timedelta, datetime
from simglucose.controller.sys_id_controller import SysIDController
from simglucose.simulation.user_interface import simulate
from simglucose.simulation.scenario import CustomScenario

RESULT_PATH = './results/sysid_results'

start_time = datetime.combine(datetime.now().date(), datetime.min.time())

insulin_time = [start_time + timedelta(hours=10)]
insulin_amount = [0.5]
sysid_controller = SysIDController(insulin_time, insulin_amount)

simulate(sim_time=timedelta(hours=24),
scenario=CustomScenario(start_time=start_time,
scenario=[(start_time + timedelta(hours=7),
30)]),
controller=sysid_controller,
start_time=start_time,
save_path=RESULT_PATH,
animate=True,
parallel=True)
Binary file added results/sysid_results/BG_trace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added results/sysid_results/CVGA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions results/sysid_results/CVGA_stats.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
,A,B,C,D,E
0,0.0,0.2,0.03333333333333333,0.16666666666666666,0.03333333333333333
Loading
Loading