Constraining inputs to a maximum radius within fmincon objective function

2 ビュー (過去 30 日間)
Alec Jeffery
Alec Jeffery 2016 年 7 月 23 日
コメント済み: Matt J 2016 年 8 月 18 日
I am trying to optimize an objective function of a 5D circle
c=[1,2,3,2,1];
r=[0,0,0,0,0] % begin from origin
maxRadius=3;
fun = @(x) -sqrt(c.*(r+abs(x)).^2); % Negative to make minimal
% Such that:
sqrt(sum(x.^2)) <= maxRadius
I'm getting hung up on the constraint on x... Where can I plug this in to fmincon? is fmincon the appropriate solver for this?
  1 件のコメント
Matt J
Matt J 2016 年 8 月 18 日
Note, fmincon expects differentiable functions and constraints. Your 'fun' objective is non-differentiable in the vicinity of x=0 and of fun=0. Likewise with your constraints. You can mitigate this by removing the unnecessary square roots,
sum(x.^2) <= maxRadius.^2
and so forth.

サインインしてコメントする。

採用された回答

Alan Weiss
Alan Weiss 2016 年 7 月 25 日
See the documentation for nonlinear constraints and, if necessary, the Getting Started example showing how to include the constraint in a call to fmincon.
Alan Weiss
MATLAB mathematical toolbox documentation

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by