Eigenvalue problem optimized with lqsnonlin

조회 수: 6 (최근 30일)
Fabio Cavagna
Fabio Cavagna 2023년 8월 3일
댓글: Matt J 2024년 10월 22일 12:13
Hello everyone,
I have the generalized eigenvalue problem (K-w^2*M)*R = 0 where
K is a 6x6 diagonal matrix whose values are unknown,
M is a 6x6 matrix whose values are known,
w^2 are the eigenvalues (typically called lambda) and they are known through f ( w = 2*pi*f )
R are the eigenvectors
I would like to obtain the diagonal values of K that minimize the difference between f_exact (my values) and f_calc evaluated through iterations.
I tried with lsqnonlin but the f_calc is far from my f_exact.
Does anyone know how to optimize in a better way?
Here's my code:
% M matrix
M = diag([1e3, 1e3, 1e3, 1e5, 1e5, 1e5]);
M(1,4) = 100; M(4,1) = 100; M(1,5) = 150; M(5,1) = 150;
M(2,6) = 10; M(6,2) = 10; M(3,6) = 1; M(6,3) = 1;
M(2,3) = 30; M(3,2) = 30; M(3,5) = 500; M(5,3) = 500;
f_exact = [30, 30, 100, 10, 10, 20]; %lambda = (2*pi*f)^2
K_guess = [1e8, 1e8, 1e8, 1e8, 1e8, 1e8]; %Initial guess
LB = [1, 1, 1, 1, 1, 1];
UB = [1e15, 1e15, 1e15, 1e15, 1e15, 1e15];
options = optimoptions('lsqnonlin','FunctionTolerance',1e-16);
K_opt = lsqnonlin(@(K) obj_function(K, M, f_exact),K_guess,LB,UB,options);
%% Check
K_check = diag(K_opt);
[R,L] = eig(K_check,M);
f_calc = diag(sqrt(L)./(2*pi));
function diff = obj_function(K, M, f_exact)
K_mat = diag(K);
[R,L] = eig(K_mat,M);
eig_calc = diag(L);
f_calc = sqrt(eig_calc)./(2*pi)
diff = f_calc - f_exact;
end
  댓글 수: 2
Torsten
Torsten 2023년 8월 3일
At least you should sort given and calculated eigenvalues before comparing them.
Sam Chak
Sam Chak 2023년 8월 4일
It's good to learn optimization with lqsnonlin. However, in this eigenvalue problem, the algorithm is kind of defeating the purpose because your objective function depends eig() computation itself.
Might as well use eig() directly to find the eigenvalues. You can use eig() for checking the accuracy, but not relying on it to solve the problem.
The logical question is how can the objective function be formulated without eig()?

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

채택된 답변

Matt J
Matt J 2023년 8월 3일
편집: Matt J 2023년 8월 3일
% M matrix
M = diag([1e3, 1e3, 1e3, 1e5, 1e5, 1e5]);
M(1,4) = 100; M(4,1) = 100; M(1,5) = 150; M(5,1) = 150;
M(2,6) = 10; M(6,2) = 10; M(3,6) = 1; M(6,3) = 1;
M(2,3) = 30; M(3,2) = 30; M(3,5) = 500; M(5,3) = 500;
f_exact = [30, 30, 100, 10, 10, 20];
K_guess = ((2*pi*f_exact(:)).^2.*diag(M))'; %<---- better initial guess
LB = [1, 1, 1, 1, 1, 1];
UB = [1e15, 1e15, 1e15, 1e15, 1e15, 1e15];
options = optimoptions('lsqnonlin','FunctionTolerance',1e-16,'StepTol',1e-16, 'OptimalityTol',1e-12,'MaxFunEvals',inf);
[K_opt,~,res] = lsqnonlin(@(K) obj_function(K, M, f_exact),K_guess,LB,UB,options);
Local minimum possible. lsqnonlin stopped because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance.
%% Check
K_check = diag(K_opt);
[R,L] = eig(K_check,M);
f_calc = diag(sqrt(L)./(2*pi)).';
sort(f_calc) %<---compare sorted
ans = 1×6
9.9997 10.0000 20.0000 30.0000 30.0000 100.0000
sort(f_exact)
ans = 1×6
10 10 20 30 30 100
function diff = obj_function(K, M, f_exact)
K_mat = diag(K);
[R,L] = eig(K_mat,M);
eig_calc = diag(L).'; %<---transpose
f_calc = sqrt(eig_calc)./(2*pi);
diff = sort(f_calc) - sort(f_exact); %<---compare sorted
end
  댓글 수: 7
Marina
Marina 2024년 10월 22일
편집: Marina 2024년 10월 22일
Do you have any suggestion on how I can get my K stiffness matrix? with a better exact vs calculated values. Thank you!
Matt J
Matt J 2024년 10월 22일 12:13
I'm afraid not. I have no reason to believe it should work.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by