37 using namespace shark;
40 struct PointExtractor{
42 RealVector
const& operator()(T
const& arg)
const{
46 template<
class Solution>
49 RealVector referencePoint(2,11);
52 auto toPoints = [](
typename Solution::const_reference point){
return point.value;};
57 int main(
int argc,
char ** argv ) {
59 std::size_t frontSize = 10;
60 std::size_t numDimensions = 10;
61 std::size_t numTrials = 10;
62 std::size_t recordingInterval = 20;
63 std::size_t numIterations = 20*recordingInterval;
66 typedef boost::shared_ptr<MultiObjectiveFunction> Function;
67 std::vector<Function > functions;
68 functions.push_back(Function(
new ZDT1(numDimensions)));
69 functions.push_back(Function(
new ZDT2(numDimensions)));
70 functions.push_back(Function(
new ZDT3(numDimensions)));
71 functions.push_back(Function(
new ZDT6(numDimensions)));
73 RealMatrix meanVolumes(functions.size(), numIterations/recordingInterval+1,0.0);
74 for(std::size_t f = 0; f != functions.size(); ++f){
75 for(std::size_t trial = 0; trial != numTrials; ++trial){
77 std::cout<<
"\r" <<functions[f]->name() <<
": "<<trial<<
"/"<<numTrials<<std::flush;
80 mocma.
mu() = frontSize;
82 mocma.
init( *functions[f] );
88 for(std::size_t i = 1; i <= numIterations; ++i){
89 mocma.
step(*functions[f]);
90 if(i % recordingInterval == 0){
96 meanVolumes /= numTrials;
98 std::cout<<
"\r# Iteration ";
99 for(std::size_t f = 0; f != functions.size(); ++f)
100 std::cout<<functions[f]->name()<<
" ";
103 std::cout.precision( 7 );
104 for(std::size_t i = 0; i != meanVolumes.size2();++i){
105 std::cout<< i*recordingInterval<<
" ";
106 for(std::size_t f = 0; f != functions.size(); ++f){
107 std::cout<<meanVolumes(f,i)<<
" ";