예제 #1
0
 def test_pid_controller(self, mock_input):
     pid_controller = PIDController(P=0.001, I=0.00001, D=0.001)
     # animation, parallel, save_path, sim_time, scenario, scenario random
     # seed, start_time, patients, sensor, sensor seed, insulin pump,
     # controller
     mock_input.side_effect = ['y', 'n', output_folder, '24', '1', '2',
                               '6', '5', '1', 'd', '1', '1', '2', '1']
     s = simulate(controller=pid_controller)
     self.assertEqual(s, 0)
예제 #2
0
 def test_ui(self, mock_input):
     # animation, parallel, save_path, sim_time, scenario, scenario random
     # seed, start_time, patients, sensor, sensor seed, insulin pump,
     # controller
     mock_input.side_effect = [
         'n', 'y', output_folder, '24', '1', '2', '6', '1', '1', '1', '2',
         '1'
     ]
     s = simulate()
     self.assertEqual(s, 0)
예제 #3
0
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt

from simglucose.simulation.user_interface import simulate

simulate()
예제 #4
0
from simglucose.controller.pid_ctrller import PIDController
from simglucose.simulation.user_interface import simulate

pid_controller = PIDController(P=0.001, I=0.00001, D=0.001, target=140)
s = simulate(controller=pid_controller)
        '''
        Every controller must have this implementation!
        ----
        Inputs:
        observation - a namedtuple defined in simglucose.simulation.env. For
                      now, it only has one entry: blood glucose level measured
                      by CGM sensor.
        reward      - current reward returned by environment
        done        - True, game over. False, game continues
        info        - additional information as key word arguments,
                      simglucose.simulation.env.T1DSimEnv returns patient_name
                      and sample_time
        ----
        Output:
        action - a namedtuple defined at the beginning of this file. The
                 controller action contains two entries: basal, bolus
        '''
        self.state = observation
        action = Action(basal=0, bolus=0)
        return action

    def reset(self):
        '''
        Reset the controller state to inital state, must be implemented
        '''
        self.state = self.init_state


ctrller = MyController(0)
simulate(controller=ctrller)