[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] help to formulate problem in terms of LP
From: |
Andrew Makhorin |
Subject: |
Re: [Help-glpk] help to formulate problem in terms of LP |
Date: |
Tue, 22 Apr 2008 19:59:55 +0400 |
> Yes i need several clauses connected with "or". But i do not
> understand your idea.
The idea is quite simple.
Let you need to model the following condition:
a1 <= x <= b1 OR a2 <= x <= b2 OR ... OR an <= x <= bn
assuming that regions [a1,b1], [a2,b2], ..., [an,xn] are
pairwise disjoint.
Using binary variables z1, z2, ..., zn, where exactly one variable
can be 1, i.e.
z1 + z2 + ... + zn = 1
you can model the condition as follows:
a1 * z1 + a2 * z2 + ... + an * zn <= x <=
b1 * z1 + b2 * z2 + ... + bm * zn