32 #ifndef SHARK_ALGORITHMS_DIRECT_SEARCH_MOCMA 33 #define SHARK_ALGORITHMS_DIRECT_SEARCH_MOCMA 46 #include <boost/foreach.hpp> 57 template<
typename Indicator=HypervolumeIndicator>
67 m_individualSuccessThreshold = 0.44;
81 std::size_t
mu()
const{
89 return m_initialSigma;
92 return m_initialSigma;
96 return m_notionOfSuccess;
99 return m_notionOfSuccess;
102 archive >> BOOST_SERIALIZATION_NVP(
m_parents);
103 archive >> BOOST_SERIALIZATION_NVP(m_mu);
104 archive >> BOOST_SERIALIZATION_NVP(
m_best);
106 archive >> BOOST_SERIALIZATION_NVP(m_selection);
107 archive >> BOOST_SERIALIZATION_NVP(m_notionOfSuccess);
108 archive >> BOOST_SERIALIZATION_NVP(m_individualSuccessThreshold);
109 archive >> BOOST_SERIALIZATION_NVP(m_initialSigma);
112 archive << BOOST_SERIALIZATION_NVP(
m_parents);
113 archive << BOOST_SERIALIZATION_NVP(m_mu);
114 archive << BOOST_SERIALIZATION_NVP(
m_best);
116 archive << BOOST_SERIALIZATION_NVP(m_selection);
117 archive << BOOST_SERIALIZATION_NVP(m_notionOfSuccess);
118 archive << BOOST_SERIALIZATION_NVP(m_individualSuccessThreshold);
119 archive << BOOST_SERIALIZATION_NVP(m_initialSigma);
124 if(!
function.canProposeStartingPoint())
125 throw SHARKEXCEPTION(
"Objective function does not propose a starting point");
126 std::vector<RealVector> points(
mu());
127 for(std::size_t i = 0; i !=
mu(); ++i){
128 points[i] =
function.proposeStartingPoint();
130 init(
function,points);
140 std::vector<SearchPointType>
const& initialSearchPoints
143 std::vector<RealVector> values(initialSearchPoints.size());
144 for(std::size_t i = 0; i != initialSearchPoints.size(); ++i){
145 if(!
function.isFeasible(initialSearchPoints[i]))
146 throw SHARKEXCEPTION(
"[MOCMA::init] starting point(s) not feasible");
147 values[i] =
function.eval(initialSearchPoints[i]);
160 penalizingEvaluator(
function, offspring.begin(), offspring.end() );
168 std::vector<SearchPointType>
const& initialSearchPoints,
169 std::vector<ResultType>
const& functionValues,
179 std::size_t noVariables = initialSearchPoints[0].size();
182 std::size_t numPoints = 0;
183 if(initialSearchPoints.size()<=
mu){
184 numPoints = initialSearchPoints.size();
185 for(std::size_t i = 0; i != numPoints; ++i){
187 m_parents[i].searchPoint() = initialSearchPoints[i];
188 m_parents[i].penalizedFitness() = functionValues[i];
189 m_parents[i].unpenalizedFitness() = functionValues[i];
193 for(std::size_t i = numPoints; i !=
mu; ++i){
194 std::size_t index =
discrete(*mpe_rng,0,initialSearchPoints.size()-1);
196 m_parents[i].searchPoint() = initialSearchPoints[index];
197 m_parents[i].penalizedFitness() = functionValues[index];
198 m_parents[i].unpenalizedFitness() = functionValues[index];
201 for(std::size_t i = 0; i !=
mu; ++i){
208 std::vector<IndividualType> offspring(
mu());
209 for(std::size_t i = 0; i !=
mu(); ++i){
210 std::size_t parentId = i;
212 offspring[i].mutate(*mpe_rng);
213 offspring[i].parent() = parentId;
223 for (std::size_t i = 0; i <
mu(); i++) {
236 m_parents[i].updateAsParent(offspringSuccess);
244 for (std::size_t i = 0; i <
mu(); i++) {
258 double m_individualSuccessThreshold;
259 double m_initialSigma;