Using PSO with discrete variables

21 次查看(过去 30 天)
Rafael
Rafael 2023-5-29
回答: Aman 2023-7-26
I'm trying to use PSO to minimize my objective function. I PSO is trying to find the best solution in a continuous space, but I would like it to look for the solution in a discrete searchspace.
Example:
If my lb = [0 0], and ub=[100 100] (2 vars estimate), PSO looks for any solution in that space, returning values with 5 decimal places, I would like for the algorithm to search in that space, but looking in a discretized space with steps of 0.1, so it could only return values like [5.1 40.8], instead of [5.1413 40.8131].
I want to do this for two reasons, first, I think that discretizing the searchspace would reduce the computing time, and second, I want to associate a weight to each set of values x in my objective function, the weights are stored in a matrix and I have an weight for each value x with steps of 0.1. This does not work if the search space is continuous.
How I call the algorithm:
objectiveFunction = @(x) weightMatrix .* myFunc(x);
optimizedPosition = particleswarm(objectiveFunction, 2, lb, ub, options);
TLDR: I want to discretize the searchspace for PSO optimization.
  1 个评论
John D'Errico
John D'Errico 2023-5-29
Hammer on it as hard as you want, but a square peg just won't happily fit inside a round hole.
PSO is not an algorithm designed to solve a discrete problem.

请先登录,再进行评论。

回答(1 个)

Aman
Aman 2023-7-26
Hi,
I understand that you have an objective function whose minimal value you want to identify and are using PSO for that in a discrete search space instead of a continuous search space.
The PSO is an inappropriate choice to do so, as it is unable to deal with the discrete search space. As you want 0.1 to be your step size, as per your lower bound and upper bound, you have approximately 10^4 possible solutions, which is not a huge number, so it would be better if you did a complete search over the available search space to find the minimal value of your objective function.
Please refer to the following thread to learn more about it.
I hope it helps!

类别

Help CenterFile Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by