ProjectionMethod#

class ProjectionMethod(projections, relaxation=1, proximity_flag=True)[source]#

Bases: Projection, ABC

A class used to represent methods for projecting a point onto multiple sets.

Parameters:
  • projections (List[Projection]) – A list of Projection objects to be used in the projection method.

  • relaxation (float) – A relaxation parameter for the projection method (default is 1).

  • proximity_flag (bool) – Flag to indicate whether to take this object into account when calculating proximity, by default 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.

proximitieslist

A list to store proximity values during the solve process.

relaxationfloat

Relaxation parameter for the projection.

proximity_flagbool

Flag to indicate whether to take this object into account when calculating proximity.

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.

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)[source]#

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 criterion

  • alternative_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)[source]#

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.