Would this work for you?


set J;

var x{i in J};



s.t. c{i in K : i < card(J)} x[i] >= x[i+1]



-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of 
Andrew Makhorin
Sent: Tuesday, November 20, 2012 1:15 PM
To: [email protected]
Subject: [Help-glpk] [Fwd: Constraints on 2 successive elements of a set]



-------- Forwarded Message --------

From: paterijk <[email protected]<mailto:[email protected]>>

To: [email protected]<mailto:[email protected]>

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 mailing list

[email protected]<mailto:[email protected]>

https://lists.gnu.org/mailman/listinfo/help-glpk

________________________________
This e-mail and any attachments may be confidential or legally privileged. If 
you received this message in error or are not the intended recipient, you 
should destroy the e-mail message and any attachments or copies, and you are 
prohibited from retaining, distributing, disclosing or using any information 
contained herein. Please inform us of the erroneous delivery by return e-mail. 
Thank you for your cooperation.
_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk

Reply via email to