optimization.hpp
Go to the documentation of this file.
1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  Copyright (C) 2006, 2007 Ferdinando Ametrano
4 
5  This file is part of QuantLib, a free-software/open-source library
6  for financial quantitative analysts and developers - http://quantlib.org/
7 
8  QuantLib is free software: you can redistribute it and/or modify it
9  under the terms of the QuantLib license. You should have received a
10  copy of the license along with this program; if not, please email
11  <quantlib-dev@lists.sf.net>. The license is also available online at
12  <http://quantlib.org/license.shtml>.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the license for more details.
17 */
18 
19 
20 #ifndef qla_optimization_hpp
21 #define qla_optimization_hpp
22 
23 #include <oh/libraryobject.hpp>
24 
25 #include <ql/types.hpp>
26 
27 namespace QuantLib {
28  class EndCriteria;
29  class OptimizationMethod;
30  class LineSearch;
31  class Constraint;
32 }
33 
34 namespace QuantLibAddin {
35 
36  inline std::string qlSecondsToString(QuantLib::Real elapsed) {
37  QuantLib::Integer seconds = static_cast<QuantLib::Integer>(elapsed);
38  QuantLib::Integer hours = seconds/3600;
39  seconds -= hours * 3600;
40  QuantLib::Integer minutes = seconds/60;
41  seconds -= minutes * 60;
42  std::ostringstream out;
43  out << hours << ":" << minutes << ":" << seconds;
44  return out.str();
45  }
46 
47  class EndCriteria :
48  public ObjectHandler::LibraryObject<QuantLib::EndCriteria> {
49  public:
50  EndCriteria(const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
51  QuantLib::Size maxIterations,
52  QuantLib::Size maxStationaryStateIterations,
53  QuantLib::Real rootEpsilon,
54  QuantLib::Real functionEpsilon,
55  QuantLib::Real gradientNormEpsilon,
56  bool permanent);
57  };
58 
59  OH_LIB_CLASS(Constraint, QuantLib::Constraint);
60 
61  class NoConstraint : public Constraint {
62  public:
64  const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
65  bool permanent);
66 
67  };
68 
69  OH_LIB_CLASS(OptimizationMethod, QuantLib::OptimizationMethod);
70 
71  class Simplex : public OptimizationMethod {
72  public:
73  Simplex(
74  const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
75  QuantLib::Real lambda,
76  bool permanent);
77  };
78 
79  class LevenbergMarquardt : public OptimizationMethod {
80  public:
81  LevenbergMarquardt(const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
82  QuantLib::Real epsfcn,
83  QuantLib::Real xtol,
84  QuantLib::Real gtol,
85  bool permanent);
86  };
87 
88  OH_LIB_CLASS(LineSearch, QuantLib::LineSearch);
89 
90  class ArmijoLineSearch : public LineSearch {
91  public:
92  ArmijoLineSearch(const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
93  QuantLib::Real eps,
94  QuantLib::Real alpha,
95  QuantLib::Real beta,
96  bool permanent);
97  };
98 
99  OH_OBJ_CLASS(LineSearchBasedMethod, OptimizationMethod);
100 
101  class ConjugateGradient : public LineSearchBasedMethod {
102  public:
104  const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
105  const boost::shared_ptr<QuantLib::LineSearch>&,
106  bool permanent);
107  };
108 
109  class SteepestDescent : public LineSearchBasedMethod {
110  public:
112  const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
113  const boost::shared_ptr<QuantLib::LineSearch>&,
114  bool permanent);
115  };
116 
117 }
118 
119 #endif
Definition: optimization.hpp:47
Definition: optimization.hpp:79
SteepestDescent(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, const boost::shared_ptr< QuantLib::LineSearch > &, bool permanent)
EndCriteria(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, QuantLib::Size maxIterations, QuantLib::Size maxStationaryStateIterations, QuantLib::Real rootEpsilon, QuantLib::Real functionEpsilon, QuantLib::Real gradientNormEpsilon, bool permanent)
OH_LIB_CLASS(AlphaForm, QuantLib::AlphaForm)
Simplex(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, QuantLib::Real lambda, bool permanent)
Definition: optimization.hpp:90
Definition: optimization.hpp:109
LevenbergMarquardt(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, QuantLib::Real epsfcn, QuantLib::Real xtol, QuantLib::Real gtol, bool permanent)
OH_OBJ_CLASS(OneAssetOption, Instrument)
Definition: abcd.hpp:38
std::string qlSecondsToString(QuantLib::Real elapsed)
Definition: optimization.hpp:36
Definition: optimization.hpp:101
Definition: abcd.hpp:30
Definition: optimization.hpp:61
Definition: optimization.hpp:71
NoConstraint(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, bool permanent)
ConjugateGradient(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, const boost::shared_ptr< QuantLib::LineSearch > &, bool permanent)
ArmijoLineSearch(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, QuantLib::Real eps, QuantLib::Real alpha, QuantLib::Real beta, bool permanent)