fmincon nonlinear inequality constraint

1 回表示 (過去 30 日間)
hey yo
hey yo 2022 年 8 月 9 日
コメント済み: hey yo 2022 年 8 月 9 日
Hello,
I do a maximum likelihood estimation using fmincon. My code requires doing a Choleski decomposition to the matrix: A=[betas(7) betas(9); betas(9) betas(8)]. Choleski decomposition requires the matrix A to be positive definite. Because A is a 2x2 matrix, positive definiteness require two conditions:
  1. beta(7)>0
  2. beta(7)*beta(8)-beta(9)^2>0
I set the lowerbound of beta(7) to be 0. To satisfy the second nonlinear inequality constraint, I wrote a function
function [c,ceq]=mycons(betas)
ceq=[];
c=-(betas(7)*betas(8)-betas(9)^2);
end
Then I run my fmincon function
[b_out,fval] =fmincon(@(betas)mainlf3(betas,numobs, p),betas,[],[],[],[], lb, ub,@(betas)mycons(betas), options1);
However, the code does not satisfy the nonlinear constraint. It gives me the error:
Error using chol
Matrix must be positive definite.
Can anyone see what I'm doing wrong? Thank you.

採用された回答

Matt J
Matt J 2022 年 8 月 9 日
編集済み: Matt J 2022 年 8 月 9 日
The nonlinear constraints are not obeyed at all iterations. At iterations where they are not obeyed, chol() will give you an error for obvious reasons.
I suggest you parametrize directly in terms of the Cholesky decomposition., i.e., Let L be an unknown matrix and set the constraint,
ceq=L*L'-[betas(7) betas(9); betas(9) betas(8)];
  3 件のコメント
Matt J
Matt J 2022 年 8 月 9 日
Yes, L would be composed of unknowns in addition to beta.
L=[L1,0;
L2,L3];
hey yo
hey yo 2022 年 8 月 9 日
Okay, thank you! This is excellent!

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

その他の回答 (1 件)

Torsten
Torsten 2022 年 8 月 9 日
It is not guaranteed that the "test parameters" betas satisfy the constraints in each iteration of the optimization process.
So you should first check for positive definiteness before calling Chol. If not, enlarge the diagonal elements artificially by a certain amount.
  1 件のコメント
hey yo
hey yo 2022 年 8 月 9 日
Thank you! I will try to do that artificial adjustment as you suggested.

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

カテゴリ

Help Center および File ExchangeNonlinear Optimization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by