Discrete Particle Swarm optimization

조회 수: 2 (최근 30일)
hackel16
hackel16 2016년 11월 18일
답변: Shishir Reddy 2025년 5월 30일
Hello,
i am looking for a diskrete PSO, so that the function particleswarm is just inserting positive integer numbers.
Edit: nobody there to answer my question?
lb=[ 0 0 0 0 , 0 0 0 0 ];
ub=[inf 1000 inf 1000 , inf 1000 inf 1000 ];
fun = @(JPL) optimization1(JPL)
nvars=size(lb,2)
[x,fval,exitflag,output] = particleswarm(fun,nvars,lb,ub)

답변 (1개)

Shishir Reddy
Shishir Reddy 2025년 5월 30일
The built-in 'particleswarm' function in MATLAB is designed for continuous optimization, meaning it doesn't inherently support discrete or integer-only variables. However, the integer behaviour can be enforced within the objective function by rounding the input variables.
Here’s how you can modify your anonymous function to work with discrete (integer) values:
lb = [0 0 0 0, 0 0 0 0];
ub = [inf 1000 inf 1000, inf 1000 inf 1000];
nvars = numel(lb);
% Wrap the objective function to round inputs to nearest integers
fun = @(JPL) optimization1(round(abs(JPL)));
[x, fval, exitflag, output] = particleswarm(fun, nvars, lb, ub);
This workaround effectively treats the problem as a discrete one, though 'particleswarm' itself still works in continuous space as the actual particle positions are continuous, but the evaluation of the objective function uses the rounded values.
For more information regarding 'particleswarm' function, kindly refer the following documentation - https://www.mathworks.com/help/gads/particleswarm.html
I hope this workaround helps.

카테고리

Help CenterFile Exchange에서 Particle Swarm에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by