initialize_evaluation#

TwinModel.initialize_evaluation(parameters=None, inputs=None, json_config_filepath=None)#

Initialize the twin model evaluation with: (1) a dictionary of parameters values and/or inputs (start) values OR (2) a json configuration file (see example below).

Option (2) overrides option (1).

If no inputs is given (rather in the arguments or in the config file), then inputs are reset to their default values when calling this method. Same thing happens for parameters.

Parameters and inputs that are not found into the provided dictionaries or config file, keep their default values (i.e. the start value of the twin model).

Evaluation time is reset to zero after calling this method and Initialization time is updated.

This method must be called: (1) before to evaluate the twin model, (2) if you want to update parameters values between multiple twin evaluations (in such case the twin model is reset).

Parameters:
parametersdict, optional

The parameter values (i.e. {“name”: value}) to be used for the next evaluation.

inputsdict, optional

The input values (i.e. {“name”: value}) to be used for twin model initialization.

json_config_filepathstr, optional

A file path to a json config file (with .json extension) to be used to initialize the evaluation

Examples

>>> import json
>>> from pytwin import TwinModel
>>>
>>> config = {"version": "0.1.0", "model": {"inputs": {"input-name-1": 1., "input-name-2": 2.},         >>> "parameters": {"param-name-1": 1.,"param-name-2": 2.}}}
>>> with open('path_to_your_config.json', 'w') as f:
>>>     f.write(json.dumps(config))
>>>
>>> twin_model = TwinModel(model_filepath='path_to_your_twin_model.twin')
>>> twin_model.initialize_evaluation(json_config_filepath='path_to_your_config.json')
>>> outputs = twin_model.outputs