00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <FlowShopOpMutationShift.h>
00014
00015
00016 std::string FlowShopOpMutationShift::className() const
00017 {
00018 return "FlowShopOpMutationShift";
00019 }
00020
00021
00022 bool FlowShopOpMutationShift::operator()(FlowShop & _flowshop)
00023 {
00024 bool isModified;
00025 int direction;
00026 unsigned int tmp;
00027 FlowShop result = _flowshop;
00028
00029 unsigned int point1, point2;
00030 do
00031 {
00032 point1 = rng.random(result.size());
00033 point2 = rng.random(result.size());
00034 } while (point1 == point2);
00035
00036 if (point1 < point2)
00037 direction = 1;
00038 else
00039 direction = -1;
00040
00041 tmp = result[point1];
00042 for (unsigned int i=point1 ; i!=point2 ; i+=direction)
00043 result[i] = result[i+direction];
00044 result[point2] = tmp;
00045
00046 if (result != _flowshop)
00047 {
00048
00049 _flowshop.value(result);
00050
00051 isModified = true;
00052 }
00053 else
00054 {
00055
00056 isModified = false;
00057 }
00058
00059 return isModified;
00060 }