KKT function

135 views
Skip to first unread message

Yuzhou Zhao

unread,
Jul 8, 2022, 11:24:45 PM7/8/22
to YALMIP
Hello, I have two questions related to the KKT function in Yalmip.

First, I observe that the KKT function yields negative values for the dual variables of equality constraints. Why is it not positive dual variables? I attach a convex problem without inequality constraints for testing. In this file, I use
捕获.PNG
to calculate the dual variables and yield negative values of dual variables.

Second, I am confused about the results from the  KKT function when considering the inequality constraints. In the results, I can only see many matrices with many numbers, say A and rhs. But I don't know how these relate to inequality constraints and which row and column correspond to which dual variables. I also attached a test file for a convex problem with inequality constraints for testing. Thanks.
convex_problem_without_inequality.m
convex_problem_with_inequality.m

Johan Löfberg

unread,
Jul 9, 2022, 2:15:48 AM7/9/22
to YALMIP
Dual variables for equalities have no sign restrictions, and which sign you get depends on conventions used (x==y and y==x are equivalent but ill lead to different signs)

To figure out how extracted data corresponds to high-level model, you will have to reverse engineer using models with known data by looking at where your constraint ended up. Normally it is simply in the same order as they were added in the model

Yuzhou Zhao

unread,
Jul 9, 2022, 11:09:20 AM7/9/22
to YALMIP
Thank you. I have another question. Since my convex problem includes inequality constraints, after the problem is solved,  I want to know which constraints are tight. I want to obtain the signal that the constraint is tight and change the constraint to equality constraints.

For example, my convex problem has an inequality constraint, say,   x<=1. After the problem is solved, the value of x is 1, which means the inequality constraint x<=1 is tight. Then, I change the equality constraint to "x==1" and resolve the problem. I think the result remains the same.

I don't want to do this manually because the real problem may have many constraints and many constraints are tight. Is there any method to achieve this procedure?

Johan Löfberg

unread,
Jul 9, 2022, 11:18:50 AM7/9/22
to YALMIP

Solve and resolve what? The KKT conditions derived contains a set of nonconvex complementarity constraints, and once you've solved the KKT problem (using a global solver) there is nothing to resolve

If you remove the complementarity, and then solve the LP relaxation and check if something is tight and then resolve after changing to equality, you've done nothing really as you get the same solution (assuming it is unique). You cannot solve the KKT system by some simple procedure as it sounds you think, it is NP-hard and requires a complex branch-and-bound procedure to be solved.

Johan Löfberg

unread,
Jul 9, 2022, 11:21:32 AM7/9/22
to YALMIP
it is also a bit unclear why you are using the KKT operator, as you did not use it with any specification of parameters. Simply deriving the KKT for a fixed LP and then trying to solve that system is a bad way of solving the starting problem

Yuzhou Zhao

unread,
Jul 9, 2022, 2:09:39 PM7/9/22
to YALMIP
My purpose is to obtain the matrix A in the KKT condition and also inverse it. However, if the inequality constraints are included, matrix A is not a square matrix that cannot be inversed(inv(A)). So I try to remove the inequality constraints. To do so, first, I need to know which inequality constraint is tight, I pick out this constraint and change it into an equality constraint and resolve the original problem with this equality constraint. I will get the same result.

Sometimes, we want to study the sensitivity so the matrix A is important, not just build an optimization problem and solve it directly. I attach an example in the file.

test.m

Yuzhou Zhao

unread,
Jul 9, 2022, 2:18:38 PM7/9/22
to YALMIP
For example, if I make a disturbance in an equality constraint, say x1+x2==3+theta, theta is a disturbance. I want to study how this disturbance affects the variables x1 and x2. I want to study the sensitivity, dx1/dtheta and dx2/dtheta. If I don't have matrix A, how can I study the sensitivity? If the matrix A is not square. how can I inverse it to obtain the derivatives?

Johan Löfberg

unread,
Jul 10, 2022, 2:54:23 AM7/10/22
to YALMIP
If your only use of kkt is to get the A-matrix, why even involve kkt. Just export the model to a solver format and then identify from there.
Reply all
Reply to author
Forward
0 new messages