Environment

BaseEnvironment

class BaseEnvironment.BaseEnvironment(as_tcp_ip_client: bool = True, instance_id: int = 1, instance_nb: int = 1, **kwargs)[source]
apply_prediction(prediction: Dict[str, ndarray]) None[source]

Apply network prediction in environment. Not mandatory.

Parameters

prediction – Prediction data.

check_sample() bool[source]

Check if the current produced sample is usable for training. Not mandatory.

Returns

Current data can be used or not

close() None[source]

Close the Environment. Automatically called when Environment is shut down. Not mandatory.

create() None[source]

Create the Environment. Automatically called when Environment is launched. Must be implemented by user.

define_additional_fields(fields: Union[List[Tuple[str, Type]], Tuple[str, Type]]) None[source]

Specify the additional data fields names and types.

Parameters

fields – Field or list of Fields to tag as additional data.

define_training_fields(fields: Union[List[Tuple[str, Type]], Tuple[str, Type]]) None[source]

Specify the training data fields names and types.

Parameters

fields – Field or list of fields to tag as training data.

get_database_handler() DatabaseHandler[source]

Get the DatabaseHandler of the Environment.

get_prediction(**kwargs) Dict[str, ndarray][source]

Request a prediction from Network.

Returns

Network prediction.

init() None[source]

Initialize the Environment. Automatically called when Environment is launched. Not mandatory.

init_database() None[source]

Define the fields of the training dataset. Automatically called when Environment is launched. Must be implemented by user.

init_visualization() None[source]

Define the visualization objects to send to the Visualizer. Automatically called when Environment is launched. Not mandatory.

load_parameters() Dict[str, Any][source]

Load a set of parameters from the Database.

save_parameters(**kwargs) None[source]

Save a set of parameters in the Database.

set_additional_data(**kwargs) None[source]

Set the additional data to send to the TcpIpServer or the EnvironmentManager.

set_training_data(**kwargs) None[source]

Set the training data to send to the TcpIpServer or the EnvironmentManager.

async step() None[source]

Compute the number of steps in the Environment specified by simulations_per_step in EnvironmentConfig. Must be implemented by user.

update_visualisation() None[source]

Triggers the Visualizer update.

BaseEnvironmentConfig

class BaseEnvironmentConfig.BaseEnvironmentConfig(environment_class: Type[BaseEnvironment], as_tcp_ip_client: bool = True, number_of_thread: int = 1, ip_address: str = 'localhost', port: int = 10000, simulations_per_step: int = 1, max_wrong_samples_per_step: int = 10, load_samples: bool = False, only_first_epoch: bool = True, always_produce: bool = False, visualizer: Optional[Type[VedoVisualizer]] = None, record_wrong_samples: bool = False, env_kwargs: Optional[Dict[str, Any]] = None)[source]
create_environment() BaseEnvironment[source]

Create an Environment that will not be a TcpIpObject.

Returns

Environment object.

create_server(environment_manager: Optional[Any] = None, batch_size: int = 1, visualization_db: Optional[Tuple[str, str]] = None) TcpIpServer[source]

Create a TcpIpServer and launch TcpIpClients in subprocesses.

Parameters
  • environment_manager – EnvironmentManager.

  • batch_size – Number of sample in a batch.

  • visualization_db – Path to the visualization Database to connect to.

Returns

TcpIpServer object.

start_client(idx: int = 1) None[source]

Run a subprocess to start a TcpIpClient.

Parameters

idx – Index of client.

start_server(server: TcpIpServer, visualization_db: Optional[Tuple[str, str]] = None) None[source]

Start TcpIpServer.

Parameters
  • server – TcpIpServer.

  • visualization_db – Path to the visualization Database to connect to.