How to Solve Linear Complementarity Problem (LCP) with MATLAB ?
조회 수: 15 (최근 30일)
이전 댓글 표시
I want to use MATLAB for solving Linear Complementarity Problem (LCP) as defined in the following:

what optimization function (e.g., fmincon,lsqnonneg,etc.) should I use, or someone could give me some example.
댓글 수: 1
채택된 답변
Matt J
2025년 6월 9일
편집: Matt J
2025년 6월 9일
n=5; q=-rand(n,1); M=rand(n); M=(M+M')/2;
smallTolerance=1e-6;
z=optimvar('z',n,'Lower',0);
prob=optimproblem('Objective', z'*M*z + z'*q, "Constraints", M*z+q>=0);
[sol,fval]=solve(prob);
fval
assert(fval<=smallTolerance, "No solution found")
eig(M)', %Not PSD
zOptimal=sol.z %Solutions
omegaOptimal=M*zOptimal+q
댓글 수: 4
Torsten
2025년 6월 9일
Don't you have to use
n=5; q=-rand(n,1); M=rand(n); Msym=(M+M')/2;
smallTolerance=1e-6;
z=optimvar('z',n,'Lower',0);
prob=optimproblem('Objective', z'*Msym*z + z'*q, "Constraints", M*z+q>=0);
[sol,fval]=solve(prob);
fval
assert(fval<=smallTolerance, "No solution found")
eig(Msym)', %Not PSD
zOptimal=sol.z %Solutions
omegaOptimal=M*zOptimal+q
for M being a general nxn matrix ?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Problem-Based Optimization Setup에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!