from xevo import erun, crossevo from bitflip import * from boolflip import * obj = bitflip() obj = boolflip() genetics = crossevo() #1120+-34 goalstrength = 10000.0 maxsteps = 1500 def statinf(q): return { "shape": np.array(q).shape, "mean": np.mean(q), "std": np.std(q), "max": np.max(q), "min": np.min(q), "stdm": np.std(q) / np.sqrt(len(q)) } def runone(show=True): counter.reset() global c c = erun(genetics.copy(), obj, show=show) c.run(goalstrength=goalstrength, maxsteps=maxsteps) return counter.i
def quickmut(obj, population=20, goal=0.0, maxsteps=1000, show=True): c = erun(crossevo(), obj, population=population, show=show) c.run(goalstrength=goal, maxsteps=maxsteps) return c.getwinner()
sigma = 0.03 x = [i / 10 for i in range(100)] y = [math.exp(3 * xx) + np.random.normal(0, sigma, 1)[0] for xx in x] # y=[3*xx+np.random.normal(0,sigma,1)[0] for xx in x] # obj=evofit(x=x,y=y,sigma=sigma,f=fmath.exp(fmath.variable("a")*fmath.variable("x"))) # obj=evofit(x=x,y=y,sigma=sigma,f=fmath.sin(fmath.tanh(fmath.variable("x")))) # print(obj) # print(obj.strength()) # exit() genetics = xevo.crossevo() obj = evofit(x=x, y=y, sigma=sigma) goalstrength = 100.0 maxsteps = 10000000 def runone(show=True): global c c = xevo.erun(genetics.copy(), obj, show=show, population=100, delay=0.001) c.run(goalstrength=goalstrength, maxsteps=maxsteps) runone() print(c.getwinner())