def rqpso_opt(D, pop_size, max_iter, pop_max, pop_min, fitness_function, alpha=None, beta=None, rec_step=50):
	
	swarm = RevisedQuantumParticleSwarm(D, pop_size, pop_max, pop_min)      # 种群初始化
	opt = Optimizer(max_iter, swarm, evaluator=fitness_function, rec_step=rec_step, is_record=True)            # 优化算法初始化
	if alpha and beta:
		opt.fit(alpha, beta)
	else:
		opt.fit()           # 优化求解

	AlgorithmVisual(opt.recoder, evaluator, pop_min_, pop_max_, is_save=True)             # 结果可视化
def qpso_opt(D, pop_size, max_iter, pop_max, pop_min, fitness_function, alpha=None, rec_step=50):
	
	swarm = QuantumParticleSwarm(D, pop_size, pop_max, pop_min)
	opt = Optimizer(max_iter, swarm, fitness_function, rec_step=rec_step, is_record=True)
	if alpha:
		opt.fit(alpha)
	else:
		opt.fit()

	AlgorithmVisual(opt.recoder, evaluator, pop_min_, pop_max_, is_save=True)
Ejemplo n.º 3
0
def particle_swarm_opt(D, pop_size, max_iter, pop_max, pop_min, V_max, V_min, fitness_function, weight=None):
	from swarm.particle import ParticleSwarm
	
	swarm = ParticleSwarm(D, pop_size, pop_max, pop_min, V_max, V_min)  # 种群初始化
	opt = Optimizer(max_iter, swarm, fitness_function)  # 优化器初始化
	if weight:
		opt.fit(weight)  # 优化迭代
	else:
		opt.fit()
		
	return opt.recoder
Ejemplo n.º 4
0
def revised_quantum_particle_opt(D, pop_size, max_iter, pop_max, pop_min, fitness_function, alpha=None, beta=None):
	from swarm.particle import RevisedQuantumParticleSwarm
	
	swarm = RevisedQuantumParticleSwarm(D, pop_size, pop_max, pop_min)
	opt = Optimizer(max_iter, swarm, evaluator=fitness_function)
	if alpha and beta:
		opt.fit(alpha, beta)
	else:
		opt.fit()
	
	return opt.recoder
Ejemplo n.º 5
0
def quantum_particle_swarm_opt(D, pop_size, max_iter, pop_max, pop_min, fitness_function, alpha=None):
	from swarm.particle import QuantumParticleSwarm
	
	swarm = QuantumParticleSwarm(D, pop_size, pop_max, pop_min)
	opt = Optimizer(max_iter, swarm, fitness_function)
	if alpha:
		opt.fit(alpha)
	else:
		opt.fit()
	
	return opt.recoder
def pso_opt(D, pop_size, max_iter, pop_max, pop_min, V_max, V_min, fitness_function, weight=None, rec_step=50):
	from swarm.particle import ParticleSwarm
	
	swarm = ParticleSwarm(D, pop_size, pop_max, pop_min, V_max, V_min)  # 种群初始化
	opt = Optimizer(max_iter, swarm, fitness_function, rec_step=rec_step, is_record=True)  # 优化器初始化
	if weight:
		opt.fit(weight)  # 优化迭代
	else:
		opt.fit()

	AlgorithmVisual(opt.recoder, evaluator, pop_min_, pop_max_, is_save=True)
Ejemplo n.º 7
0
def revised_quantum_particle_opt(D, pop_size, max_iter, pop_max, pop_min, fitness_function, alpha=None, beta=None):
	from swarm.particle import RevisedQuantumParticleSwarm
	
	swarm = RevisedQuantumParticleSwarm(D, pop_size, pop_max, pop_min)
	opt = Optimizer(max_iter, swarm, evaluator=fitness_function)
	if alpha and beta:
		opt.search(alpha, beta)
	else:
		opt.search()
	plt.figure(figsize=(5, 3))
	plt.loglog(range(max_iter), opt.yy)
	plt.title('RQPSO')
	plt.grid()
Ejemplo n.º 8
0
def quantum_particle_swarm_opt(D, pop_size, max_iter, pop_max, pop_min, fitness_function, alpha=None):
	from swarm.particle import QuantumParticleSwarm
	
	swarm = QuantumParticleSwarm(D, pop_size, pop_max, pop_min)
	opt = Optimizer(max_iter, swarm, fitness_function)
	if alpha:
		opt.search(alpha)
	else:
		opt.search()
	
	plt.figure(figsize=(5, 3))
	plt.loglog(range(max_iter), opt.yy)
	plt.title('QPSO')
	plt.grid()
Ejemplo n.º 9
0
def particle_swarm_opt(D, pop_size, max_iter, pop_max, pop_min, V_max, V_min, fitness_function, weight=None):
	from swarm.particle import ParticleSwarm
	
	swarm = ParticleSwarm(D, pop_size, pop_max, pop_min, V_max, V_min)      # 种群初始化
	opt = Optimizer(max_iter, swarm, fitness_function)                      # 优化器初始化
	if weight:
		opt.search(weight)      # 优化迭代
	else:
		opt.search()
	
	plt.figure(figsize=(5, 3))          # 结果可视化
	plt.loglog(range(max_iter), opt.yy)
	plt.title('PSO')
	plt.grid()
Ejemplo n.º 10
0
def rqpso_opt(D,
              pop_size,
              max_iter,
              pop_max,
              pop_min,
              fitness_function,
              alpha=None,
              beta=None):
    swarm = RevisedQuantumParticleSwarm(D, pop_size, pop_max, pop_min)
    opt = Optimizer(max_iter, swarm, evaluator=fitness_function)
    if alpha and beta:
        opt.fit(alpha, beta)
    else:
        opt.fit()
    plt.figure(figsize=(5, 3))
    plt.loglog(range(max_iter // opt.rec_step), opt.recoder.fitness)
    plt.title('RQPSO')
    plt.grid()
Ejemplo n.º 11
0
def pso_opt(D,
            pop_size,
            max_iter,
            pop_max,
            pop_min,
            V_max,
            V_min,
            fitness_function,
            weight=None):

    swarm = ParticleSwarm(D, pop_size, pop_max, pop_min, V_max, V_min)  # 种群初始化
    opt = Optimizer(max_iter, swarm, fitness_function)  # 优化器初始化
    if weight:
        opt.fit(weight)  # 优化迭代
    else:
        opt.fit()

    plt.figure(figsize=(5, 3))  # 结果可视化
    plt.loglog(range(max_iter // opt.rec_step), opt.recoder.fitness)
    plt.title('PSO')
    plt.grid()