MCPcopy Create free account
hub / github.com/Arash-codedev/openGA / eval_solution

Function eval_solution

examples/so-1/example_so1.cpp:40–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40bool eval_solution(
41 const MySolution& p,
42 MyMiddleCost &c)
43{
44 double x=p.x;
45 double y=p.y;
46 // see the surface plot at:
47 // https://academo.org/demos/3d-surface-plotter/?expression=x*x%2By*y%2B30.0*sin(x*100.0*sin(y)%2By*100.0*cos(x))%2B125%2B45.0*sqrt(x%2By)*sin((15.0*(x%2By))%2F(x*x%2By*y))&xRange=-10%2C%2B10&yRange=-10%2C%2B10&resolution=100
48 //
49 // the middle comupations of cost:
50 if(x+y>0)
51 {
52 double predictable_noise=30.0*sin(x*100.0*sin(y)+y*100.0*cos(x));
53 c.cost_distance2=x*x+y*y+predictable_noise;
54 c.cost_sqsin=125+45.0*sqrt(x+y)*sin((15.0*(x+y))/(x*x+y*y));
55 return true; // genes are accepted
56 }
57 else
58 return false; // genes are rejected
59}
60
61MySolution mutate(
62 const MySolution& X_base,

Callers 2

init_population_tryMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected