SimultaneousProjection#
- class SimultaneousProjection(projections, weights=None, relaxation=1, proximity_flag=True)[source]#
Bases:
ProjectionMethodClass to represent a simultaneous projection.
- Parameters:
projections (
List[Projection]) – A list of projection methods to be applied.weights (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]] |None) – An array of weights for each projection method. If None, equal weights are assigned to each projection. Weights are normalized to sum up to 1. Default is None.relaxation (
float) – A relaxation parameter for the projection methods. Default is 1.proximity_flag (
bool) – A flag indicating whether to use proximity in the projection methods. Default is True.
- Attributes:
- projectionsList[Projection]
The list of Projection objects used in the projection method.
- all_xarray-like or None
Storage for all x values if storage is enabled during solve.
- relaxationfloat
Relaxation parameter for the projection.
- proximity_flagbool
Flag to indicate whether to take this object into account when calculating proximity.
- weightsnpt.NDArray
The weights assigned to each projection method.
Methods
project(x)Perform the (possibly relaxed) projection of input array 'x' onto the constraint.
proximity(x, proximity_measures)Calculate proximity measures of point x to the set.
solve(x[, max_iter, prox_tol, del_prox_tol, ...])Solves the optimization problem using an iterative approach.
step(x)Perform the (possibly relaxed) projection of input array 'x' onto the constraint.
visualize(ax)Visualizes all projection objects (if applicable) on the given matplotlib axis.
Notes
While the simultaneous projection is performed simultaneously mathematically, the actual computation right now is sequential.
- project(x)#
Perform the (possibly relaxed) projection of input array ‘x’ onto the constraint.
- Parameters:
x (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]) – The input array to be projected.- Return type:
ndarray- Returns:
The (possibly relaxed) projection of ‘x’ onto the constraint.
- proximity(x, proximity_measures)#
Calculate proximity measures of point x to the set.
- Parameters:
x (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]) – Input array for which the proximity measure is to be calculated.- Return type:
float- Returns:
The proximity measures of the input array x.
- solve(x, max_iter=500, prox_tol=1e-06, del_prox_tol=1e-08, del_prox_n=5, proximity_measures=None, storage=False, storage_iters=None, alternative_stopping_criterion=None, alternative_stopping_criterion_initial_call=None)#
Solves the optimization problem using an iterative approach.
- Parameters:
x (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]) – Starting point for the algorithm.max_iter (
int) – Maximum number of iterations to perform, by default 500.prox_tol (
float) – The tolerance for the proximity on the constraints, by default 1e-6.del_prox_tol (
float) – The tolerance for the change in proximity over the last del_prox_n iterations, by default 1e-8.del_prox_n (
int) – The number of iterations that del_prox_tol needs to be met in a row, by default 5.proximity_measures (
Optional[List]) – The proximity measures to calculate, by default a l2 norm measure is used. Right now only the first in the list is used to check the feasibility.storage (
bool) – Flag indicating whether to store intermediate solutions, by default False.storage_iters (
Union[List[int],int,None]) – Controls which iterations are stored (when storage=True). If None, all iterations are stored. If a list of ints, only those iteration indices are stored (0 = initial point). If an int, storage occurs every that many iterations.alternative_stopping_criterion (
Optional[Callable]) – Alternative stopping criterionalternative_stopping_criterion_initial_call (
Optional[Callable]) – Initial call for an alternative stopping criterion
- Return type:
ndarray- Returns:
The solution after the iterative process.
- step(x)#
Perform the (possibly relaxed) projection of input array ‘x’ onto the constraint.
- Parameters:
x (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]) – The input array to be projected.- Return type:
ndarray- Returns:
The (possibly relaxed) projection of ‘x’ onto the constraint.
- visualize(ax)#
Visualizes all projection objects (if applicable) on the given matplotlib axis.
- Parameters:
ax (matplotlib.axes.Axes) – The matplotlib axis on which to visualize the projections.