import SwarmPackagePy from SwarmPackagePy import testFunctions as tf from SwarmPackagePy import animation, animation3D alh = SwarmPackagePy.abfo1(100, tf.easom_function, -10, 10, 2, 20, 16, 4, 2, 12, 0.1, 0.25, 400) animation(alh.get_agents(), tf.easom_function, -10, 10) animation3D(alh.get_agents(), tf.easom_function, -10, 10) #SwarmPackagePy.bfo(n, function, lb, ub, dimension, iteration, Nc, Ns, C, Ped)
print('Optimum Allocation : ', revf.OptAlloc) #print('Max Revenue : ',revf.OptAlloc) fits = alh._get_jfits() plt.plot(fits, 'b', label='J-fit') jcclist = alh._get_jcclist() plt.plot(jcclist, 'r', label='J-cc') jarlist = alh._get_jarlist() plt.plot(jarlist, 'g', label='J-ar') jlist = alh._get_jlist() plt.plot(jlist, 'y', label='J') jblist = alh._get_jblist() plt.plot(jblist, 'p', label='J-best') plt.legend() plt.show() # plt.pause(0.001) # plt.subplot(2, 1, 2) steps = alh._get_csteps() # print(steps) plt.plot(steps) plt.show() animation(alh.get_agents(), f, 0, r, dim) animation3D(alh.get_agents(), f, 0, r, dim)
#animation3D(alh.get_agents(), tf.easom_function, -10, 10) #alh = SwarmPackagePy.abfoa2(20, tf.gaussian_function, -10, 10, 2, 20, 16, 4, 2, 12, 0.9, 0.25, 0.1) #animation(alh.get_agents(), tf.gaussian_function, -10, 10) #animation3D(alh.get_agents(), tf.gaussian_function, -10, 10) alh = SwarmPackagePy.abfoa2(100, tf.thriple_gaussian_function_positive, -10, 10, 50, 20, 16, 4, 2, 12, 0.9, 0.25, 1) steps = alh._get_csteps() print(steps) plt.plot(steps) plt.ylabel('Step Size') #plt.show() jlist = alh._get_jlist() print(jlist) #plt.plot(jlist,'r') plt.show() animation(alh.get_agents(), tf.thriple_gaussian_function_positive, -10, 10) animation3D(alh.get_agents(), tf.thriple_gaussian_function_positive, -10, 10) """ alh = SwarmPackagePy.abfoa2(100, tf.thriple_wide_gaussian_function, -50, 50, 2, 20, 16, 4, 2, 12, 0.9, 0.25, 0.1) animation(alh.get_agents(), tf.thriple_wide_gaussian_function, -50, 50) animation3D(alh.get_agents(), tf.thriple_wide_gaussian_function, -50, 50) """ #SwarmPackagePy.bfo(n, function, lb, ub, dimension, iteration, Nc, Ns, C, Ped)
from SwarmPackagePy import testFunctions as tf from SwarmPackagePy import animation, animation3D eval_function = [ tf.ackley_function, ] """ tf.ackley_function, tf.bukin_function, tf.cross_in_tray_function, tf.sphere_function, tf.bohachevsky_function, tf.sum_squares_function, tf.sum_of_different_powers_function, tf.booth_function, tf.matyas_function, tf.mccormick_function, tf.dixon_price_function, tf.six_hump_camel_function, tf.three_hump_camel_function, tf.easom_function, tf.michalewicz_function, tf.beale_function, tf.drop_wave_function ] """ for func in eval_function: alh = SwarmPackagePy.aba(50, func, -10, 10, 2, 20) animation(alh.get_agents(), func, -10, 10) animation3D(alh.get_agents(), func, -10, 10)
import SwarmPackagePy from SwarmPackagePy import testFunctions as tf from SwarmPackagePy import animation, animation3D #alh = SwarmPackagePy.pso(50, tf.easom_function, -10, 10, 2, 20,w=0.5, c1=1, c2=1) #alh = SwarmPackagePy.bfo(n, function, lb, ub, dimension, iteration, Nc, Ns, C, Ped) #alh = SwarmPackagePy.bfo_with_swarm(20, tf.easom_function, -30, 30, 2, 10, 2, 12, 0.2, 1.15, 0.1, 0.2, 0.1, 10) alh = SwarmPackagePy.bfo_with_env_swarm(50, tf.easom_function, -30, 30, 3, 30, 100, 4, 0.1, 0.25, 0.1, 0.2, 0.1, 10, 0) animation3D(alh.get_agents(), tf.easom_function, -50, 50) animation3D(alh.get_agents(), tf.easom_function, -50, 50) #SwarmPackagePy.bfo(n, function, lb, ub, dimension, iteration, Nc, Ns, C, Ped)
import SwarmPackagePy from SwarmPackagePy import testFunctions as tf from SwarmPackagePy import animation, animation3D #alh = SwarmPackagePy.pso(50, tf.easom_function, -10, 10, 2, 20,w=0.5, c1=1, c2=1) #alh = SwarmPackagePy.bfo(n, function, lb, ub, dimension, iteration, Nc, Ns, C, Ped) #alh = SwarmPackagePy.bfo_with_swarm(20, tf.easom_function, -30, 30, 2, 10, 2, 12, 0.2, 1.15, 0.1, 0.2, 0.1, 10) alh = SwarmPackagePy.bfo_with_env_swarm(50, tf.sphere_function, -30, 30, 3, 30, 100, 4, 0.1, 0.25, 0.1, 0.2, 0.1, 10, 0) animation(alh.get_agents(), tf.sphere_function, -50, 50) animation3D(alh.get_agents(), tf.sphere_function, -50, 50) #SwarmPackagePy.bfo(n, function, lb, ub, dimension, iteration, Nc, Ns, C, Ped)
jarlist = alh._get_jarlist() jlist = alh._get_jlist() plt.plot(jlist, 'y', label='J') jblist = alh._get_jblist() plt.plot(jblist, 'g', label='J-best') plt.legend() plt.show() #plt.pause(0.001) #plt.subplot(2, 1, 2) steps = alh._get_csteps() #print(steps) plt.plot(steps) plt.show() animation(alh.get_agents(), f, -r, r) animation3D(alh.get_agents(), f, -r, r) """" alh = SwarmPackagePy.bfoa_swarm1(50, tf.f1_sphere_function, -10, 10, 2, 100, 16, 4, 2, 12, 0.1, 0.25, 0.1, 0.2, 0.1, 10,400 ) animation(alh.get_agents(), tf.f1_sphere_function, -10, 10) animation3D(alh.get_agents(), tf.f1_sphere_function, -10, 10) """ """ alh = SwarmPackagePy.bfoa_swarm1(100, tf.f1_sphere_function, -32, 32, 30, 100, 24, 8, 8, 12, 0.1, 0.25, 0.1, 0.2, 0.1, 10,400 ) animation(alh.get_agents(), tf.f1_sphere_function, -32, 32) animation3D(alh.get_agents(), tf.f1_sphere_function, -32, 32) """
while chooseFunction != 4: if chooseFunction == 1: print("=== Three-hump camel function ===") alh = SwarmPackagePy.pso(50, tf.three_hump_camel_function, -5, 5, 20, 100, w=0.5, c1=1, c2=1) print(alh.get_Gbest()) animation3D(alh.get_agents(), tf.three_hump_camel_function, -5, 5) elif chooseFunction == 2: print("=== Booth function ===") alh = SwarmPackagePy.pso(50, tf.booth_function, -10, 10, 20, 100, w=0.5, c1=1, c2=1) print(alh.get_Gbest()) animation3D(alh.get_agents(), tf.booth_function, -10, 10)
#plt.show() steps = alh._get_csteps() #print('steps') #print(steps) #plt.plot(steps,'g', label='J-ar') #plt.show() jlist = alh._get_jlist() #print('jlist') #print(jlist) plt.plot(jlist,'y', label='J') #plt.show() jblist = alh._get_jblist() #print(jblist) plt.plot(jblist,'g', label='J-Best') plt.legend() plt.show() steps = alh._get_csteps() #print(steps) plt.plot(steps) plt.show() animation(alh.get_agents(), tf.f3_ackley_function, -32, 32) animation3D(alh.get_agents(), tf.f3_ackley_function, -32, 32) #SwarmPackagePy.bfo(n, function, lb, ub, dimension, iteration, Nc, Ns, C, Ped)
import SwarmPackagePy as sw from SwarmPackagePy import testFunctions as tf from SwarmPackagePy import animation, animation3D import numpy as np sw._version_ swarm_strength = np.random.random_integers(25, 55) print("Swarm strength =", swarm_strength) firefly = sw.fa(n=swarm_strength, function=tf.sum_squares_function, lb=-10, ub=10, dimension=2, psi=2, iteration=50) animation(firefly.get_agents(), tf.sum_squares_function, -10, 10) animation3D(firefly.get_agents(), tf.sum_squares_function, -10, 10)
import SwarmPackagePy from SwarmPackagePy import testFunctions as tf from SwarmPackagePy import animation, animation3D alh = SwarmPackagePy.swarm(50, tf.ackley_function, -5, 5, 3, 30) animation(alh.get_agents(), tf.ackley_function, -5, 5) animation3D(alh.get_agents(), tf.ackley_function, -5, 5)
import SwarmPackagePy from SwarmPackagePy import testFunctions as tf from SwarmPackagePy import animation, animation3D # alh = SwarmPackagePy.bfoa(100, tf.easom_function, -10, 10, 2, 20, 16, 4, 2, 12, 0.1, 0.25, 400 ) # animation(alh.get_agents(), tf.easom_function, -10, 10) # animation3D(alh.get_agents(), tf.easom_function, -10, 10) #alh = SwarmPackagePy.bfoa(100, tf.easom_function, -10, 10, 50, 100, 16, 4, 2, 12, 0.1, 0.25, 400 ) #animation(alh.get_agents(), tf.easom_function, -20, 20) #animation3D(alh.get_agents(), tf.easom_function, -20, 20) #alh = SwarmPackagePy.bfoa(100, tf.multiple_gaussian_function, -20, 20, 50, 100, 16, 4, 2, 12, 0.1, 0.25, 400 ) #animation(alh.get_agents(), tf.multiple_gaussian_function, -20, 20) #animation3D(alh.get_agents(), tf.multiple_gaussian_function, -20, 20) alh = SwarmPackagePy.bfoa(100, tf.thriple_gaussian_function_codegen, -10, 10, 50, 100, 16, 4, 2, 12, 0.1, 0.25, 400) animation(alh.get_agents(), tf.thriple_gaussian_function_codegen, -10, 10) animation3D(alh.get_agents(), tf.thriple_gaussian_function_codegen, -10, 10) #SwarmPackagePy.bfo(n, function, lb, ub, dimension, iteration, Nc, Ns, C, Ped)