예제 #1
0
def draw_contour():
    import pylab, numpy
    x, y = numpy.mgrid[-1:2:0.02,-0.5:2:0.02]
    c = 0*x
    s,t = x.shape
    for i in range(s):
       for j in range(t):
          xx,yy = x[i,j], y[i,j]
          c[i,j] = fOsc3D([xx,yy])
    pylab.contourf(x,y,c,100)
예제 #2
0
def draw_contour():
    import pylab, numpy
    x, y = numpy.mgrid[-1:2:0.02, -0.5:2:0.02]
    c = 0 * x
    s, t = x.shape
    for i in range(s):
        for j in range(t):
            xx, yy = x[i, j], y[i, j]
            c[i, j] = fOsc3D([xx, yy])
    pylab.contourf(x, y, c, 100)
예제 #3
0
def draw_contour():
    import matplotlib.pyplot as plt, numpy
    x, y = numpy.mgrid[-1:2:0.02, -0.5:2:0.02]
    c = 0 * x
    s, t = x.shape
    for i in range(s):
        for j in range(t):
            xx, yy = x[i, j], y[i, j]
            c[i, j] = fOsc3D([xx, yy])
    plt.contourf(x, y, c, 100)
예제 #4
0
def draw_contour():
    import matplotlib.pyplot as plt, numpy
    x, y = numpy.mgrid[-1:2:0.02,-0.5:2:0.02]
    c = 0*x
    s,t = x.shape
    for i in range(s):
       for j in range(t):
          xx,yy = x[i,j], y[i,j]
          c[i,j] = fOsc3D([xx,yy])
    plt.contourf(x,y,c,100)
예제 #5
0
    solver.Solve(fOsc3D,termination=ChangeOverGeneration(1e-5, 30), \
                 strategy=strategy,CrossProbability=1.0,ScalingFactor=0.9)

    return solver.Solution()


if __name__ == '__main__':
    import pylab
    from mystic.solvers import fmin
    #from mystic._scipyoptimize import fmin
    draw_contour()
    solution = main()
    print("solution: %s" % solution)
    pylab.plot([solution[0]], [solution[1]], 'wo', markersize=10)
    print("Differential Evolution: Min: %s, sol = %s" %
          (fOsc3D(solution), solution))

    print("\nTrying scipy.optimize.fmin (Nelder-Mead Simplex)...")

    m = fmin(fOsc3D, [0.1, 0.1])
    pylab.plot([m[0]], [m[1]], 'ro', markersize=5)
    print("solution w/ initial conditions (0.1,0.1): %s\n" % m)

    m = fmin(fOsc3D, [1, 1])
    pylab.plot([m[0]], [m[1]], 'ro', markersize=5)
    print("solution w/ initial conditions (1,1): %s\n" % m)

    m = fmin(fOsc3D, [-1, 1])
    print("solution w/ initial conditions (-1,1): %s\n" % m)
    pylab.plot([m[0]], [m[1]], 'ro', markersize=5)
예제 #6
0
    solver.Solve(fOsc3D,termination=ChangeOverGeneration(1e-5, 30), \
                 strategy=strategy,CrossProbability=1.0,ScalingFactor=0.9)

    return solver.Solution()
  


if __name__ == '__main__':
    import pylab
    from mystic.solvers import fmin
   #from mystic._scipyoptimize import fmin
    draw_contour()
    solution = main()
    print "solution: ", solution
    pylab.plot([solution[0]],[solution[1]],'wo',markersize=10)
    print "Differential Evolution: Min: %s, sol = %s" % (fOsc3D(solution), solution)

    print "\nTrying scipy.optimize.fmin (Nelder-Mead Simplex)..."

    m = fmin(fOsc3D, [0.1, 0.1])
    pylab.plot([m[0]],[m[1]],'ro',markersize=5)
    print "solution w/ initial conditions (0.1,0.1): %s\n" % m

    m = fmin(fOsc3D, [1, 1])
    pylab.plot([m[0]],[m[1]],'ro',markersize=5)
    print "solution w/ initial conditions (1,1): %s\n" % m

    m = fmin(fOsc3D, [-1, 1])
    print "solution w/ initial conditions (-1,1): %s\n" % m
    pylab.plot([m[0]],[m[1]],'ro',markersize=5)
예제 #7
0
    solver.Solve(fOsc3D,termination=ChangeOverGeneration(1e-5, 30), \
                 strategy=strategy,CrossProbability=1.0,ScalingFactor=0.9)

    return solver.Solution()


if __name__ == '__main__':
    import pylab
    from mystic.solvers import fmin
    #from mystic._scipyoptimize import fmin
    draw_contour()
    solution = main()
    print "solution: ", solution
    pylab.plot([solution[0]], [solution[1]], 'wo', markersize=10)
    print "Differential Evolution: Min: %s, sol = %s" % (fOsc3D(solution),
                                                         solution)

    print "\nTrying scipy.optimize.fmin (Nelder-Mead Simplex)..."

    m = fmin(fOsc3D, [0.1, 0.1])
    pylab.plot([m[0]], [m[1]], 'ro', markersize=5)
    print "solution w/ initial conditions (0.1,0.1): %s\n" % m

    m = fmin(fOsc3D, [1, 1])
    pylab.plot([m[0]], [m[1]], 'ro', markersize=5)
    print "solution w/ initial conditions (1,1): %s\n" % m

    m = fmin(fOsc3D, [-1, 1])
    print "solution w/ initial conditions (-1,1): %s\n" % m
    pylab.plot([m[0]], [m[1]], 'ro', markersize=5)