필터 지우기
필터 지우기

Least Squares with constraint on absolute value

조회 수: 2 (최근 30일)
L
L 2023년 6월 15일
댓글: L 2023년 6월 19일
Hi , I need to solve a least squares values of the form
, where x is a 32x1 vector and B is a 32x32 matrix.
Howerver, x is complex and I need to constraint the solutions to make each element of vector x to have absolute value of 1.
Is that possible?
Best,

채택된 답변

Torsten
Torsten 2023년 6월 16일
편집: Torsten 2023년 6월 16일
rng("default")
n = 32;
y = rand(n,1) + 1i*rand(n,1);
B = rand(n) + 1i*rand(n);
x0 = rand(n,1) + 1i*rand(n,1);
x0 = [real(x0);imag(x0)];
x0 = x0./[sqrt(x0(1:n).^2+x0(n+1:2*n).^2);sqrt(x0(1:n).^2+x0(n+1:2*n).^2)];
fun = @(x)(B*(x(1:n)+1i*x(n+1:2*n))-y)'*(B*(x(1:n)+1i*x(n+1:2*n))-y);
fun(x0)
ans = 1.2661e+04
nonlcon = @(x)deal([],x(1:n).^2+x(n+1:2*n).^2-ones(n,1));
sol = fmincon(fun,x0,[],[],[],[],[],[],nonlcon,optimset('MaxFunEvals',10000,'TolFun',1e-12,'TolX',1e-12))
Local minimum possible. Constraints satisfied. fmincon stopped because the size of the current step is less than the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance.
sol = 64×1
0.6418 -0.9517 -0.9328 -0.8359 -0.9372 0.4603 0.7496 0.8249 0.9990 -0.2242
fun(sol)
ans = 10.3184
sol(1:n).^2+sol(n+1:2*n).^2-ones(n,1)
ans = 32×1
1.0e-15 * 0 0 -0.2220 0 0 0 0 0 0 0

추가 답변 (1개)

Matt J
Matt J 2023년 6월 15일
편집: Matt J 2023년 6월 15일
You'll need to write the problem in terms of the real-valued components xi and xr of x,
x=xr+1i*xi
Once you do that, your absolute value constraints become quadratic,
xr^2+xi^2=1
and you can solve with fmincon.
  댓글 수: 2
L
L 2023년 6월 16일
편집: L 2023년 6월 16일
Than
ks for your answer.
Is this correct?
n = @(x) vecnorm( y - B*x);
A = [];
b = [];
Aeq = [];
beq = [];
lb = [];
ub = [];
nonlcon = @unity;
x0 = zeros(32,1);
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)
function [c,ceq] = unity(x)
c = real(x)^2 + 1*iimg(x)^2 - 1;
ceq = [];
end

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Solver 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