Solver States Interfaces (i_solver_state)¶
- class pypint.solvers.states.i_solver_state.IStepState(**kwargs)[source]¶
Bases: builtins.object
State of a single integration step
A integration step is a single point in time.
- __weakref__¶
list of weak references to the object (if defined)
- delta_tau[source]¶
Accessor for the width of the integration step
Usually the distance to the previous integration node.
Returns: delta_tau Return type: float Raises: ValueError – if delta_tau is not non-zero positive
- integral[source]¶
Accessor for an integral value
Parameters: integral (float) – (no consistency checks are done)
- solution[source]¶
Proxy to the included solution of the state
Returns: solution Return type: StepSolutionData
- time_point[source]¶
Proxy for StepSolutionData.time_point
- class pypint.solvers.states.i_solver_state.IStateIterator(**kwargs)[source]¶
Bases: builtins.object
Interface for a sequence of states
IStateIterator models a sequence of states allowing for easy iteration over all containing states.
Examples
>>> from pypint.solutions.data_storage import TrajectorySolutionData >>> my_states = IStateIterator(solution_class=TrajectorySolutionData, element_type=IStepState, num_states=3) >>> len(my_states) 3
Notes
Please keep in mind, that only derived classes can alter the currently accesable state. Such a class is IStaticStateIterator.
- __init__(**kwargs)[source]¶
Parameters: num_states (int) – (optional) Raises: ValueError – if num_states is not a non-zero positive integer
- finalize()[source]¶
Finalize this sequence of states
This copies the solution data from all containing states to its own solution object and finalizes it. As well, the current_index is reset to zero.
Raises: RuntimeError – if this state has already been finalized
- __weakref__¶
list of weak references to the object (if defined)
- finalized[source]¶
Read-only accessor to determine the finalized state of this state sequence
Raises: RuntimeError – if this object is finalized but its containing solution object is not (though, this should never happen)
- first[source]¶
Accessor to the first state of this sequence
Returns: first – if first_index returns None Return type: None
- first_index[source]¶
Index of the first state of this seuqence
Returns: first_index – None is returned, if there are no states in this sequence Return type: 0 or None
- last[source]¶
Accessor for the last state in this sequence
Returns: last – None if last_index is None Return type: IStepState, IStateIterator or None
- last_index[source]¶
Index of the last state in this sequence
Returns: last_index – None if there are no states in this sequence Return type: int or None
- previous[source]¶
Accessor to the previous state of this sequence
Returns: previous – None if previous_index returns None Return type: IStepState, IStateIterator or None
- previous_index[source]¶
Index of the previous state of this sequence
Returns: previous_index – None if no previous state is available, i.e. if current_index is 0 Return type: int or None
- class pypint.solvers.states.i_solver_state.IStaticStateIterator(**kwargs)[source]¶
Bases: pypint.solvers.states.i_solver_state.IStateIterator
Specialized sequence of states with fixed number of states
- proceed()[source]¶
Proceed current to the next state in the sequence
Raises: RuntimeError – if this sequence has already been finalized via IStateIterator.finalize()
- next[source]¶
Accessor for the next state in this sequence
Returns: next – None if next_index is None Return type: IStepState, IStateIterator or None
- class pypint.solvers.states.i_solver_state.ITimeStepState(**kwargs)[source]¶
Bases: pypint.solvers.states.i_solver_state.IStaticStateIterator
Stores integration step states of a single time step.
- __init__(**kwargs)[source]¶
Parameters: - num_states (int) – number of states in this sequence
- solution_class (TrajectorySolutionData or StepSolutionData) – (optional) defaults to TrajectorySolutionData
- element_type (IStepState or IStateIterator) – (optional) defaults to IStepState
Raises: ValueError – if num_states is not given
- current_step_index[source]¶
Proxy for current_index
- current_time_point[source]¶
Accessor for the current step’s time point
Returns: current_time_point – None is returned if current_step is None Return type: float or None
- delta_time_step[source]¶
Accessor for the width of the time step
Returns: width_of_time_step Return type: float Raises: ValueError – (only setter) if delta_time_step is not a non-zero positive float
- last_step_index[source]¶
Proxy for last_index
- next_step_index[source]¶
Proxy for next_index
- next_time_point[source]¶
Accessor for the next step’s time point
Returns: next_time_point – None is returned if next_step is None Return type: float or None
- previous_step[source]¶
Accessor for the previous step
Returns: previous step – None is returned if previous_index is None Return type: IStepState or None
- previous_step_index[source]¶
Proxy for previous_index
- previous_time_point[source]¶
Accessor for the previous step’s time point
Returns: previous_time_point – None is returned if previous_step is None Return type: float or None
- class pypint.solvers.states.i_solver_state.IIterationState(**kwargs)[source]¶
Bases: pypint.solvers.states.i_solver_state.IStaticStateIterator
Stores time step states of a single iteration.
- __init__(**kwargs)[source]¶
Parameters: - num_time_steps (int) – number of time steps in this sequence
- num_states (int) – number of steps per time step
- solution_class (TrajectorySolutionData, any other solution class) – (optional) defaults to TrajectorySolutionData
- element_type (IStateIterator) – (optional) defaults to ITimeStepState
Raises: ValueError – if num_time_steps is not given
- finalize()[source]¶
Finalizes this iteration and copies solutions
The solutions of all steps of all time steps are copied to this sequence’s TrajectorySolutionData and is finalized afterwards.
The remaining behaviour is the same as the overridden method.
See also
IStateIterator.finalize() : overridden method
- proceed()[source]¶
Proceeds to the next time step
Same as IStaticStateIterator.proceed() with the addition, that the current time step’s initial value is set as a reference to the previous time step’s last step.
- current_step[source]¶
Proxy for ITimeStepState.current_step
- current_step_index[source]¶
Proxy for ITimeStepState.current_step_index
- current_time_step_index[source]¶
Proxy for current_index
- final_step[source]¶
Read-only accessor for the very last step
Returns: last_step – proxies ITimeStepState.last if last_time_step is not None else returns None Return type: IStepState
- first_step[source]¶
Read-only accessor for the first step
Returns: first_step – proxies ITimeStepState.first if first_time_step is not None else returns None Return type: IStepState
- first_time_step_index[source]¶
Proxy for first_index
- last_time_step_index[source]¶
Proxy for last_index
- next_step[source]¶
Read-only accessor for the next step
Returns: next_step – proxies ITimeStepState.next_step if it is not None else returns ITimeStepState.first if next_time_step is not None else returns None Return type: IStepState
- next_time_step_index[source]¶
Proxy for next_index
- previous_step[source]¶
Read-only accessor for the previous step
Returns: previous_step – proxies ITimeStepState.previous_step if it is not None else ITimeStepState.initial Return type: IStepState
- previous_time_step_index[source]¶
Proxy for previous_index
- class pypint.solvers.states.i_solver_state.ISolverState(**kwargs)[source]¶
Bases: pypint.solvers.states.i_solver_state.IStateIterator
Stores iteration states.
- finalize()[source]¶
Finalizes the whole solver state.
This copies the TrajectorySolutionData objects from the IIterationState instances of this sequence to the main IterativeSolution object and finalizes it.
- proceed()[source]¶
Proceeds to the next iteration
Extends the sequence of IIterationState by appending a new instance with the set num_time_steps and num_nodes.
- current_iteration[source]¶
Proxies IStateIterator.current
- current_iteration_index[source]¶
Proxies IStateIterator.current_index
- current_step[source]¶
Read-only accessor for the current step
Proxies ITimeStepState.current_step if current_iteration and IIterationState.current_time_step are not None else returns None.
- current_step_index[source]¶
Read-only accessor for the current step’s index
Proxies ITimeStepState.current_step_index if current_iteration and IIterationState.current_time_step are not None else returns None.
- current_time_step[source]¶
Read-only accessor for the current time step
Proxies IIterationState.current_time_step if current_iteration is not None else returns None.
- current_time_step_index[source]¶
Read-only accessor for the current time step’s index
Proxies IIterationState.current_time_step_index if current_iteration is not None else returns None.
- delta_interval[source]¶
Accessor for the total interval width.
Parameters: delta_interval (float) – width of the whole interval Raises: ValueError – if given interval is not a non-zero float
- first_iteration[source]¶
Proxies IStateIterator.first
- is_first_iteration[source]¶
Check on whether current iteration is the first one.
Returns: is_first – True if len(self) is one, False otherwise Return type: bool
- last_iteration[source]¶
Proxies IStateIterator.last
- last_iteration_index[source]¶
Proxies IStateIterator.last_index
- next_step[source]¶
Read-only accessor for the next step
Proxies IIterationState.next_step if current_iteration is not None else returns None.
- next_time_step[source]¶
Read-only accessor for the next time step
Proxies IIterationState.next_time_step if current_iteration is not None else returns None.
- previous_iteration[source]¶
Proxies IStateIterator.previous
- previous_iteration_index[source]¶
Proxies IStateIterator.previous_index
- previous_step[source]¶
Read-only accessor for the previous step
Proxies ITimeStepState.previous_step if neither current_iteration nor IIterationState.current_time_step or IIterationState.previous_step are None else returns None.
- previous_step_index[source]¶
Read-only accessor for the previous step’s index
Proxies ITimeStepState.previous_step_index if neither current_iteration nor IIterationState.current_time_step or IIterationState.previous_step are None else returns None.
- previous_time_step[source]¶
Read-only accessor for the revious time step
Proxies IIterationState.previous_time_step if current_iteration is not None else returns None.