load_state#
- TwinModel.load_state(model_id, evaluation_time, epsilon=1e-08)#
Load a state that has been saved by a TwinModel instantiated with same .twin file. Calling this method replaces evaluation initialization.
- Parameters:
- model_id: str
This is the id of the model that saved the state.
- evaluation_time: float
Evaluation time at which the state was saved.
- epsilon: float
Absolute period that is added before and after evaluation time to account for round off error while searching the saved state. Search is performed in the interval [t-epsilon, t+epsilon] with t the evaluation time. First found saved state in this interval is loaded.
- Raises:
- TwinModelError:
If no state has been saved by model with 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)