Hello, I have a linear program which I solved using GAMS. Then I derived the corresponding KKT conditions for the LP and solved using MCP Path solver and the results are the same which is expected. However, when I add a constraint similar to the one mentioned below, I cannot get the same results using the LP and MCP solver. The results from the LP solver makes sense though. Therefore, the KKT conditions must be wrong. The equation I am adding is as follows:

I am not sure how to take care of the ‘e(h-1)’ part when taking derivative of the above equation w.r.t e(h) when deriving KKT condition. Therefore, I am wondering if there is a solver that derives KKT condition when solving it and I can take a look at the type of KKT conditions it is forming while solving the LP. I tried the JAMS and EMP solver but I couldn’t make it work. I would really appreciate any suggestions.

If you use h-1 in your constraint, you will run into problems in the first h, as any parameter or variable with h-1 as index is not part of the model or defined.
This might have been the reason that you had different results, as e(h-1) is set to zero for the first equation.
To get rid of this problem you just add a dollar constraint to the equation so it starts at the second element.

Thank you for your reply. That actually doesn’t solve my problem since the primal problem is working fine. I am defining the value at e(0), so that is not a problem. I want to see the corresponding KKT condition for the LP. My handwritten KKTs are not giving the desired result. So I am wondering if there is a solver to derive/see the KKTs generated for the LP.

Keep in mind that JAMS does the reformulation at a scalar level, and it does this in the process directory, which is by default deleted at the completion of the GAMS run. So run like this:

gams nlp2mcp.gms keep=1

then go to the process directory named 225a or similar. Lots of stuff there, especially the MCP model in emp.dat.

If you struggle with matching the names used in emp.dat (e.g. x1, x2, x3) to the names from the original model, you are not alone. It helps for this to have JAMS produce a dictionary file of name matches. If you put the GAMS source below at the end of the trnsport model you’ll get the dictionary file dict.txt.

Model transport / all /;
file info / '%emp.info%' /;
putclose info / 'modeltype mcp';
file opt / 'jams.opt' /;
putclose opt / 'dict dict.txt';
transport.optfile = 1;
solve transport using emp minimizing z;