필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
Matt Latourette
Matt Latourette 2022년 10월 27일
댓글: Rajeev 2022년 11월 2일
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