I'm using amplpy, and setting up the following model to solve a simple LCP:
set Rn;
param B {Rn,Rn} default 0;
param q {Rn} default 0;
var x {j in Rn};
s.t. f {i in Rn}:
0 <= x[i]
complements
sum {j in Rn} B[i,j]*x[j]
>= -q[i];
I'm solving it via pathampl, which confirms that
** EXIT - solution found.
Major Iterations. . . . 0
Minor Iterations. . . . 0
Restarts. . . . . . . . 0
Crash Iterations. . . . 1
Gradient Steps. . . . . 0
Function Evaluations. . 2
Gradient Evaluations. . 2
Basis Time. . . . . . . 0.012745
Total Time. . . . . . . 0.022692
Residual. . . . . . . . 1.830372e-08
Path 4.7.04: Solution found.
1 iterations (1 for crash); 0 pivots.
2 function, 2 gradient evaluations.
Now, let's evaluate the solution.
x = ampl.getVariable('x').getValues().toPandas().values[:, 0]
BB = ampl.getParameter('B').getValues().toPandas().values
qq = ampl.getParameter('q').getValues().toPandas().values[:, 0]
# second part of complementarity problem: Bx +q >= 0
# first part is trivially: x >= 0
# so, either x =0 or ineq2 =0 opr both, so it's necessary that the product is zero, which is not the case:
(ineq2 * x).min()
Out[18]: -4478.5662322322232
(ineq2 * x).max()
Out[19]: 4487.1317370994529
Have I set up my model incorrectly?