epidemioptim/train.py
def train(config, expe_name, trial_id, beta_default):
    """
    Main training script. Defines the cost function and epidemiological model to form the environment model.

    Parameters
    ----------
    config: str
        Identifier of the configuration parameters.
    expe_name: str
        String to describe your experiment, will be used for the logging directory.
    trial_id: int
        Trial identifier for logging path.
    beta_default: float
        Additional parameter for our experiments.

    """
    # Get the configuration
    params = get_params(config_id=config, expe_name=expe_name)
    params.update(trial_id=trial_id)
    params['cost_params']['beta_default'] = beta_default

    # Set seeds
    set_seeds(params['seed'])

    # Get the epidemiological model
    model = get_model(model_id=params['model_id'],
                        params=params['model_params'])

    # Update cost function params
    params['cost_params']['N_region'] = int(model.pop_sizes[params['model_params']['region']])
    params['cost_params']['N_country']  = int(sum(list(model.pop_sizes.values())))

    # Get cost function
    cost_function = get_cost_function(cost_function_id=params['cost_id'],
                                                                               params=params['cost_params'])

    # Create the optimization problem as a Gym-like environment
    env = get_env(env_id=params['env_id'],
                  cost_function=cost_function,
                  model=model,
                  simulation_horizon=params['simulation_horizon'],
                  seed=params['seed'])


    # Setup logdir
    params = get_logdir(params=params)

    # Get DQN algorithm parameterized by beta
    algorithm = get_algorithm(algo_id=params['algo_id'],
                              env=env,
                              params=params)

    # Run the training loop
    algorithm.learn(num_train_steps=params['num_train_steps'])

    Main training script. Defines the cost function and epidemiological model to form the environment model.

    Parameters
    ----------
    config: str
        Identifier of the configuration parameters.
    expe_name: str
        String to describe your experiment, will be used for the logging directory.
    trial_id: int
        Trial identifier for logging path.
    beta_default: float
        Additional parameter for our experiments.

    
Main training script. Defines the cost function and epidemiological model to form the environment model.
Parameters

str
Identifier of the configuration parameters.
expe_name: str
String to describe your experiment, will be used for the logging directory.
trial_id: int
Trial identifier for logging path.
beta_default: float
Additional parameter for our experiments.
Main training script . Defines the cost function and epidemiological model to form the environment model . Parameters str Identifier of the configuration parameters . expe_name : str String to describe your experiment will be used for the logging directory . trial_id : int Trial identifier for logging path . beta_default : float Additional parameter for our experiments .
def train(config, expe_name, trial_id, beta_default):
    params = get_params(config_id=config, expe_name=expe_name)
    params.update(trial_id=trial_id)
    params['cost_params']['beta_default'] = beta_default
    set_seeds(params['seed'])
    model = get_model(model_id=params['model_id'],
                        params=params['model_params'])
    params['cost_params']['N_region'] = int(model.pop_sizes[params['model_params']['region']])
    params['cost_params']['N_country']  = int(sum(list(model.pop_sizes.values())))
    cost_function = get_cost_function(cost_function_id=params['cost_id'],
                                                                               params=params['cost_params'])
    env = get_env(env_id=params['env_id'],
                  cost_function=cost_function,
                  model=model,
                  simulation_horizon=params['simulation_horizon'],
                  seed=params['seed'])
    params = get_logdir(params=params)
    algorithm = get_algorithm(algo_id=params['algo_id'],
                              env=env,
                              params=params)
    algorithm.learn(num_train_steps=params['num_train_steps'])
def train ( config , expe_name , trial_id , beta_default ) : params = get_params ( config_id = config , expe_name = expe_name ) params . update ( trial_id = trial_id ) params [ 'cost_params' ] [ 'beta_default' ] = beta_default set_seeds ( params [ 'seed' ] ) model = get_model ( model_id = params [ 'model_id' ] , params = params [ 'model_params' ] ) params [ 'cost_params' ] [ 'N_region' ] = int ( model . pop_sizes [ params [ 'model_params' ] [ 'region' ] ] ) params [ 'cost_params' ] [ 'N_country' ] = int ( sum ( list ( model . pop_sizes . values ( ) ) ) ) cost_function = get_cost_function ( cost_function_id = params [ 'cost_id' ] , params = params [ 'cost_params' ] ) env = get_env ( env_id = params [ 'env_id' ] , cost_function = cost_function , model = model , simulation_horizon = params [ 'simulation_horizon' ] , seed = params [ 'seed' ] ) params = get_logdir ( params = params ) algorithm = get_algorithm ( algo_id = params [ 'algo_id' ] , env = env , params = params ) algorithm . learn ( num_train_steps = params [ 'num_train_steps' ] )
Main training script.
Main training script .
"""
    Main training script. Defines the cost function and epidemiological model to form the environment model.

    Parameters
    ----------
    config: str
        Identifier of the configuration parameters.
    expe_name: str
        String to describe your experiment, will be used for the logging directory.
    trial_id: int
        Trial identifier for logging path.
    beta_default: float
        Additional parameter for our experiments.

    """ # Get the configuration # Set seeds # Get the epidemiological model # Update cost function params # Get cost function # Create the optimization problem as a Gym-like environment # Setup logdir # Get DQN algorithm parameterized by beta # Run the training loop
config
expe_name
trial_id
beta_default