BlockIterativeAMSHalfspace#

class BlockIterativeAMSHalfspace(A, b, weights, algorithmic_relaxation=1.0, relaxation=1.0, proximity_flag=True)[source]#

Bases: HalfspaceAlgorithm

Block Iterative AMS Algorithm. This class implements a block iterative version of the AMS (Alternating Minimization Scheme) algorithm. It is designed to handle constraints and weights in a block-wise manner.

Parameters:
  • A (ndarray[tuple[Any, ...], dtype[TypeVar(_ScalarT, bound= generic)]]) – Matrix for linear systems

  • b (ndarray[tuple[Any, ...], dtype[TypeVar(_ScalarT, bound= generic)]]) – Bound for linear systems

  • weights (Union[List[List[float]], List[ndarray[tuple[Any, ...], dtype[TypeVar(_ScalarT, bound= generic)]]]]) – A list of lists or arrays representing the weights for each block. Each list/array should sum to 1.

  • algorithmic_relaxation (ndarray[tuple[Any, ...], dtype[TypeVar(_ScalarT, bound= generic)]] | float) – The relaxation parameter used by the algorithm, by default 1.0.

  • relaxation (float) – Outer relaxation parameter, applied to the entire solution of the iterate by default 1.0.

  • proximity_flag (bool) – A flag indicating whether to use proximity measures, by default True.

Methods

indexed_map(x, idx)

Applies the linear mapping to the input array x at multiple specified indices.

map(x)

Applies the linear mapping to the input array x.

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.

single_map(x, i)

Applies the linear mapping to the input array x at a specific index i.

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.

Raises:

ValueError – If any of the weight lists do not sum to 1.

indexed_map(x, idx)#

Applies the linear mapping to the input array x at multiple specified indices.

Parameters:
  • x (ndarray[tuple[Any, ...], dtype[TypeVar(_ScalarT, bound= generic)]]) – The input array to which the linear mapping is applied.

  • idx (Union[List[int], ndarray[tuple[Any, ...], dtype[TypeVar(_ScalarT, bound= generic)]]]) – The indices at which the linear mapping is applied.

Return type:

ndarray

Returns:

The result of applying the linear mapping to the input array at the specified indices.

map(x)#

Applies the linear mapping to the input array x.

Parameters:

x (ndarray[tuple[Any, ...], dtype[TypeVar(_ScalarT, bound= generic)]]) – The input array to which the linear mapping is applied.

Return type:

ndarray

Returns:

The result of applying the linear mapping to the input array.

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.

single_map(x, i)#

Applies the linear mapping to the input array x at a specific index i.

Parameters:
  • x (ndarray[tuple[Any, ...], dtype[TypeVar(_ScalarT, bound= generic)]]) – The input array to which the linear mapping is applied.

  • i (int) – The specific index at which the linear mapping is applied.

Return type:

ndarray

Returns:

The result of applying the linear mapping to the input array at the specified index.

solve(x, max_iter=500, prox_tol=1e-06, del_prox_tol=1e-08, del_prox_n=5, storage=False, storage_iters=None, proximity_measures=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 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.