torchmin.minimize_constr

torchmin.minimize_constr(f, x0, method=None, constr=None, bounds=None, max_iter=None, tol=None, options=None, callback=None, disp=0)[source]

Minimize a scalar function of one or more variables subject to bounds and/or constraints.

Note

Method 'trust-constr' is currently a wrapper for SciPy’s trust-constr solver.

Parameters
  • f (callable) – Scalar objective function to minimize.

  • x0 (Tensor) – Initialization point.

  • method (str, optional) –

    The minimization routine to use. Should be one of the following:

    • ’l-bfgs-b’

    • ’frank-wolfe’

    • ’trust-constr’

    If no method is provided, a default method will be selected based on the criteria of the problem.

  • constr (dict or string, optional) –

    Constraint specifications. Should either be a string (Frank-Wolfe method) or a dictionary (trust-constr method) with the following fields:

    • fun (callable) - Constraint function

    • lb (Tensor or float, optional) - Constraint lower bounds

    • ub (Tensor or float, optional) - Constraint upper bounds

    One of either lb or ub must be provided. When lb == ub it is interpreted as an equality constraint.

  • bounds (sequence or Bounds, optional) –

    Bounds on variables. There are two ways to specify the bounds:

    1. Sequence of (min, max) pairs for each element in x. None is used to specify no bound.

    2. Instance of scipy.optimize.Bounds class.

    Bounds of -inf/inf are interpreted as no bound. When lb == ub it is interpreted as an equality constraint.

  • max_iter (int, optional) – Maximum number of iterations to perform. If unspecified, this will be set to the default of the selected method.

  • tol (float, optional) – Tolerance for termination. For detailed control, use solver-specific options.

  • options (dict, optional) – A dictionary of keyword arguments to pass to the selected minimization routine.

  • callback (callable, optional) – Function to call after each iteration with the current parameter state, e.g. callback(x).

  • disp (int) –

    Level of algorithm’s verbosity:

    • 0 : work silently (default).

    • 1 : display a termination report.

    • 2 : display progress during iterations.

    • 3 : display progress during iterations (more complete report).

Returns

result – Result of the optimization routine.

Return type

OptimizeResult