magnet.geometric_utils.linear_constrained_least_squares#

magnet.geometric_utils.linear_constrained_least_squares(C: ndarray, d: ndarray, Aeq: ndarray, beq: ndarray, lb: ndarray, ub: ndarray, x0: ndarray) ndarray#

Solve linear constrained least squares problem.

The problem solved is : minimize 0.5 * ||`C`@x - d`||**2 subject to the equality constraints `Aeq`@x = `beq, and to the bounds on variable x lb <= x <= ub (inequalities are intended component-wise).

Parameters:
  • C (np.ndarray of float) – Design matrix.

  • d (np.ndarray of float) – Target vector.

  • Aeq (np.ndarray of float) – Equality constraint matrix.

  • beq (np.ndarray of float) – Equality constraint right hand side vector.

  • lb (np.ndarray of float) – Lower and upper bounds on parameters.

  • ub (np.ndarray of float) – Lower and upper bounds on parameters.

  • x0 (np.ndarray of float) – Initial guess.

Returns:

Result of the minimization.

Return type:

np.ndarray of float

Notes

The solver used in this function is `scipy.optimize.minimize’, which is a very general optimizer, so it is not optimized for this problem. As such, the function can be slow.