zfista package

Submodules

zfista.metrics module

zfista.metrics.calculate_metrics(*named_results: tuple[str, list[OptimizeResult]]) tuple[dict[str, dict[str, float]], dict[str, dict[str, float]]]

Calculate a variety of performance metrics for a set of named optimization results.

Parameters:

*named_results (Tuple[str, List[OptimizeResult]]) – A tuple containing a string identifier and a list of optimization results.

Returns:

A pair of dictionaries containing the metrics and performance ratios for each optimization result.

Return type:

Tuple[Dict[str, Dict[str, float]], Dict[str, Dict[str, float]]]

zfista.metrics.extract_function_values(res: list[OptimizeResult]) ndarray[Any, dtype[floating[Any]]]

Extract the objective function values from a list of OptimizeResult instances.

Parameters:

res (List[OptimizeResult]) – List of optimization results.

Returns:

Array of objective function values.

Return type:

np.ndarray

zfista.metrics.extract_non_dominated_points(F: ndarray[Any, dtype[floating[Any]]]) ndarray[Any, dtype[floating[Any]]]

Extract the non-dominated points from an objective function values array.

Parameters:

F (FloatArray) – Array of objective function values.

Returns:

Array of non-dominated points.

Return type:

np.ndarray

zfista.metrics.purity(front: ndarray[Any, dtype[floating[Any]]], front_true: ndarray[Any, dtype[floating[Any]]]) float

Compute the purity of an estimated Pareto front compared to the true Pareto front.

Parameters:
  • front (FloatArray) – Array of points in the estimated Pareto front.

  • front_true (FloatArray) – Array of points in the true Pareto front.

Returns:

The purity of the estimated Pareto front.

Return type:

float

zfista.metrics.spread_metrics(front: ndarray[Any, dtype[floating[Any]]], front_true: ndarray[Any, dtype[floating[Any]]]) tuple[floating[Any] | float, float]

Compute spread metrics (Gamma and Delta) between an estimated Pareto front and the true Pareto front.

Parameters:
  • front (FloatArray) – Array of points in the estimated Pareto front.

  • front_true (FloatArray) – Array of points in the true Pareto front.

Returns:

A tuple containing the Gamma and Delta values.

Return type:

Tuple[float, float]

zfista.problems module

class zfista.problems.FDS(n_features: int = 10, l1_ratios: Sequence[float] | None = None, l1_shifts: Sequence[float] | None = None, bounds: tuple[NDArray[np.floating[T]] | float, NDArray[np.floating[T]] | float] | None = None)

Bases: Problem

n_features = 10 (default), n_objectives = 3

We solve problems with the objective functions

\[\begin{gathered} f_1(x) = \sum_i i (x_i - i)^4 / n^2, \\ f_2(x) = \exp(\sum_i x_i / n) + \|x\|^2, \\ f_3(x) = \sum_i i (n - i + 1) \exp(-x_i) / (n (n + 1)). \end{gathered}\]

Each gradient of \(f_i\) can be written as

\[\begin{gathered} \nabla f_1(x) = 4 / n^2 \sum_i i (x_i - i)^3, \\ \nabla f_2(x) = \exp(\sum_i x_i / n) / n + 2 x, \\ \nabla f_3(x) = - [i (n - i + 1) \exp(-x_i) / (n (n + 1))]_i \end{gathered}\]

Reference: Fliege, J., Graña Drummond, L.M., Svaiter, B.F.: Newton’s method for multiobjective optimization. SIAM J. Optim. 20(2), 602–626 (2009)

f(x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]
jac_f(x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]
class zfista.problems.JOS1(n_features: int = 5, l1_ratios: Sequence[float] | None = None, l1_shifts: Sequence[float] | None = None, bounds: tuple[NDArray[np.floating[T]] | float, NDArray[np.floating[T]] | float] | None = None)

Bases: Problem

n_features = 5 (default), n_objectives = 2

We solve problems with the objective functions

\[\begin{gathered} f_1(x) = (1 / n) \sum_i x_i^2, \\ f_2(x) = (1 / n) \sum_i (x_i - 2)^2. \end{gathered}\]

Each gradient of \(f_i\) can be written as

