help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] [Fwd: Constraints on 2 successive elements of a set]


From: Meketon, Marc
Subject: Re: [Help-glpk] [Fwd: Constraints on 2 successive elements of a set]
Date: Tue, 20 Nov 2012 12:25:48 -0600

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: help-glpk-bounces+address@hidden [mailto:help-glpk-bounces+address@hidden On Behalf Of Andrew Makhorin
Sent: Tuesday, November 20, 2012 1:15 PM
To: address@hidden
Subject: [Help-glpk] [Fwd: Constraints on 2 successive elements of a set]

 

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

address@hidden

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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]