フィルターのクリア

Check if function handle is nonlinear with Matlab

2 ビュー (過去 30 日間)
Daniela Würmseer
Daniela Würmseer 2022 年 4 月 2 日
コメント済み: Torsten 2022 年 4 月 3 日
Hello,
is it possible to check with matlab if a Function Handle is nonlinear?
For example:
f1=@(x) x(1)+x(2)-5;
f2=@(x)10*x(1)-x(1)^2+4*x(2)-x(2)^2;
So here i would need something which tells me that f1 is linear and f2 is nonlinear. Thanks
  1 件のコメント
Paul
Paul 2022 年 4 月 2 日
The first function is linear in x, I suppose, but is not linear from a system theoretric perspective, as it doesn't satisfy superposition or scaling. Just want to make sure we're clear on the definition of linear in the question.

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

採用された回答

Torsten
Torsten 2022 年 4 月 2 日
編集済み: Torsten 2022 年 4 月 2 日
Call your function handle f with symbolic vectors x and y and a symbolic scalar a and check whether
f(x+y) - (f(x) + f(y)) - f(0) == 0
f(a*x) - a*f(x) == 0
  4 件のコメント
Daniela Würmseer
Daniela Würmseer 2022 年 4 月 3 日
Thank you for your answers.
Perhaps i could solve my Problem differently: My Problem is that i have an Algorithm which takes an Optimization Problem with two functions f1, f2 which can be linear or nonlinear. And the Algorithm solves this Problem by a kind of direction Method. So it solves first a "new" Optimization Problem with one function (max alpha) and the constraints are the constraints of the origin Problem and we add as constraints for example: (those are only for illustration and not the real algorithm):
f1(x)-alpha <= 0 and f2(x)-alpha <=0.
I could just define those functions in nonlincon of fmincon but nonlincon is normally for nonlinear functions. Would it be a problem to use nonlincon with linear functions (normally not or)?
For example if f1 and f2 are linear to still use nonlincon like this:
%Definitions of f, x0, Aneq.....
nonlincon = @constr;
function [cneq,ceq] = constr(x)
ceq = [];
cneq(1) = f1(x)-alpha;
cneq(2) = f2(x)-alpha;
end
options = optimoptions('fmincon','Algorithm','sqp');
[x,alpha]=fmincon(f,x0,Aneq,bneq,Aeq,beq,lb,[],nonlincon,options);
Torsten
Torsten 2022 年 4 月 3 日
I could just define those functions in nonlincon of fmincon but nonlincon is normally for nonlinear functions. Would it be a problem to use nonlincon with linear functions (normally not or)?
No problem. Implementing linear constraints either in lb,ub or A, Aeq, b, beq should only make the code run faster.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver-Based Nonlinear Optimization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by