\[\nabla f_1(x) = (2 / n) x, \nabla f_2(x) = (2 / n) (x - 2).\]

Reference: Jin, Y., Olhofer, M., Sendhoff, B.: Dynamic weighted aggregation for evolutionary multi-objective optimization: Why does it work and how? In: GECCO’01 Proceedings of the 3rd Annual Conference on Genetic and Evolutionary Computation, pp. 1042–1049 (2001)

f(x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]
jac_f(x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]
class zfista.problems.LinearFunctionRank1(n_features: int = 10, n_objectives: int = 4, l1_ratios: Sequence[float] | None = None, l1_shifts: Sequence[float] | None = None, bounds: tuple[FloatArray | float, FloatArray | float] | None = None)

Bases: Problem

n_features = 10 (default), n_objectives = 4 (default)

We solve problems with the objective functions

\[\begin{gathered} f_i(x) = \left( i \sum_{j = 1}^n j x_j - 1 \right)^2, \quad i = 1, \dots, 4. \end{gathered}\]

Each gradient of \(f_i\) can be written as

\[\begin{gathered} \nabla f_i(x) = \left[ 2 i k \left( i \sum_{j = 1}^n j x_j - 1 \right) \right]_k \end{gathered}\]

Reference: Moré, J.J., Garbow, B.S., Hillstrom, K.E.: Testing unconstrained optimization software. ACM T. Math. Softw. 7(1), 17–41 (1981)

f(x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]
jac_f(x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]
class zfista.problems.Problem(n_features: int, n_objectives: int, l1_ratios: Sequence[float] | None = None, l1_shifts: Sequence[float] | None = None, bounds: tuple[NDArray[np.floating[T]] | float, NDArray[np.floating[T]] | float] | None = None)

Bases: object

Superclass of test problems to be solved by the proximal gradient methods for multiobjective optimization.

In all test problems, each objective function can be written as

\[F_i(x) = f_i(x) + g_i(x),\]

where \(f_i\) is convex and differentiable and \(g_i\) is closed, proper and convex.

Parameters:
  • n_features – The dimension of the decision variable.

  • n_objectives – The number of objective functions.

  • l1_ratios – An array of shape (n_objectives,) containing the coefficients for the L1 regularization term for each objective function. If not provided, no L1 regularization is applied.

  • l1_shifts – An array of shape (n_objectives,) containing the shifts for the L1 regularization term for each objective function. If not provided, no shifts are applied.

  • bounds – A tuple with two elements representing the lower and upper bounds of the decision variable. Each element can be a scalar or an array of shape (n_features,). If not provided, no bounds are applied.

abstract f(x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]
g(x: ndarray[Any, dtype[floating[Any]]]) ndarray[Any, dtype[floating[Any]]]
abstract jac_f(x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]
minimize_proximal_gradient(x0: NDArray[np.floating[T]], **kwargs: Any) OptimizeResult
prox_wsum_g(weight: ndarray[Any, dtype[floating[T]]], x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]
class zfista.problems.SD

Bases: Problem

n_features = 4, n_objectives = 2

We solve problems with the objective functions

\[\begin{gathered} f_1(x) = 2 x_1 + \sqrt{2} x_2 + \sqrt{2} x_3 + x_4, \\ f_2(x) = 2 / x_1 + 2 \sqrt{2} / x_2 + 2 \sqrt{2} / x_3 + x_4, \end{gathered}\]

subject to

\[[1, \sqrt{2}, \sqrt{2}, 1] \le x \le [3, 3, 3, 3].\]

Each gradient of f_i can be written as

\[\nabla f_1(x) = [1, \sqrt{2}, \sqrt{2}, 1], \nabla f_2(x) = 0.\]

Reference: Stadler, W., Dauer, J.: Multicriteria optimization in engineering: a tutorial and survey. In: Kamat, M.P. (ed.) Progress in Aeronautics and Astronautics: Structural Optimization: Status and Promise, vol. 150, pp. 209–249. American Institute of Aeronautics and Astronautics, Reston (1992)

f(x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]
jac_f(x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]
class zfista.problems.TOI4(l1_ratios: Sequence[float] | None = None, l1_shifts: Sequence[float] | None = None, bounds: tuple[NDArray[np.floating[T]] | float, NDArray[np.floating[T]] | float] | None = None)

