Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
differentialevolution_mt.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2012 Ralph Schreyer
5 Copyright (C) 2012 Mateusz Kapturski
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21/*
22 Copyright (C) 2016 Quaternion Risk Management Ltd.
23 All rights reserved.
24
25 This file is part of ORE, a free-software/open-source library
26 for transparent pricing and risk analysis - http://opensourcerisk.org
27
28 ORE is free software: you can redistribute it and/or modify it
29 under the terms of the Modified BSD License. You should have received a
30 copy of the license along with this program.
31 The license is also available online at <http://opensourcerisk.org>
32
33 This program is distributed on the basis that it will form a useful
34 contribution to risk analytics and model standardisation, but WITHOUT
35 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
36 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.*/
37
38/*! \file differentialevolution_mt.hpp
39 \brief Multithreaded version of QL class
40*/
41
42#pragma once
43
46
47#include <ql/math/optimization/constraint.hpp>
48#include <ql/math/optimization/differentialevolution.hpp>
49#include <ql/math/randomnumbers/mt19937uniformrng.hpp>
50
51namespace QuantExt {
52using namespace QuantLib;
53
55public:
56 using Strategy = DifferentialEvolution::Strategy;
57 using CrossoverType = DifferentialEvolution::CrossoverType;
58 using Candidate = DifferentialEvolution::Candidate;
59 using Configuration = DifferentialEvolution::Configuration;
60
63
64 virtual EndCriteria::Type minimize(Problem_MT& p, const EndCriteria& endCriteria) override;
65
66 const Configuration& configuration() const { return configuration_; }
67
68private:
69 void updateCost(std::vector<Candidate>& population, Problem_MT& p) const;
70
72 std::string maxTime_;
76 MersenneTwisterUniformRng rng_;
77
78 bool checkMaxTime() const;
79
80 void fillInitialPopulation(std::vector<Candidate>& population, const Problem_MT& p) const;
81
82 void getCrossoverMask(std::vector<Array>& crossoverMask, std::vector<Array>& invCrossoverMask,
83 const Array& mutationProbabilities) const;
84
85 Array getMutationProbabilities(const std::vector<Candidate>& population) const;
86
87 void adaptSizeWeights() const;
88
89 void adaptCrossover() const;
90
91 void calculateNextGeneration(std::vector<Candidate>& population, Problem_MT& p) const;
92
93 Array rotateArray(Array inputArray) const;
94
95 void crossover(const std::vector<Candidate>& oldPopulation, std::vector<Candidate>& population,
96 const std::vector<Candidate>& mutantPopulation, const std::vector<Candidate>& mirrorPopulation,
97 Problem_MT& p) const;
98};
99
100} // namespace QuantExt
DifferentialEvolution::Strategy Strategy
void crossover(const std::vector< Candidate > &oldPopulation, std::vector< Candidate > &population, const std::vector< Candidate > &mutantPopulation, const std::vector< Candidate > &mirrorPopulation, Problem_MT &p) const
const Configuration & configuration() const
void getCrossoverMask(std::vector< Array > &crossoverMask, std::vector< Array > &invCrossoverMask, const Array &mutationProbabilities) const
virtual EndCriteria::Type minimize(Problem_MT &p, const EndCriteria &endCriteria) override
minimize the optimization problem P
void calculateNextGeneration(std::vector< Candidate > &population, Problem_MT &p) const
Array getMutationProbabilities(const std::vector< Candidate > &population) const
DifferentialEvolution::Configuration Configuration
DifferentialEvolution::Candidate Candidate
DifferentialEvolution::CrossoverType CrossoverType
Array rotateArray(Array inputArray) const
void fillInitialPopulation(std::vector< Candidate > &population, const Problem_MT &p) const
DifferentialEvolution_MT(Configuration configuration=Configuration(), std::string maxTime="")
void updateCost(std::vector< Candidate > &population, Problem_MT &p) const
Abstract class for constrained optimization method.
Definition: method_mt.hpp:64
Constrained optimization problem.
Definition: problem_mt.hpp:64
Abstract multithreaded optimization method class.
Abstract optimization problem class (for multithreaded optimization methods)