Constrained linear least-squares problems, with unknowns in multiplier matrix

1 回表示 (過去 30 日間)
Gino Sartori
Gino Sartori 2022 年 9 月 8 日
コメント済み: Gino Sartori 2022 年 9 月 8 日
I have three known vectors v_1, v_2 and v_3 and an unknown vector C
v_1 = [47;23;4;3;9;8;3];
v_2 = [32;17;5;21;8;3;11];
v_3 = [22;9;6;34;2;2;0];
V = sym('v',[7 1]);
the four vectors are related by the following equations
syms a b c d
eqn1 = v_2 == a*v_1+b*V;
eqn2 = v_3 == c*v_1+d*V;
So in total I have 11 unknowns (a,b,c,d and v1-v7) and 14 equations (7 from eqn1 and 7 from eqn2). The sum of a+b (and c+d) must be equal to 1, and the sum of v1-v7 must give 100.
This is not an exact relationship, but I would like to solve the problem as closely as possible. For this reason, based on my experiences with a similar problem (but with C as a known vector), I thought of solving the problem using lsqlin:
C = [v_1,V]
Aeq = ones(1,2);
beq = 1;
lb = zeros(1,2);
ub = ones(1,2);
x = lsqlin(C,v_2,[],[],Aeq,beq,lb,ub)
However, I have now run into two problems: (1) lsqlin requires C to be data type double (2) I want to consider both eqn1 and eqn2 simultaneously to solve my problem.
Does anyone have any advice on how to deal with this problem?

採用された回答

Torsten
Torsten 2022 年 9 月 8 日
You must use a nonlinear optimizer (in this case: fmincon) because products of the parameters to be estimated are involved (b*V, d*V). lsqlin is not suited for this case.
Take the below code as a start.
v_1 = [47;23;4;3;9;8;3];
v_2 = [32;17;5;21;8;3;11];
v_3 = [22;9;6;34;2;2;0];
fun = @(p)[v_2-p(1)*v_1-p(2)*p(5:11);v_3-p(3)*v_1-p(4)*p(5:11)];
f = @(p) sum(fun(p).^2);
Aeq = [0 0 0 0 1 1 1 1 1 1 1;1 1 0 0 0 0 0 0 0 0 0; 0 0 1 1 0 0 0 0 0 0 0];
beq = [100;1;1];
lb = [0 0 0 0 -Inf -Inf -Inf -Inf -Inf -Inf -Inf].';
ub = [1 1 1 1 Inf Inf Inf Inf Inf Inf Inf ].';
p0 = [0.5 0.5 0.5 0.5 100/7*ones(1,7)].';
p = fmincon(f,p0,[],[],Aeq,beq,lb,ub)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Least Squares についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by