Is There Any Single-Precision Optimization Code?
2 ビュー (過去 30 日間)
古いコメントを表示
I wish to optimize the nonlinear constrained function with the single precision (not double precision that is default of the Matlab)
However, because the 'fmincon' supports only the double precision,
I wish to use any matlab optimization code which supports the single precision.
2 件のコメント
John D'Errico
2021 年 11 月 24 日
Is there a good reason why you think you need to use only single precision? If your problem is that large, then restricting it to work in single precision is arguably a bad idea anyway.
採用された回答
Song-Hyun Ji
2021 年 11 月 29 日
For Code Generation in fmincon, the target hardware must support standard double-precision floating-point computations. You cannot generate code for single-precision or fixed-point computations. Please see the content at the following documentation.
https://www.mathworks.com/help/optim/ug/code-generation-in-fmincon.html
0 件のコメント
その他の回答 (1 件)
Andy Bartlett
2021 年 12 月 6 日
編集済み: Andy Bartlett
2021 年 12 月 6 日
I'm not sure if there is support for single-precision simulation and code generation of the kind of standalone optimization solvers you are seeking. But there are some optimization solvers embedded inside some other modeling elements that do support single precision simulation and code generation. I don't know if these fit your higher level need, but investigating these MAY lead your efforts in a useful direction.
Model Predictive Control Toolbox provides modeling elements for controls that can be used with double precision or single precision floating-point. Model Predictive Controllers use optimization solvers to determine the plant inputs in real-time.
Using the model from this documented example, the controller can be changed to use single precision and put in its own reference model (R2021a version attached).
This simulates in single precision and still provides the desired closed loop system behavior. The generated code uses only single precision and no double precision. The generated code would be suitable for a embedded controller like a Cortex M4F that has hardware for floating-point singles, but can only support doubles via big and slow software emulation libraries.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with Optimization Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!