load_state#
- TwinModel.load_state(model_id, evaluation_time, epsilon=1e-08)#
Load a state that has been saved by a twin model instantiated with the same TWIN file.
Note
Calling this method replaces evaluation initialization.
- Parameters:
- model_id
str
ID of the model that saved the state.
- evaluation_time
float
Evaluation time at which the state was saved.
- epsilon
float
,optional
Absolute period that is added before and after the evaluation time to account for round-off error while searching the saved state. The default value is
1e-8
. The search is performed in the interval [t-epsilon, t+epsilon] with t being the evaluation time. The first saved state found in this interval is loaded.
- model_id
- Raises:
- TwinModelError:
If no state has been saved by the model with the given model ID and same model name as the one calling this method.
Examples
>>> from pytwin import TwinModel >>> # Instantiate a TwinModel, initialize it and evaluate it step by step until you want to save its state >>> model1 = TwinModel('model.twin') >>> model1.initialize_evaluation() >>> model1.evaluate_step_by_step(step_size=0.1) >>> model1.save_state() >>> # Instantiate a new TwinModel with same twin file and load the saved state >>> model2 = TwinModel('model.twin') >>> model2.load_state(model_id=model1.id, evaluation_time=model1.evaluation_time) >>> model2.evaluate_step_by_step(step_size=0.1)