[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re[2]: [Help-glpk] Variables with different cardinalities

**From**: |
Andrew Makhorin |

**Subject**: |
Re[2]: [Help-glpk] Variables with different cardinalities |

**Date**: |
Tue, 18 Jan 2005 11:35:40 +0300 |

>* It sounds like you must be using a MIP, since variables have a finite*
>* number of possible values. All you need to do is declare a variable to *
>* be integer and give appropriate lower and upper bounds. This will limit *
>* the values it can take. It is perfectly fine to have variables with *
>* different bounds.*
>* *
>* I think something like the following would work, thought I didn't test *
>* it myself:*
>* var One >=0, <= 3, integer;*
>* var Two >=0, <= 2, integer;*
To model a discrete variable which takes its values on an arbitrary
finite domain { a[1], a[2], ..., a[n] } the following standard technique
may be used:
var x;
var z{1..n}, binary; /* auxiliary decision variables */
s.t. sum{j in 1..n} z[j] = 1;
s.t. x = sum{j in 1..n} a[j] * z[j];