Why doesn't particleswarm accept integer types for the nvars argument?

5 次查看(过去 30 天)
This is less of a true "question" and more of a product improvement suggestion for MATLAB. The particleswarm function is just one example of this phenomenon. There are other examples of this kind of behavior in MATLAB toolbox functions.
The nvars argument for the particleswarm function is described in the documentation as, "Number of variables, specified as a positive integer." It's intrinsically an integer value. It's not possible to have a non-integer number of variables for the function to be optimized by particleswarm. Why, then, does the particleswarm function only accept this input as a double type? I have the number of parameters stored as a uint8 in the class that represents my model, as that was a sensible representation for it. Sure, I can just typecast to double whenever I call the optimizer, but it violates the Principle of Least Astonishment to have a function that takes an argument that is intrinsically an integer but then only accept that argument in floating point format.
  1 个评论
Rajeev
Rajeev 2022-11-2
Hi Matt,
Thank you for the suggestion. I have notified my colleagues about this suggestion and they will look into it. I will inform you about it as soon as I get an update.
Thanks,
Rajeev
Associate in Engineering Development Group

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by