Logo Search packages:      
Sourcecode: quantlib version File versions


Go to the documentation of this file.
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

 Copyright (C) 2001, 2002, 2003 Nicolas Di Césaré

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@lists.sf.net>. The license is also available online at

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.

/*! \file problem.hpp
    \brief Abstract optimization class

#ifndef quantlib_optimization_problem_h
#define quantlib_optimization_problem_h

#include <ql/Optimization/method.hpp>

namespace QuantLib {

    //! Constrained optimization problem
00032     class Problem {
        //! default constructor
00035         Problem(CostFunction& f,// Function and it gradient vector
                Constraint& c,  // Constraint
                OptimizationMethod& meth)   // Optimization method
        : costFunction_(f), constraint_(c), method_(meth) {}

        //! call cost function computation and increment evaluation counter
        Real value(const Array& x) const;

        //! call cost function gradient computation and increment
        //  evaluation counter
        void gradient(Array& grad_f, const Array& x) const;

        //! call cost function computation and it gradient
        Real valueAndGradient(Array& grad_f, const Array& x) const;

        //! Constrained optimization method
00051         OptimizationMethod& method() const { return method_; }

        //! Constraint
00054         Constraint& constraint() const { return constraint_; }

        //! Cost function
00057         CostFunction& costFunction() const { return costFunction_; }

        //! Minimization
00060         void minimize() const { method_.minimize(*this); }

        Array& minimumValue() const { return method_.x (); }

        //! Unconstrained cost function
00066         CostFunction& costFunction_;
        //! Constraint
00068         Constraint& constraint_;
        //! constrained optimization method
00070         OptimizationMethod& method_;

    // inline definitions

00076     inline Real Problem::value(const Array& x) const {
        return costFunction_.value(x);

00081     inline void Problem::gradient(Array& grad_f, const Array& x) const {
        costFunction_.gradient(grad_f, x);

00086     inline Real Problem::valueAndGradient(Array& grad_f,
                                          const Array& x) const {
        return costFunction_.valueAndGradient(grad_f, x);



Generated by  Doxygen 1.6.0   Back to index