Bases: Problem

n_features = 4, n_objectives = 2

We solve problems with the objective functions

\[\begin{gathered} f_1(x) = x_1^2 + x_2^2 + 1, f_2(x) = 0.5((x_1 - x_2)^2 + (x_3 - x_4)^2) + 1. \end{gathered}\]

Each gradient of \(f_i\) can be written as

\[\begin{gathered} \nabla f_1(x) = (2 x_1, 2 x_2, 0, 0)^\top, \nabla f_2(x) = (x_1 - x_2, x_2 - x_1, x_3 - x_4, x_4 - x_3)^\top. \end{gathered}\]

Reference: Toint, Ph.L.: Test problems for partially separable optimization and results for the routine PSPMIN. Tech. Rep. 83/4, Department of Mathematics, University of Namur, Brussels (1983)

f(x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]
jac_f(x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]
class zfista.problems.TRIDIA(l1_ratios: Sequence[float] | None = None, l1_shifts: Sequence[float] | None = None, bounds: tuple[NDArray[np.floating[T]] | float, NDArray[np.floating[T]] | float] | None = None)

Bases: Problem

n_features = 3, n_objectives = 3

We solve problems with the objective functions

\[\begin{gathered} f_1(x) = (2 x_1 - 1)^2, f_2(x) = 2 (2 x_1 - x_2)^2, f_3(x) = 3 (2 x_2 - x_3)^2. \end{gathered}\]

Each gradient of \(f_i\) can be written as

\[\begin{gathered} \nabla f_1(x) = (8 x_1 - 4, 0, 0)^\top, \nabla f_2(x) = (16 x_1 - 8 x_2, 4 x_2 - 8 x_1, 0)^\top, \nabla f_3(x) = (0, 24 x_2 - 12 x_3, 6 x_3 - 12 x_2)^\top. \end{gathered}\]

Reference: Toint, Ph.L.: Test problems for partially separable optimization and results for the routine PSPMIN. Tech. Rep. 83/4, Department of Mathematics, University of Namur, Brussels (1983)

f(x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]
jac_f(x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]
class zfista.problems.ZDT1(n_features: int = 30)

Bases: Problem

n_features = 30 (default), n_objectives = 2

We solve problems with the objective functions

\[\begin{gathered} f_1(x) = x_1, \\ f_2(x) = h(x) \left( 1 - \sqrt{\frac{x_1}{h(x)}} \right), \end{gathered}\]

where

\[h(x) = 1 + \frac{9}{n - 1} \sum_{i=2}^n x_i.\]

Each gradient of \(f_i\) can be written as

\[\begin{gathered} \nabla f_1(x) = (1, 0, \dots, 0)^\top, \\ \nabla f_2(x) = (- \frac{\sqrt{h(x) / x_1}}{2}, \frac{9}{2 (n - 1)} (1 - \sqrt{x_1 / h(x)}), \dots, \frac{9}{2 (n - 1)} (1 - \sqrt{x_1 / h(x)}) )^\top. \end{gathered}\]

Reference: Zitzler, E., Deb, K., Thiele, L.: Comparison of multiobjective evolutionary algorithms: empirical results. Evolutionary Computation, IEEE Transactions on 8(2), 257–271 (2000)

f(x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]
jac_f(x: ndarray[Any, dtype[floating[T]]]) ndarray[Any, dtype[floating[T]]]

zfista.proximal_gradient module

