00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef MOEOOBJECTIVEVECTORTRAITS_H_
00014 #define MOEOOBJECTIVEVECTORTRAITS_H_
00015
00016 #include <iostream>
00017 #include <stdexcept>
00018 #include <vector>
00019
00023 class moeoObjectiveVectorTraits
00024 {
00025 public:
00026
00032 static void setup(unsigned int _nObjectives, std::vector < bool > & _bObjectives)
00033 {
00034
00035 if ( nObj && (nObj != _nObjectives) ) {
00036 std::cout << "WARNING\n";
00037 std::cout << "WARNING : the number of objectives are changing\n";
00038 std::cout << "WARNING : Make sure all existing objects are destroyed\n";
00039 std::cout << "WARNING\n";
00040 }
00041
00042 nObj = _nObjectives;
00043
00044 bObj = _bObjectives;
00045
00046 if (nObj != bObj.size())
00047 throw std::runtime_error("Number of objectives and min/max size don't match in moeoObjectiveVectorTraits::setup");
00048 }
00049
00050
00054 static unsigned int nObjectives()
00055 {
00056
00057 if (! nObj)
00058 throw std::runtime_error("Number of objectives not assigned in moeoObjectiveVectorTraits");
00059 return nObj;
00060 }
00061
00062
00067 static bool minimizing(unsigned int _i)
00068 {
00069
00070 if (_i >= bObj.size())
00071 throw std::runtime_error("Wrong index in moeoObjectiveVectorTraits");
00072 return bObj[_i];
00073 }
00074
00075
00080 static bool maximizing(unsigned int _i) {
00081 return (! minimizing(_i));
00082 }
00083
00084
00088 static double tolerance()
00089 {
00090 return 1e-6;
00091 }
00092
00093
00094 private:
00095
00097 static unsigned int nObj;
00099 static std::vector < bool > bObj;
00100
00101 };
00102
00103 #endif