jxx123 / simglucose

A Type-1 Diabetes simulator implemented in Python for Reinforcement Learning purpose
MIT License
248 stars 114 forks source link

Patient interface missing observation, state and t #74

Open drozzy opened 1 year ago

drozzy commented 1 year ago

Patient interface is defined as :

"""Base class for patient"""

class Patient(object):
    def step(self, action):
        """
        Run one time step of the patient dynamiBodySimiFace_setPatisetPatient
        Input
            action: a namedtuple
        ------
        Outputs
            t: current time
            state: updated state
            observation: the observable states
        """
        raise NotImplementedError

    @staticmethod
    def model(t, state, action, params):
        """
        ordinary differential equations
        """
        raise NotImplementedError

    def reset(self):
        """
        Reset to the initial state
        Return observation
        """
        raise NotImplementedError

However, the code uses patient.observation, patient.state and patient.t.

Should those properties be part of the interface or not? Additionally, it seems like the static method model is not really part of required interface, so could be removed.

drozzy commented 1 year ago

Something like this:

from abc import ABC, abstractmethod

class Patient(ABC):
    """
    Actual proper base class for patient, 
    that includes the parts missing from simglucose definition
    """
    @abstractmethod
    def step(self, action):
        """
        Run one time step of the patient dynamiBodySimiFace_setPatisetPatient
        Input
            action: a namedtuple
        ------
        Outputs
            t: current time
            state: updated state
            observation: the observable states
        """
        ...

    @abstractmethod
    def reset(self):
        """
        Reset to the initial state
        Return observation
        """
        ...

    @property
    @abstractmethod
    def t(self):
        ...

    @property
    @abstractmethod
    def state(self):
        ...

    @property
    @abstractmethod
    def observation(self):
        ...
jxx123 commented 8 months ago

The patient interface is a premature design choice. There is only one class T1DPatient is inheriting the interface. Any design on the base interface is redundant.

I think we should delete the Patient interface, and if we have plan to add say T2DPatient etc. in the future, we will add the base back with a design that meets the actual needs.

What do you think?