zfista.proximal_gradient.minimize_proximal_gradient(f: Callable[[ndarray[Any, dtype[floating[Any]]]], floating[Any] | float] | Callable[[ndarray[Any, dtype[floating[Any]]]], ndarray[Any, dtype[floating[Any]]]], g: Callable[[ndarray[Any, dtype[floating[Any]]]], floating[Any] | float] | Callable[[ndarray[Any, dtype[floating[Any]]]], ndarray[Any, dtype[floating[Any]]]], jac_f: Callable[[ndarray[Any, dtype[floating[Any]]]], ndarray[Any, dtype[floating[Any]]]], prox_wsum_g: Callable[[floating[Any] | float, ndarray[Any, dtype[floating[Any]]]], ndarray[Any, dtype[floating[Any]]]] | Callable[[ndarray[Any, dtype[floating[Any]]], ndarray[Any, dtype[floating[Any]]]], ndarray[Any, dtype[floating[Any]]]], x0: ndarray[Any, dtype[floating[Any]]], lr: float = 1, tol: float = 1e-05, tol_internal: float = 1e-12, max_iter: int = 1000000, max_iter_internal: int = 100000, max_backtrack_iter: int = 100, warm_start: bool = False, decay_rate: float = 0.5, nesterov: bool = False, nesterov_ratio: tuple[float, float] = (0, 0.25), return_all: bool = False, verbose: bool = False, deprecated: bool = False) OptimizeResult

Minimization of scalar or vector-valued function

\[F(x) := f(x) + g(x)\]

where \(f_i\) is convex and continuously differentiable and \(g_i\) is closed, proper and convex by using the proximal gradient method.

Parameters:
  • f (callable) –

    A continuously differentiable vector-valued function.

    f(x) -> float or array_like, shape (n_features,)

  • g (callable) –

    A closed, proper and convex vector-valued function.

    g(x) -> float or array_like, shape (n_features,)

  • jac_f (callable) –

    A function that returns the Jacobian matrix of \(f\).

    jac_f(x) -> array_like, shape (n_objectives, n_features)

  • prox_wsum_g (callable) –

    Proximal operator of the weighted sum of \(g_i\).

    prox_wsum_g(weight, x) -> array_like, shape (n_features,)

  • x0 (array, shape (n_features,)) – Initial guess.

  • lr (float, default=1) – The learning rate.

  • tol (float, default=1e-5) – The tolerance for the optimization: the algorithm checks the infinity norm (i.e. max abs value) of the search direction and continues until it is greater than tol.

  • tol_internal (float, default=1e-12) – The tolerance used in the solver (scipy.optimize.minimize(method='trust-constr')) for the subproblem.

  • max_iter (int, default=1000000) – The maximum number of iterations.

  • max_iter_internal (int, default=100000) – The maximum number of iterations in the solver (scipy.optimize.minimize(method='trust-constr')) for the subproblem

  • warm_start (bool, default=False) – Use warm start in the subproblem.

  • decay_rate (float, default=0.5) – Coefficient used to decay the learning rate.

  • nesterov (bool, default=False) – If True, enable Nesterov’s acceleration.

  • nesterov_ratio (tuple of floats (a, b), default=(0, 0.25)) – Coefficients used for updating stepsize: \(t_{k + 1} = \sqrt{t_k^2 - a t_k + b} + 0.5\) If nesterov is False, then nesterov_ratio will be ignored.

  • return_all (bool, default=False) – If True, return lists of the sequence \(\{x^k\}\) and the error criteria \(\|x^k - y^k\|_\infty\).

  • verbose (bool, default=False) – If True, display progress during iterations.

  • deprecated (bool, default=False) – If True, uses the deprecated constraint in the subproblem. Note that using the deprecated option is not mathematically proven to converge, and it’s advised to use the recommended condition instead.

Returns:

  • res (scipy.minimize.OptimizeResult with the fields documented below.)

  • x (array, shape (n_features,)) – Solution found.

  • fun (float or array_like) – Objective functions at the solution.

  • success (bool) – Whether or not the minimizer exited successfully.

  • message (str) – Description of the cause of the termination.

  • nit (int) – Total number of iterations of the proximal gradient method.

  • time (float) – Total time.

  • allvecs (list of array, optional) – A list of the sequence \(\{x^k\}\)

  • allfuns (list of array, optional) – A list of the function values \(\{F(x^k)\}\)

  • allerrs (list of float, optional) – A list of the error criteria \(\|x^k - y^k||_\infty\)

Module contents

