| 80 | } |
| 81 | |
| 82 | MySolution mutate( |
| 83 | const MySolution& X_base, |
| 84 | const std::function<double(void)> &rnd01, |
| 85 | double shrink_scale) |
| 86 | { |
| 87 | MySolution X_new; |
| 88 | bool in_range_x,in_range_y; |
| 89 | const double mu=0.2*shrink_scale; // mutation radius |
| 90 | do{ |
| 91 | X_new=X_base; |
| 92 | X_new.x+=mu*(rnd01()-rnd01()); |
| 93 | X_new.y+=mu*(rnd01()-rnd01()); |
| 94 | in_range_x= (X_new.x>=-10.0 && X_new.x<10.0); |
| 95 | in_range_y= (X_new.y>=-10.0 && X_new.y<10.0); |
| 96 | } while(!in_range_x || !in_range_y); |
| 97 | return X_new; |
| 98 | } |
| 99 | |
| 100 | MySolution crossover( |
| 101 | const MySolution& X1, |
nothing calls this directly
no outgoing calls
no test coverage detected