30 #ifndef SHARK_ALGORITHMS_DIRECT_SEARCH_STEADYSTATEMOCMA 31 #define SHARK_ALGORITHMS_DIRECT_SEARCH_STEADYSTATEMOCMA 42 #include <boost/foreach.hpp> 53 template<
typename Indicator=HypervolumeIndicator>
63 std::vector< Individual > m_pop;
70 double m_individualSuccessThreshold;
71 double m_initialSigma;
75 m_individualSuccessThreshold = 0.44;
87 return "SteadyStateMOCMA";
90 std::size_t
mu()
const{
98 return m_initialSigma;
101 return m_initialSigma;
119 return m_notionOfSuccess;
122 return m_notionOfSuccess;
130 template<
typename Archive>
131 void serialize(Archive &archive,
const unsigned int version) {
132 archive & BOOST_SERIALIZATION_NVP(m_pop);
133 archive & BOOST_SERIALIZATION_NVP(m_mu);
134 archive & BOOST_SERIALIZATION_NVP(
m_best);
136 archive & BOOST_SERIALIZATION_NVP(m_evaluator);
137 archive & BOOST_SERIALIZATION_NVP(m_notionOfSuccess);
138 archive & BOOST_SERIALIZATION_NVP(m_individualSuccessThreshold);
139 archive & BOOST_SERIALIZATION_NVP(m_initialSigma);
151 std::vector<SearchPointType>
const& startingPoints
158 std::size_t noVariables =
function.numberOfVariables();
160 for(std::size_t i = 0; i !=
mu(); ++i){
161 m_pop[i] = Individual(noVariables,m_individualSuccessThreshold,m_initialSigma);
162 m_pop[i].searchPoint()=
function.proposeStartingPoint();
163 m_evaluator(
function, m_pop[i]);
164 m_best[i].point = m_pop[i].searchPoint();
165 m_best[i].value = m_pop[i].unpenalizedFitness();
167 m_selection(m_pop,m_mu);
168 m_pop.push_back(Individual(noVariables,m_individualSuccessThreshold,m_initialSigma));
179 std::size_t maxIdx = 0;
180 for (; maxIdx < m_pop.size(); maxIdx++) {
181 if (m_pop[maxIdx].rank() != 1)
185 Individual& parent = m_pop[Rng::discrete(0, std::max<std::size_t>(0, maxIdx-1))];
187 Individual& offspring = m_pop[
mu()];
190 m_evaluator(
function, offspring);
192 m_selection(m_pop,m_mu);
206 for(std::size_t i = 0; i !=
mu(); ++i){
207 if(!m_pop[i].selected()){
209 m_best[i].value = m_pop[
mu()].unpenalizedFitness();
210 swap(m_pop[i] , m_pop[
mu()]);
220 std::size_t start = 0;
221 std::size_t end =
mu()-1;
223 if(m_pop[start].rank() == 1){
225 }
else if(m_pop[end].rank() != 1){
228 swap(m_pop[start],m_pop[end]);