Base Data

Data logging, management, and reward calculation.

class GlobalReward[source]

Bases: ABC, Resetable

Base class for simulation-wide data management and rewarding.

The method calculate_reward must be overridden by subclasses. Other methods may be extended as necessary for housekeeping.

datastore_type: type[DataStore]

Link the data manager to the scenario.

Parameters:

scenario (Scenario) – The scenario that the data manager is being used with.

Return type:

None

reset_overwrite_previous() None[source]

Overwrite attributes from previous episode.

Return type:

None

initial_data(satellite: Satellite) Data[source]

Furnish the DataStore with initial data.

Parameters:

satellite (Satellite)

Return type:

Data

create_data_store(satellite: Satellite, **data_store_kwargs) None[source]

Create a data store for a satellite.

Parameters:
  • satellite (Satellite) – Satellite to create a data store for.

  • data_store_kwargs – Additional keyword arguments to pass to the data store

Return type:

None

abstract calculate_reward(new_data_dict: dict[str, Data]) dict[str, float][source]

Calculate step reward based on all satellite data from a step.

Returns a dictionary of rewards for each satellite based on the new data generated by each satellite during the previous step, in the form:

{"sat-1_id": 0.23, "sat-2_id": 0.0, ...}
Parameters:

new_data_dict (dict[str, Data]) –

A dictionary of new data generated by each satellite, in the form:

{"sat-1_id": data1, "sat-2_id": data2, ...}

Return type:

dict[str, float]

reward(new_data_dict: dict[str, Data]) dict[str, float][source]

Call calculate_reward and log cumulative reward.

Parameters:

new_data_dict (dict[str, Data])

Return type:

dict[str, float]

class DataStore(satellite: Satellite, initial_data: Data | None = None)[source]

Bases: ABC

Base class for satellite data logging.

One DataStore is created for each satellite in the scenario each time the scenario is reset. The DataStore is responsible for generating data from the satellite’s environment and actions by comparing the current and previous-step state from get_log_state and returning a unit of data with compare_log_states. These two methods must be implemented by subclasses.

Parameters:
  • satellite (Satellite) – Satellite which data is being stored for.

  • initial_data (Data | None) – Initial data to start the store with. Usually comes from initial_data.

data_type: type[Data]
get_log_state() Any[source]

Pull information used in determining current data contribution.

Return type:

Any

abstract compare_log_states(old_state: Any, new_state: Any) Data[source]

Generate a unit of data based on previous step and current step logs.

Parameters:
Returns:

New data generated by the satellite.

Return type:

Data

update_from_logs() Data[source]

Update the data store based on collected information.

Returns:

New data from the previous step.

Return type:

Data

stage_communicated_data(external_data: Data) None[source]

Prepare data to be added from another source, but don’t add it yet.

Works with update_with_communicated_data to add data from other satellites without erroneously propagating it through other satellites.

Parameters:

external_data (Data) – Data from another satellite to be added

Return type:

None

update_with_communicated_data() None[source]

Update the data store from staged data.

Return type:

None

class Data[source]

Bases: ABC

Base class for units of satellite data.

Only needs to implement the __add__ method, which is used to combine two units of data. This is used when adding new data from actions or communication to the data store.