MOEAD.h
Go to the documentation of this file.
1//===========================================================================
2/*!
3 *
4 *
5 * \brief Implements the MOEA/D algorithm.
6 *
7 * \author Bjoern Bugge Grathwohl
8 * \date February 2017
9 *
10 * \par Copyright 1995-2017 Shark Development Team
11 *
12 * <BR><HR>
13 * This file is part of Shark.
14 * <https://shark-ml.github.io/Shark/>
15 *
16 * Shark is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Lesser General Public License as published
18 * by the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * Shark is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU Lesser General Public License for more details.
25 *
26 * You should have received a copy of the GNU Lesser General Public License
27 * along with Shark. If not, see <http://www.gnu.org/licenses/>.
28 *
29 */
30//===========================================================================
31
32#ifndef SHARK_ALGORITHMS_DIRECT_SEARCH_MOEAD
33#define SHARK_ALGORITHMS_DIRECT_SEARCH_MOEAD
34
41
42namespace shark {
43
44/// \brief Implements the MOEA/D algorithm.
45///
46/// Implementation of the MOEA/D algorithm from the following paper:
47/// Q. Zhang and H. Li, MOEA/D: a multi-objective evolutionary algorithm based
48/// on decomposition, IEEE Transactions on Evolutionary Computation, vol. 11,
49/// no. 6, pp. 712 - 731, 2007
50/// DOI: 10.1109/TEVC.2007.892759
51/// \ingroup multidirect
52class MOEAD : public AbstractMultiObjectiveOptimizer<RealVector>
53{
54public:
55 SHARK_EXPORT_SYMBOL MOEAD(random::rng_type & rng = random::globalRng);
56
57 std::string name() const{
58 return "MOEA/D";
59 }
60
61 double crossoverProbability() const{
62 return m_crossoverProbability;
63 }
64
66 return m_crossoverProbability;
67 }
68
69 double nm() const{
70 return m_mutation.m_nm;
71 }
72
73 double & nm(){
74 return m_mutation.m_nm;
75 }
76
77 double nc() const{
78 return m_crossover.m_nc;
79 }
80
81 double & nc(){
82 return m_crossover.m_nc;
83 }
84
85 std::size_t mu() const{
86 return m_mu;
87 }
88
89 std::size_t & mu(){
90 return m_mu;
91 }
92
93 /// \brief The number of points used for initialization of the algorithm.
94 std::size_t numInitPoints() const{
95 return m_mu;
96 }
97
98 std::size_t neighbourhoodSize() const{
99 return m_neighbourhoodSize;
100 }
101
102 std::size_t & neighbourhoodSize(){
103 return m_neighbourhoodSize;
104 }
105
106 template <typename Archive>
107 void serialize(Archive & archive)
108 {
109 archive & BOOST_SERIALIZATION_NVP(m_crossoverProbability);
110 archive & BOOST_SERIALIZATION_NVP(m_mu);
111 archive & BOOST_SERIALIZATION_NVP(m_parents);
112 archive & BOOST_SERIALIZATION_NVP(m_best);
113 archive & BOOST_SERIALIZATION_NVP(m_weights);
114 archive & BOOST_SERIALIZATION_NVP(m_neighbourhoods);
115 archive & BOOST_SERIALIZATION_NVP(m_neighbourhoodSize);
116 archive & BOOST_SERIALIZATION_NVP(m_bestDecomposedValues);
117 archive & BOOST_SERIALIZATION_NVP(m_crossover);
118 archive & BOOST_SERIALIZATION_NVP(m_mutation);
119 archive & BOOST_SERIALIZATION_NVP(m_curParentIndex);
120 }
121
122 using AbstractMultiObjectiveOptimizer<RealVector >::init;
124 ObjectiveFunctionType const& function,
125 std::vector<SearchPointType> const & initialSearchPoints
126 );
128protected:
131 std::vector<SearchPointType> const & initialSearchPoints,
132 std::vector<ResultType> const & functionValues,
133 RealVector const & lowerBounds,
134 RealVector const & upperBounds,
135 std::size_t const mu,
136 double const nm,
137 double const nc,
138 double const crossover_prob,
139 std::size_t const neighbourhoodSize,
140 std::vector<Preference> const & weightVectorPreferences = std::vector<Preference>()
141 );
142 // Make me an offspring...
143 SHARK_EXPORT_SYMBOL std::vector<IndividualType> generateOffspring() const;
144 SHARK_EXPORT_SYMBOL void updatePopulation(std::vector<IndividualType> const & offspringvec);
145
146 std::vector<IndividualType> m_parents;
147
148private:
149 random::rng_type * mpe_rng;
150 double m_crossoverProbability; ///< Probability of crossover happening.
151 std::size_t m_mu; ///< Size of parent population and the "N" from the paper
152
153 std::size_t m_curParentIndex;
154
155 /// \brief Number of neighbours for each candidate to consider.
156 ///
157 /// This is the "T" from the paper.
158 std::size_t m_neighbourhoodSize;
159 RealMatrix m_weights; ///< The weight vectors. These are all the lambdas from the paper
160
161 /// \brief Row n stores the indices of the T closest weight vectors.
162 ///
163 /// This is the "B" function from the paper.
164 UIntMatrix m_neighbourhoods;
165 RealVector m_bestDecomposedValues; ///< The "z" from the paper.
166
168 PolynomialMutator m_mutation;
169};
170
171
172} // namespace shark
173
174#endif // SHARK_ALGORITHMS_DIRECT_SEARCH_MOEAD