class cv::MinProblemSolver

Overview

Basic interface for all solvers. Moreā€¦

#include <optim.hpp>

class MinProblemSolver: public cv::Algorithm
{
public:
    // classes

    class Function;

    // methods

    virtual
    Ptr<Function>
    getFunction() const = 0;

    virtual
    TermCriteria
    getTermCriteria() const = 0;

    virtual
    double
    minimize(InputOutputArray x) = 0;

    virtual
    void
    setFunction(const Ptr<Function>& f) = 0;

    virtual
    void
    setTermCriteria(const TermCriteria& termcrit) = 0;
};

// direct descendants

class ConjGradSolver;
class DownhillSolver;

Inherited Members

public:
    // methods

    virtual
    void
    clear();

    virtual
    bool
    empty() const;

    virtual
    String
    getDefaultName() const;

    virtual
    void
    read(const FileNode& fn);

    virtual
    void
    save(const String& filename) const;

    virtual
    void
    write(FileStorage& fs) const;

    template <typename _Tp>
    static
    Ptr<_Tp>
    load(
        const String& filename,
        const String& objname = String()
        );

    template <typename _Tp>
    static
    Ptr<_Tp>
    loadFromString(
        const String& strModel,
        const String& objname = String()
        );

    template <typename _Tp>
    static
    Ptr<_Tp>
    read(const FileNode& fn);

protected:
    // methods

    void
    writeFormat(FileStorage& fs) const;

Detailed Documentation

Basic interface for all solvers.

Methods

virtual
Ptr<Function>
getFunction() const = 0

Getter for the optimized function.

The optimized function is represented by Function interface, which requires derivatives to implement the calc(double*) and getDim() methods to evaluate the function.

Returns:

Smart-pointer to an object that implements Function interface - it represents the function that is being optimized. It can be empty, if no function was given so far.

virtual
TermCriteria
getTermCriteria() const = 0

Getter for the previously set terminal criteria for this algorithm.

Returns:

Deep copy of the terminal criteria used at the moment.

virtual
double
minimize(InputOutputArray x) = 0

actually runs the algorithm and performs the minimization.

The sole input parameter determines the centroid of the starting simplex (roughly, it tells where to start), all the others (terminal criteria, initial step, function to be minimized) are supposed to be set via the setters before the call to this method or the default values (not always sensible) will be used.

Parameters:

x The initial point, that will become a centroid of an initial simplex. After the algorithm will terminate, it will be setted to the point where the algorithm stops, the point of possible minimum.

Returns:

The value of a function at the point found.

virtual
void
setFunction(const Ptr<Function>& f) = 0

Setter for the optimized function.

It should be called at least once before the call to* minimize(), as default value is not usable.

Parameters:

f The new function to optimize.
virtual
void
setTermCriteria(const TermCriteria& termcrit) = 0

Set terminal criteria for solver.

This method is not necessary to be called before the first call to minimize(), as the default value is sensible.

Algorithm stops when the number of function evaluations done exceeds termcrit.maxCount, when the function values at the vertices of simplex are within termcrit.epsilon range or simplex becomes so small that it can enclosed in a box with termcrit.epsilon sides, whatever comes first.

Parameters:

termcrit Terminal criteria to be used, represented as cv::TermCriteria structure.