Dear Dr. Balda,
I've been trying to implement your code to a calibration problem I have with many variables. 9 fixed and one more for each measurement. I believe it is for this reason that your function has not been giving me consistent results and I end up iterating more than 1000 times. I already defined the funtions I want to minimize(the residuals) but I would like to add a restriction to some of the variables. The restriction would be something like I don't want to allow the absolut value of some of the x's to be greater than 30. How would you go about that?

Dear Sam,
Thanks for powerful pso toolbox. I have an error after running the code with nonlinear constraint. The error message is:
" Problem is infeasible due to nonlinear constraints"
I have checked that my nonlinear constraints is passed with my initial population that I supplied. What could be the possible place that I can take a look to fix this problem.
Thanks
Parinya

Thanks for pointing that out, Aman.
b should really be a column vector [2;1] so that it will fit the equation
[1 0 ; 0 1]*[x1; x2] ≤ [2; 1]
however it looks like GA is robust enough to check for and correct that error.
I will add a small piece of input-checking code in the next release so that PSO will yield the same behavior as GA.

Sam,If PSO toolbox syntax same as GA toolbox so then I have found one a little bugs(but not with GA If using same syanx )for example: If I compare n run both GA n PSO syntax for two variable objective function.... pso(@(x)(x(1)^2+x(2)^2+x(1)),2,[1 0;0 1],[2 1]) showing "hozcat " and "psocheckinitialpopulation" error
...BUT ga(@(x)(x(1)^2+x(2)^2+x(1)),2,[1 0;0 1],[2 1]) result come out

Aman, I'm glad your problem is working properly now. Sorry for the inconvenience! Erik, you are very welcome; is it OK if I add your name to the list of acknowledgements for this toolbox?

Comment only