How to Solve Linear Complementarity Problem (LCP) with MATLAB ?
24 views (last 30 days)
Show older comments
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 Comment
Accepted Answer
Matt J
on 9 Jun 2025
Edited: Matt J
on 9 Jun 2025
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 Comments
Torsten
on 9 Jun 2025
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 ?
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!