[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: [Help-glpk] Compare two matrices

**From**: |
Andrew Makhorin |

**Subject**: |
Re: [Help-glpk] Compare two matrices |

**Date**: |
Tue, 7 Aug 2007 07:08:25 +0400 |

>*> I have the following problem: I have a parameter A with (3 indices)*
>*> and a decision variable X also with 3 indices (same matrix form).*
>*> The idea is as follows: Parameter A is the old matrix, X is the new*
>*> matrix. Now I need to be sure that at most 10 changes are made. So I*
>*> would like to have at most 10 different X[a,b,c] to A[a,b,c] for all*
>*> a,b,c.*
>*> Now I was used to programs that could work with absolute values*
>*> (SUM[a,b,c]: abs(A[a,b,c]-X[a,b,c]) <= 10), however GLPK is not able*
>*> to work with absolute values of decision variables.*
>*> Does anyone have an idea how to solve this?*
>*> I tried introducing a Dummy: D[a,b,c] = 1 for A[a,b,c]<=X[a,b,c], 0*
>*> else but that didn't work out....*
>* Big M formulation:*
>* "if z1 then x <= a - eps else x <= +M" can be modeled as*
>* x <= (a - eps) * z1 + M * (1 - z1)*
"if z2 then x >>= a + eps else x >= -M" can be modeled as
>* x >= (a + eps) * z2 - M * (1 - z2)*
>* "if z then x <= a - eps or x >= a + eps else a - eps < x < a + eps"*
>* is equivalent to "z = z1 or z2" and can be modeled as*
>* 0 <= 2 * z - z1 - z2 <= 1*
>* where z1, z2, z are binary variables.*
Since z1 and z2 cannot be 1 at the same time, i.e. z1 + z2 <= 1,
the latter constraint can be simplified as
z = z1 + z2
that allows eliminating z.