1

I am working on a a spectra fitting program that uses Pyswarm's particle swarm optimization. The fitness function is simply an image similarity score between a base microwave spectrum and a spectrum made by each particle in the PSO. The parameters for the particles are the rotational constants A,B,C.

My issue is that I need A>B>C for each particle. Given the format that Pyswarm implements, how would I set up these parameter constraints?

Link to pyswarm site

1 Answer 1

2
pso(Function, lb, ub, ieqcons=[constraints], f_ieqcons=None, args=(),kwargs = argss, swarmsize=100, omega=0.5, phip=0.5, phig=0.5, maxiter=100, minstep=1e-8, minfunc=1e-8, debug=False)

Where you define constraints as:

def constraints(x):

return x[0] - x[1], x[1] - x[2] 

Your x[] has A, B, C in it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.