Results

Results: oppy class of results

This module contains a results class which provides several possibilities for the different solvers.

In the results class all the output generated by the methods is stored. What exactly or how much should be stored you can control arbitrarily and set in the options. Here you usually already have three default settings and one very flexible:

  1. "sol" : the algorithm just returns the solution vector of the optimization problem:

    • xnumpy.ndarray, shape (n,)

      solution vector of the optimization problem

  2. "normal" : The algorithm returns the solution vector, the number of iterations and the list with the norm of the residuals

    • xnumpy.ndarray, shape (n,)

      solution vector of the optimization problem

    • iterationsfloat

      number of iterations the algorithm needed

    • reslist

      list with the norm of the residuals If setting is None, this is the default option.

  3. "all" : The algorithm returns all possible outputs, the returns are for example:

    • xnumpy.ndarray, shape (n,)

      solution vector of the problem

    • iterationsfloat

      number of iterations the algorithm needed

    • reslist

      list with the norm of the residuals

    • Xnumpy.ndarray, shape n x iterations

      matrix including all intermediate solution vectors

    • linesearchlist

      list including all step sizes the linesearch algorithm produced (not included for linear solvers)

    • additionallist

      a list including additional material, e.g. all options the user set

  4. list : a list of strings is passed and the algorithms returns all values contained in the list, e.g.

    • listlist

      where list = ["x", "res", "X", "iterations"]

This can deviate however occasionally with methods why you should consult if necessary always additionally the documentation of the respective method.

Documentation is available in the docstrings and online here.

oppy.results.results module

class oppy.results.Results(caller, setting=None)

Results for optimization algorithms and iterative solvers.

This class saves a result objects for all the unconstrained and constraint optimization methods, as well as for all iterative and stationary solvers and all other methods of the oppy package.

- x

solution vector of the optimization problem

Type: numpy.ndarray, shape (n,)
- iterations

number of iterations the algorithm needed

Type: float
- res

list with the norm of the residuals

Type: list
- X

matrix including all intermediate solution vectors

Type: numpy.ndarray, shape n x iterations
- linesearch

list including all step sizes the linesearch algorithm produced

Type: list
- additional

a list including additional material, e.g. all options the user set

Type: list

Note

The attributes differ from subpackage to subpackage and depend on the Results parameter of the Options class.

__init__(self, caller, setting=None)

Initialization function, to create an instance of the results class.

create_master_dict(self, setting=None)

Function to handle the first initialization for the master_dict. After initializing the master_dict, only the update_results method gets called.

update_results(self, update_dict)

Function to update the results dict. This method maps a dict containing information about the current iteration of the algorithm to the master dict of the results class.

finalize(self)

Function to improve the class before returning its dict. This includes deleting some internal results and casting some of the variables into their current type (e.g. X is returned as a huge matrix instead of a list). This method should be run in each method before returning the class.

__repr__(self)

Function which compute the “official” string representation.