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

6 Ansichten (letzte 30 Tage)
Matt Latourette
Matt Latourette am 27 Okt. 2022
Kommentiert: Rajeev am 2 Nov. 2022
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 Kommentar
Rajeev
Rajeev am 2 Nov. 2022
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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by