Scenario

class Melodie.scenario_manager.Scenario(id_scenario: int | str | None = 0)

Bases: Element

Scenario contains a set of parameters used in simulation model. It is created before the initialization of Model.

Parameters:

id_scenario – the id of scenario. if None, this will be self-increment from 0 to scenarios_number-1

copy() Scenario

Copy current scenario to a new scenario.

Returns:

New scenario object.

setup()

Setup method, be sure to inherit it on the custom scenario class.

to_dict()

Convert this scenario object to a dict.

Returns:

A dict, property_name->property_value

to_json()

Convert this scenario to a dict without concerning non-serializable properties.

Returns:

a dict, property_name->property_value, without non-serializable properties

get_dataframe(df_info: DataFrameInfo) pd.DataFrame

Get dataframe from scenario

Parameters:

df_info

Returns:

pandas dataframe.

get_matrix(matrix_info: MatrixInfo) np.ndarray

Get matrix from scenario.

Parameters:

matrix_info

Returns:

2D numpy array