Constrained Optimization, a function that returns a vector?

6 ビュー (過去 30 日間)
jaskier222
jaskier222 2017 年 7 月 14 日
コメント済み: Alan Weiss 2017 年 7 月 16 日
Hello! I looking for some matlab function (Constrained Optimization) which one returns a vector. The function what I try minimalize is in the attachment. It is MPC problem. I try to solve some problem like:
A = [];
b = [];
x0 = [0,0,0]
fun = @(x)(([3;3;3]-[3;3;3])'*([3;3;3]-[3;3;3])+parameter*(x-[1;1;1])'*(x-[1;1;1]))
[x,fval] = optimalization_function(fun,x0,A,b)
Matrices like [3;3;3] is just example.
I tried 'fmincon' but it works only for function that returns scalar.

採用された回答

Alan Weiss
Alan Weiss 2017 年 7 月 14 日
What does minimizing a vector mean? it doesn't mean anything mathematically. You cannot minimize a vector.
The equation in your attached image minimizes the NORM of a vector. That is a scalar, and makes sense to minimize. If you as fmincon to minimize the norm of a vector function, it will happily attempt to do so.
Alan Weiss
MATLAB mathematical toolbox documentation

その他の回答 (1 件)

jaskier222
jaskier222 2017 年 7 月 14 日
Hmm, I used:
x0=[0,0,0]
A=[]
b=[]
[x,fval] = fmincon(fun,x0,A,b)
fun = @(x)((y_zad_k-y_k)'*(y_zad_k-y_k)+parameter*(x-u_k_1)'*(x-u_k_1))
where
N = 6;
N_u = 3;
y_zad is matrix [Nx1]
y_k is matrix [Nx1]
u_k_1 is matrix [N_ux1]
matlab gave me this: "Supplied objective function must return a scalar value." All I placed id 2-level matlab function.
  2 件のコメント
Alan Weiss
Alan Weiss 2017 年 7 月 14 日
Evaluate fun(x0). If you don't get a scalar, then your function is not scalar-valued. If you do get a scalar, then please ask again.
Alan Weiss
MATLAB mathematical toolbox documentation
Alan Weiss
Alan Weiss 2017 年 7 月 16 日
I just had another idea. Try
x0 = zeros(3,1);
I think that your original x0 is a row vector, but should be a column vector.
Alan Weiss
MATLAB mathematical toolbox documentation

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

カテゴリ

Help Center および File ExchangeGet Started with Optimization Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by