guofei9987 / scikit-opt

Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Optimization Algorithm,Immune Algorithm, Artificial Fish Swarm Algorithm, Differential Evolution and TSP(Traveling salesman)
https://scikit-opt.github.io/scikit-opt/#/en/
MIT License
5.27k stars 990 forks source link

Complex constraints in PSO #62

Open mchirsa5 opened 4 years ago

mchirsa5 commented 4 years ago

I have tried running the example in PSO with the constraints (defined in DE example). However,

constraint_eq = [lambda x: 1 - x[1] - x[2]] pso = PSO(func=obj_func, dim=2, pop=40, max_iter=100, lb=new_low_bound, ub=new_up_bound, constraint_eq=constraint_eq, w=0.8, c1=0.5, c2=0.5)

However, the is an error showing that TypeError: init() got an unexpected keyword argument 'constraint_eq'.

Could you please tell me how to add constraints in PSO?

guofei9987 commented 3 years ago

Nonlinear constraint is available now in version 0.6.1. demo: https://github.com/guofei9987/scikit-opt/blob/master/examples/demo_pso_ani.py enjoy!