Esempio n. 1
0
def observation_space():
    """Return observation space.
    The state is (susceptible, exposed, infected, recovered).
    """
    state_dim = State.num_variables()
    state_space_low = np.zeros(state_dim)
    state_space_high = np.inf * np.ones(state_dim)
    return spaces.Box(state_space_low, state_space_high, dtype=np.float64)
Esempio n. 2
0
def credit_action_space(initial_state):
    """Return action space for credit simulator.
    
    The action space is the vector of possible logistic regression
    parameters, which depends on the dimensionality of the features.
    """
    num_features = initial_state.features.shape[1]
    return spaces.Box(low=-np.inf,
                      high=np.inf,
                      shape=(num_features, ),
                      dtype=np.float64)
Esempio n. 3
0
def action_space():
    """Return action space.

    There are four control variables in the model:
        - Treated bednet use
        - Condom use
        - Direct treatment of infected humans
        - Indoor residual spray use.

    """
    return spaces.Box(np.zeros(4), np.ones(4), dtype=np.float64)
Esempio n. 4
0
def observation_space():
    """Return observation space.
 
    The state is (uninfected_T1, infected_T1, uninfected_T2, infected_T2,
    free_virus, immune_response) in units (cells/ml, cells/ml, cells/ml,
    cells/ml, copies/ml, cells/ml).
    """
    state_dim = State.num_variables()
    state_space_low = np.zeros(state_dim)
    state_space_high = np.inf * np.ones(state_dim)
    return spaces.Box(state_space_low, state_space_high, dtype=np.float64)
Esempio n. 5
0
def credit_observation_space(initial_state):
    """Return observation space for credit simulator.
    
    The observation space is the vector of possible datasets, which
    must have the same dimensions as the initial state.
    """
    return spaces.Dict({
        "features":
        spaces.Box(
            low=-np.inf,
            high=np.inf,
            shape=initial_state.features.shape,
            dtype=np.float64,
        ),
        "labels":
        spaces.Box(
            low=-np.inf,
            high=np.inf,
            shape=initial_state.labels.shape,
            dtype=np.float64,
        ),
    })
Esempio n. 6
0
def observation_space():
    """Return the model observation space."""
    num_states = State.num_variables()
    state_space_low = np.zeros(num_states)
    state_space_high = np.inf * np.ones(num_states)
    return spaces.Box(state_space_low, state_space_high, dtype=np.float64)
Esempio n. 7
0
def compute_intervention(action, time):
    """Return intervention that changes the classifier parameters to action."""
    return Intervention(time=time, theta=action)


CreditEnv = ODEEnvBuilder(
    simulate_fn=simulate,
    config=Config(),
    # The initial state is the baseline features and labels in the credit dataset
    initial_state=State(features=CreditData.features,
                        labels=CreditData.labels),
    # Action space is classifiers with the same number of parameters are
    # features.
    action_space=spaces.Box(low=-np.inf,
                            high=np.inf,
                            shape=(CreditData.num_features, ),
                            dtype=np.float64),
    # Observation space is the strategically adapted features and labels
    observation_space=spaces.Dict({
        "features":
        spaces.Box(
            low=-np.inf,
            high=np.inf,
            shape=CreditData.features.shape,
            dtype=np.float64,
        ),
        "labels":
        spaces.Box(
            low=-np.inf,
            high=np.inf,
            shape=CreditData.labels.shape,
Esempio n. 8
0
def observation_space():
    """Return the observation space. The state is (nonmedical_users, oud_useres, illicit_users)."""
    state_dim = State.num_variables()
    state_space_low = np.zeros(state_dim)
    state_space_high = np.inf * np.ones(state_dim)
    return spaces.Box(state_space_low, state_space_high, dtype=np.float64)
Esempio n. 9
0
def observation_space():
    """Return observation space, the positive orthant."""
    state_dim = State.num_variables()
    state_space_low = np.zeros(state_dim)
    state_space_high = np.inf * np.ones(state_dim)
    return spaces.Box(state_space_low, state_space_high, dtype=np.float64)