Skip to content

Solving

Convenience Function

gropt.solve

solve(params: GroptParams, min_iter: int = 1, max_iter: int = 2000, log_interval: int = 20, gamma_x: float = 1.6, max_feval: int = 12000, extra_iters: int = 0, ils_tol: float = 0.001, ils_max_iter: int = 20, ils_min_iter: int = 2, ils_sigma: float = 0.0001, ils_tik_lam: float = 0.0) -> SolveResult

Convenience function to solve a GrOpt problem.

Parameters:

Name Type Description Default
params GroptParams

The problem definition.

required
min_iter int

General solver parameters (see SolverGroptSDMM.set_general_params).

1
max_iter int

General solver parameters (see SolverGroptSDMM.set_general_params).

1
log_interval int

General solver parameters (see SolverGroptSDMM.set_general_params).

1
gamma_x int

General solver parameters (see SolverGroptSDMM.set_general_params).

1
max_feval int

General solver parameters (see SolverGroptSDMM.set_general_params).

1
ils_tol float

ILS parameters (see SolverGroptSDMM.set_ils_params).

0.001
ils_max_iter float

ILS parameters (see SolverGroptSDMM.set_ils_params).

0.001
ils_min_iter float

ILS parameters (see SolverGroptSDMM.set_ils_params).

0.001
ils_sigma float

ILS parameters (see SolverGroptSDMM.set_ils_params).

0.001
ils_tik_lam float

ILS parameters (see SolverGroptSDMM.set_ils_params).

0.001

Returns:

Type Description
SolveResult

The optimization result.

SolveResult

gropt.SolveResult

Result from a GrOpt solve operation.

Attributes:

Name Type Description
X ndarray

The optimized gradient waveform.

converged bool

Whether all constraints were satisfied.

n_iter int

Number of outer SDMM iterations.

n_feval int

Total number of inner linear solver iterations.

SolverGroptSDMM

gropt.SolverGroptSDMM

Bases: Solver

SDMM solver for GrOpt gradient optimization problems.

set_sdmm_params

set_sdmm_params(rw_interval: int = 8, rw_e_corr: float = 0.4, rw_eps: float = 1e-36, rw_scalelim: float = 1.5, grw_min_infeasible: int = 20, grw_interval: int = 20, grw_mod: float = 2.0) -> None

Set SDMM-specific parameters.

Parameters:

Name Type Description Default
rw_interval int

Interval for reweighting operations.

8
rw_e_corr float

Error correction for reweighting.

0.4
rw_eps float

Epsilon for numerical stability in reweighting.

1e-36
rw_scalelim float

Scale limit for reweighting.

1.5
grw_min_infeasible int

Minimum infeasible iterations before adaptive reweighting.

20
grw_interval int

Interval for adaptive reweighting checks.

20
grw_mod float

Modification factor for adaptive reweighting.

2.0

solve

solve(gparams: GroptParams) -> SolveResult

Run the SDMM solver.

Parameters:

Name Type Description Default
gparams GroptParams

The problem definition.

required

Returns:

Type Description
SolveResult

The optimization result containing the waveform and convergence info.

SolverOSQP

gropt.SolverOSQP

Bases: Solver

OSQP solver for GrOpt gradient optimization problems.

solve

solve(gparams: GroptParams) -> SolveResult

Run the OSQP solver.

Parameters:

Name Type Description Default
gparams GroptParams

The problem definition.

required

Returns:

Type Description
SolveResult

The optimization result containing the waveform and convergence info.

Equilibration

gropt.equilibrate

equilibrate(gparams: GroptParams, n_iter: int = 5, n_reps: int = 10) -> None

Ruiz equilibration of the operator matrix.

Iteratively scales operator rows and columns so that the maximum absolute value in each row and column approaches 1, improving solver conditioning.

Parameters:

Name Type Description Default
gparams GroptParams

The problem definition (operators will be modified in place).

required
n_iter int

Number of equilibration iterations.

5
n_reps int

Number of random vector repetitions per norm estimate.

10

gropt.estimate_row_col_norms

estimate_row_col_norms(gparams: GroptParams, n_reps: int = 10, norm_type: NormType = NormType.Inf) -> tuple[Annotated[NDArray[numpy.float64], dict(shape=(None,), order=C)], Annotated[NDArray[numpy.float64], dict(shape=(None,), order=C)]]

Estimate row and column norms of the operator matrix.

Parameters:

Name Type Description Default
gparams GroptParams

The problem definition (must have operators added).

required
n_reps int

Number of random vector repetitions for the estimate.

10
norm_type NormType

NormType.Inf (default) or NormType.L2.

Inf

Returns:

Name Type Description
row_norms ndarray

Estimated norm for each constraint row.

col_norms ndarray

Estimated norm for each variable column.

gropt.rescale_eq_vecs

rescale_eq_vecs(gparams: GroptParams, row_scale: float, col_scale: float) -> None

Rescale equilibration vectors by scalar factors.

Multiplies all operator eq_rows by row_scale and eq_cols by col_scale.

Parameters:

Name Type Description Default
gparams GroptParams

The problem definition.

required
row_scale float

Scale factor applied to all row equilibration vectors.

required
col_scale float

Scale factor applied to all column equilibration vectors.

required

gropt.estimate_spec_norm

estimate_spec_norm(gparams: GroptParams, n_iters: int = 20) -> float

Estimate the spectral norm of the operator matrix via power iteration.

Parameters:

Name Type Description Default
gparams GroptParams

The problem definition (must have operators prepared).

required
n_iters int

Number of power iterations.

20

Returns:

Type Description
float

Estimated spectral norm.

gropt.estimate_individual_spec_norm

estimate_individual_spec_norm(gparams: GroptParams, n_iters: int = 20, op_idx: int = 0) -> float

Estimate the spectral norm of a single operator matrix via power iteration.

Parameters:

Name Type Description Default
gparams GroptParams

The problem definition (must have operators prepared).

required
n_iters int

Number of power iterations.

20
op_idx int

Index of the operator for which to estimate the spectral norm.

0

Returns:

Type Description
float

Estimated spectral norm.