1

I'm using Matlab's global optimization toolbox to optimize a cost function using PSO. Some of my input variables are involved in equality constraints and they must be integers. How can I define that in PSO?

I've tried to use a penalty function by adding this if statement in the cost function file,

 if(ceil(x(1))+duration~= ceil(x(2))|| x(1)>x(2))
  C=10000*C^2;
 end

x(1) is the starting time and x(2) is the ending time, the difference between the ending and starting time must be equal to the duration (initially defined). The time is supposed to be integer that's why I used ceil. Also, the starting time must be less than ending time (logically and as governed by the equation t_end-t_start=duration). when I run this,the output is non integer, and it doesn't satisfy the condition in the if statement, yet still the cost (C) is minimum. Am I missing something? or is there any alternative approach.

Thanks

Isra
  • 155
  • 1
  • 12

0 Answers0