Why doesn't particleswarm accept integer types for the nvars argument?
4 次查看(过去 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
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 Center 和 File Exchange 中查找有关 Direct Search 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!