Iterative Solution (iterative_solution)¶
- class pypint.solutions.iterative_solution.IterativeSolution(*args, **kwargs)[source]¶
Bases: pypint.solutions.i_solution.ISolution
Storage for the solutions of an iterative solver.
A new solution of a specific iteration can be added via add_solution() and queried via solution().
Examples
By default, the internal solution data storage type is TrajectorySolutionData allowing for storage of the whole trajectory of the solution over the course of several iterations. However, this can be changed on initialization to only store the solution of the last time point over the course of iterations:
>>> from pypint.solutions.iterative_solution import IterativeSolution >>> from pypint.solutions.data_storage.step_solution_data import StepSolutionData >>> my_reduced_full_solution = IterativeSolution(solution_data_type=StepSolutionData)
- __init__(*args, **kwargs)[source]¶
Parameters: solution_data_type (TrajectorySolutionData or StepSolutionData) – Defaults to TrajectorySolutionData.
- _check_consistency()[source]¶
Check consistency of stored solution data objects.
Raises: ValueError – If the time points of at least two solution data storage objects differ.
- add_solution(*args, **kwargs)[source]¶
Adds a new solution data storage object.
After each call an internal consistency check is carried out, which might raise further exceptions. The number of used iterations (see used_iterations) is auto-incremented on success.
Parameters: - data (TrajectorySolutionData or StepSolutionData) – (must not be named) Exactly one unnamed argument must be given.
- iteration (int) – (optional) 1-based index of the iteration. Defaults to -1 meaning append after last stored iteration.
Raises: ValueError –
- if iteration is not an integer
- if iteration is not a valid index for the current size of stored solution data objects
- if not exactly one solution data object is given
- error(iteration)[source]¶
Accessor for the errors of a specific iteration.
Parameters: iteration (int) – 0-based index of the iteration. -1 means last iteration. Returns: error – or None if no solutions are stored. Return type: instance of Error Raises: ValueError – If given iteration index is not in the valid range.
- residual(iteration)[source]¶
Accessor for the residuals of a specific iteration.
Parameters: iteration (int) – 0-based index of the iteration. -1 means last iteration. Returns: residual – or None if no solutions are stored. Return type: instance of Residual Raises: ValueError – If given iteration index is not in the valid range.
- solution(iteration)[source]¶
Accessor for the solution of a specific iteration.
Parameters: iteration (int) – 0-based index of the iteration. -1 means last iteration. Returns: solution – or None if no solutions are stored. Return type: instance of data_storage_type Raises: ValueError – If given iteration index is not in the valid range.
- solutions[source]¶
Read-only accessor for the stored list of solution data storages.
Returns: values Return type: list of TrajectorySolutionData or StepSolutionData objects
- time_points[source]¶
Proxies TrajectorySolutionData.time_points.
Returns: time_points – None is returned if no solutions have yet been stored Return type: numpy.ndarray or None