seemps.analysis.optimization.optimize_mps#

seemps.analysis.optimization.optimize_mps(mps: MPS, num_indices: int = 100, make_canonical: bool = True)[source]#

Returns the minimum and maximum values of a given MPS, together with their indices. Performs two full sweeps using optima_tt, one for the left-to-right and right-to-left directions respectively.

Parameters:
mpsMPS

The MPS to optimize.

num_indicesint, default=100

The maximum amount of indices to retain from each tensor. A larger number increases the probability of finding the global maxima, but has a larger cost.

make_canonicalbool, default=True

Whether to canonicalize the MPS prior to the search and orthogonalize its tensors.

Returns:
(i_1, y_1)tuple

A tuple with the index and minimum value in the MPS.

(i_2, y_2)tuple

A tuple with the index and maximum value in the MPS.

Examples

# Compute the two extrema of a given univariate function.
# Assume that the function is already loaded.
mps_function_1d = ...
(i_min, y_min), (i_max, y_max) = optimize_mps(mps)