zfista.minimize_proximal_gradient(f: Callable[[ndarray[Any, dtype[floating[Any]]]], floating[Any] | float] | Callable[[ndarray[Any, dtype[floating[Any]]]], ndarray[Any, dtype[floating[Any]]]], g: Callable[[ndarray[Any, dtype[floating[Any]]]], floating[Any] | float] | Callable[[ndarray[Any, dtype[floating[Any]]]], ndarray[Any, dtype[floating[Any]]]], jac_f: Callable[[ndarray[Any, dtype[floating[Any]]]], ndarray[Any, dtype[floating[Any]]]], prox_wsum_g: Callable[[floating[Any] | float, ndarray[Any, dtype[floating[Any]]]], ndarray[Any, dtype[floating[Any]]]] | Callable[[ndarray[Any, dtype[floating[Any]]], ndarray[Any, dtype[floating[Any]]]], ndarray[Any, dtype[floating[Any]]]], x0: ndarray[Any, dtype[floating[Any]]], lr: float = 1, tol: float = 1e-05, tol_internal: float = 1e-12, max_iter: int = 1000000, max_iter_internal: int = 100000, max_backtrack_iter: int = 100, warm_start: bool = False, decay_rate: float = 0.5, nesterov: bool = False, nesterov_ratio: tuple[float, float] = (0, 0.25), return_all: bool = False, verbose: bool = False, deprecated: bool = False) OptimizeResult

Minimization of scalar or vector-valued function

\[F(x) := f(x) + g(x)\]

where \(f_i\) is convex and continuously differentiable and \(g_i\) is closed, proper and convex by using the proximal gradient method.

Parameters:
  • f (callable) –

    A continuously differentiable vector-valued function.

    f(x) -> float or array_like, shape (n_features,)

  • g (callable) –

    A closed, proper and convex vector-valued function.

    g(x) -> float or array_like, shape (n_features,)

  • jac_f (callable) –

    A function that returns the Jacobian matrix of \(f\).

    jac_f(x) -> array_like, shape (n_objectives, n_features)

  • prox_wsum_g (callable) –

    Proximal operator of the weighted sum of \(g_i\).

    prox_wsum_g(weight, x) -> array_like, shape (n_features,)

  • x0 (array, shape (n_features,)) – Initial guess.

  • lr (float, default=1) – The learning rate.

  • tol (float, default=1e-5) – The tolerance for the optimization: the algorithm checks the infinity norm (i.e. max abs value) of the search direction and continues until it is greater than tol.

  • tol_internal (float, default=1e-12) – The tolerance used in the solver (scipy.optimize.minimize(method='trust-constr')) for the subproblem.

  • max_iter (int, default=1000000) – The maximum number of iterations.

  • max_iter_internal (int, default=100000) – The maximum number of iterations in the solver (scipy.optimize.minimize(method='trust-constr')) for the subproblem

  • warm_start (bool, default=False) – Use warm start in the subproblem.

  • decay_rate (float, default=0.5) – Coefficient used to decay the learning rate.

  • nesterov (bool, default=False) – If True, enable Nesterov’s acceleration.

  • nesterov_ratio (tuple of floats (a, b), default=(0, 0.25)) – Coefficients used for updating stepsize: \(t_{k + 1} = \sqrt{t_k^2 - a t_k + b} + 0.5\) If nesterov is False, then nesterov_ratio will be ignored.

  • return_all (bool, default=False) – If True, return lists of the sequence \(\{x^k\}\) and the error criteria \(\|x^k - y^k\|_\infty\).

  • verbose (bool, default=False) – If True, display progress during iterations.

  • deprecated (bool, default=False) – If True, uses the deprecated constraint in the subproblem. Note that using the deprecated option is not mathematically proven to converge, and it’s advised to use the recommended condition instead.

Returns:

  • res (scipy.minimize.OptimizeResult with the fields documented below.)

  • x (array, shape (n_features,)) – Solution found.

  • fun (float or array_like) – Objective functions at the solution.

  • success (bool) – Whether or not the minimizer exited successfully.

  • message (str) – Description of the cause of the termination.

  • nit (int) – Total number of iterations of the proximal gradient method.

  • time (float) – Total time.

  • allvecs (list of array, optional) – A list of the sequence \(\{x^k\}\)

  • allfuns (list of array, optional) – A list of the function values \(\{F(x^k)\}\)

  • allerrs (list of float, optional) – A list of the error criteria \(\|x^k - y^k||_\infty\)