Example #1
0
solver.enable_signal_handler()
solver.SetRandomInitialPoints(min=minrange,max=maxrange)
solver.SetEvaluationLimits(generations=MAX_GENERATIONS)
solver.Solve(cost, termination=ChangeOverGeneration(generations=100))


if __name__ == '__main__':     

    # x0, y0, R0
    #guess = [1,1,1] # bad initial guess
    #guess = [5,5,1] # ok guess
    guess = [10,15,5] # good initial guess

    # plot training set & training set boundary
    pylab.plot(xy[:,0],xy[:,1],'k+',markersize=6)
    c = circle(x0, y0, R0)
    pylab.plot(c[:,0],c[:,1],'r-',linewidth=2)
    legend = ['random points','generating circle : %f' % R0]
    pylab.axis('equal')

    # solve with mystic's differential evolution solver
    solution = solver.Solution()
    sx, sy, sr = solution
    print("DEsol : (%f, %f) @ R = %f" % (sx, sy, sr))

    # plot DEsolver solution
    c = circle(sx, sy, sr)
    pylab.plot(c[:,0],c[:,1],'b-',linewidth=2)
    legend.append('DE optimal : %f' % sr)

    # solve with scipy.fmin
Example #2
0
solver.enable_signal_handler()
solver.SetRandomInitialPoints(min=minrange,max=maxrange)
solver.SetEvaluationLimits(generations=MAX_GENERATIONS)
solver.Solve(cost, termination=ChangeOverGeneration(generations=100))


if __name__ == '__main__':     

    # x0, y0, R0
    #guess = [1,1,1] # bad initial guess
    #guess = [5,5,1] # ok guess
    guess = [10,15,5] # good initial guess

    # plot training set & training set boundary
    pylab.plot(xy[:,0],xy[:,1],'k+',markersize=6)
    c = circle(x0, y0, R0)
    pylab.plot(c[:,0],c[:,1],'r-',linewidth=2)
    legend = ['random points','generating circle : %f' % R0]
    pylab.axis('equal')

    # solve with mystic's differential evolution solver
    solution = solver.Solution()
    sx, sy, sr = solution
    print("DEsol : (%f, %f) @ R = %f" % (sx, sy, sr))

    # plot DEsolver solution
    c = circle(sx, sy, sr)
    pylab.plot(c[:,0],c[:,1],'b-',linewidth=2)
    legend.append('DE optimal : %f' % sr)

    # solve with scipy.fmin