[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## [Help-glpk] [Fwd: Constraints on 2 successive elements of a set]

**From**: |
Andrew Makhorin |

**Subject**: |
[Help-glpk] [Fwd: Constraints on 2 successive elements of a set] |

**Date**: |
Tue, 20 Nov 2012 22:15:28 +0400 |

-------- Forwarded Message --------
From: paterijk <address@hidden>
To: address@hidden
Subject: [Help-glpk] Constraints on 2 successive elements of a set
Date: Tue, 20 Nov 2012 09:40:00 -0800 (PST)
Hi,
I'm trying to model a constraint using the GMPL modeling language.
To start, we have a set of n indices called J, and a variable vector x with
n components. The constraint then should look like :
x_i >= x_{i+1} for i=1..n-1 (obviously we do not want i+1 to go beyond the
limits of J)
What I do is the following, but I do not find it very elegant :
set J;
set K;
var x{i in J};
s.t. c{i in K} x[i] >= x[i+1]
In the data section I then define :
set J := 1 2 3;
set K := 1 2;
Does anybody know how to handle this without having to go through this set K
which I have to adapt in the data section when the set J changes? K is just
J minus the last element. Note that this also does not work when J (and K)
contain non numerical elements (because of the i+1 in the constraints).
Thanks for any hint,
Patrick
--
View this message in context:
http://old.nabble.com/Constraints-on-2-successive-elements-of-a-set-tp34702881p34702881.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.

**[Help-glpk] [Fwd: Constraints on 2 successive elements of a set]**,
*Andrew Makhorin* **<=**