pysolvegn.BatchSolveResult#

class BatchSolveResult(parameters, history, success, stop_code, n_iterations, cost, optimality, term_parameters, elapsed_time, n_rejected, config)[source]#

Result of the optimization performed by pysolvegn.solve_batch().

All the per-problem arrays have the number k of problems of the batch as first dimension. For each problem, the values describe the last iteration during which the problem was processed (frozen values).

Parameters:
  • parameters (ndarray)

  • history (List[Dict])

  • success (ndarray)

  • stop_code (ndarray)

  • n_iterations (ndarray)

  • cost (ndarray | None)

  • optimality (ndarray)

  • term_parameters (ndarray | None)

  • elapsed_time (float)

  • n_rejected (ndarray)

  • config (Dict[str, Any])

parameters#

The optimized input parameters \(\mathbf{p}_{in,k}\) of each problem with shape (k, n_parameters). If no parametrization is provided, these parameters are also the parameters passed directly to the terms. If a parametrization is provided, the corresponding parameters passed to the terms are available in term_parameters.

Type:

numpy.ndarray

history#

The history of the optimization process. Each element of the list is a dictionary describing one iteration (see the Notes section of pysolvegn.solve_batch() for the available keys). Empty if history is False.

Type:

List[Dict]

success#

Array of booleans with shape (k,). success[k] is True if the optimization of the problem k stopped because a convergence criterion (ftol, atol, gtol, xtol or ptol) was satisfied. The value of each problem is determined with the following priority:

  1. Always False if the problem was stopped by a NaN or Inf value (in its initial parameters, its term parameters, its update or, with damping="lm", its cost), by a singular linear system, by the callback function, by a failure of the Levenberg-Marquardt step or of the line search, even if a convergence criterion was satisfied at the same iteration.

  2. Otherwise True if a convergence criterion was satisfied, even if max_iteration or max_time was reached at the same iteration.

  3. Otherwise False (stopped by max_iteration or max_time).

Type:

numpy.ndarray

stop_code#

Array of integers with shape (k,): the reasons why each problem stopped, encoded as a bit mask (same bits as SolveResult.stop_code, listed in the Notes section of pysolvegn.SolveResult; several criteria can be triggered at the same iteration). Use stopped_by() to test a criterion for all the problems, reasons() to get the text of a problem and the property message for a summary.

Type:

numpy.ndarray

n_iterations#

Array of integers with shape (k,): the number of iterations performed for each problem, i.e. the number of updates \(\Delta\mathbf{p}_{in,k}^{*}\) applied to its parameters (0 if the problem stopped at its initial parameters).

Type:

numpy.ndarray

cost#

The cost function value \(C_k\) of each problem at the returned parameters, with shape (k,). The cost of the successful problems is always available (computed at the end if no criterion, damping, callback, history or verbosity required it during the optimization). NaN for the problems whose cost is not available. None if no cost is available at all.

Type:

Optional[numpy.ndarray]

optimality#

The optimality norm(g_k, ord=numpy.inf) of each problem at the returned parameters, with shape (k,), where \(\mathbf{g}_k\) is the scaled second term. NaN for the problems whose terms were not evaluated at the returned parameters.

Type:

numpy.ndarray

term_parameters#

The parameters passed to the terms, \(\mathbf{p}_{out,k} = P(\mathbf{p}_{in,k})\), of each problem at the returned parameters, with shape (k, n_p_outputs) (equal to parameters if no parametrization is provided). NaN for the problems that did not start (NaN or Inf value in p0). None if no problem started.

Type:

Optional[numpy.ndarray]

elapsed_time#

The total time of the optimization in seconds.

Type:

float

n_rejected#

Array of integers with shape (k,): the total number of rejected trial steps (Levenberg-Marquardt or line search) of each problem (0 if damping is None and line_search is False).

Type:

numpy.ndarray

config#

The configuration requested to the solver: the stopping criteria ("max_iteration", "max_time", "ftol", "xtol", "gtol", "atol", "ptol", None if not used), "damping", "lm_conf" (the complete Levenberg-Marquardt configuration, default values included), "line_search" and "line_search_conf" (complete line search configuration).

Type:

Dict[str, Any]

__init__(parameters, history, success, stop_code, n_iterations, cost, optimality, term_parameters, elapsed_time, n_rejected, config)#
Parameters:
  • parameters (ndarray)

  • history (List[Dict])

  • success (ndarray)

  • stop_code (ndarray)

  • n_iterations (ndarray)

  • cost (ndarray | None)

  • optimality (ndarray)

  • term_parameters (ndarray | None)

  • elapsed_time (float)

  • n_rejected (ndarray)

  • config (Dict[str, Any])

Return type:

None

Methods

__init__(parameters, history, success, ...)

reasons(index)

The reasons why the problem index stopped, one string per triggered criterion, each starting with its tag (e.g. "[xtol] ...").

stopped_by(name)

Test, for each problem, whether a stopping criterion was triggered at its last iteration.

Attributes

message

the number of successful problems and the number of problems stopped by each criterion (one per line).

parameters

history

success

stop_code

n_iterations

cost

optimality

term_parameters

elapsed_time

n_rejected

config