Now, if youre like me, the thought of solving a system of equations that involves variables and constraints makes your head spin faster than a spinning top on juice. Chill out, don’t worry, my dear coding friends, because I’m here to help!
To kick things off: what is optimization presolve? Well, it’s basically a fancy way of saying “pre-processing” or “cleaning up the mess before we start solving.” In other words, it involves simplifying and transforming the original linear programming problem into an equivalent but more manageable form. And why do we need to do this? Because sometimes our initial problem can be too complex for traditional optimization algorithms to handle efficiently.
So let’s dive right in! Here are some common presolve techniques that you might encounter:
1. Removing redundant constraints: This involves identifying and eliminating any constraints that don’t add anything new or useful to the problem. For example, if we have a constraint like x + y 5 but another constraint says x 3, then we can eliminate the first constraint because it’s already implied by the second one.
2. Removing redundant variables: Similar to removing redundant constraints, this involves identifying and eliminating any variables that don’t add anything new or useful to the problem. For example, if we have a variable x that can be expressed as y + z w, then we can eliminate x because it’s already defined in terms of other variables.
3. Adding slack variables: This involves introducing new variables (called “slacks”) to help simplify the problem and make it easier to solve. For example, if we have a constraint like 2x + y = 10 but want to convert it into an equivalent form with only non-negative variables, then we can introduce two slack variables s1 and s2 as follows:
x + y/2 s1 = 5 (where s1 is the first slack variable)
2x + y s2 = 10 (where s2 is the second slack variable)
4. Adding surplus variables: Similar to adding slack variables, this involves introducing new variables (called “surpluses”) to help simplify the problem and make it easier to solve. For example, if we have a constraint like x + y 10 but want to convert it into an equivalent form with only non-negative variables, then we can introduce two surplus variables s1 and s2 as follows:
x + y s1 = 10 (where s1 is the first surplus variable)
0 s1 (where s1 must be a non-negative variable)
5. Adding big-M constraints: This involves introducing new constraints to help simplify the problem and make it easier to solve. For example, if we have a constraint like x + y > 10 but want to convert it into an equivalent form with only binary variables (i.e., variables that can take on values of either 0 or 1), then we can introduce two new binary variables z1 and z2 as follows:
x + y Mz1 = 10 (where M is a very large number)
0 x + y Mz1 (where this constraint ensures that the left-hand side of the previous equation cannot be negative)
z1 {0, 1} (where this variable must take on either value 0 or 1)
6. Adding big-R constraints: Similar to adding big-M constraints, but for variables that can only take on values between two given bounds. For example, if we have a constraint like x > 5 but want to convert it into an equivalent form with only binary variables and a new variable r (which takes on the value of either 0 or 1), then we can introduce the following constraints:
x M(r-1) = 5 (where M is a very large number)
0 x M(r-1) (where this constraint ensures that the left-hand side of the previous equation cannot be negative)
r {0, 1} (where this variable must take on either value 0 or 1)
7. Adding big-C constraints: Similar to adding big-M and big-R constraints, but for variables that can only take on values between two given bounds with a constant term added to the constraint. For example, if we have a constraint like x + y > 5 but want to convert it into an equivalent form with only binary variables and new variables r1 and r2 (which take on the value of either 0 or 1), then we can introduce the following constraints:
x + y M(r1-1) = 5 (where M is a very large number)
0 x + y M(r1-1) (where this constraint ensures that the left-hand side of the previous equation cannot be negative)
r1 {0, 1} (where this variable must take on either value 0 or 1)
y N(r2-1) = 0 (where N is a very large number)
0 y N(r2-1) (where this constraint ensures that the left-hand side of the previous equation cannot be negative)
r2 {0, 1} (where this variable must take on either value 0 or 1)
8. Adding big-L constraints: Similar to adding big-M and big-R constraints, but for variables that can only take on values between two given bounds with a constant term added to the constraint and a new variable l (which takes on the value of either 0 or 1). For example, if we have a constraint like x + y > 5 but want to convert it into an equivalent form with only binary variables, new variables r1, r2, and l (which take on the value of either 0 or 1), then we can introduce the following constraints:
This is great information! And maybe give a code snippet for implementing one of them in Python?