[Top][All Lists]
[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: |
Andrew Makhorin |
Subject: |
Re: [Help-glpk] [Fwd: Constraints on 2 successive elements of a set] |
Date: |
Wed, 21 Nov 2012 05:45:11 +0400 |
-------- Forwarded Message --------
From: paterijk <address@hidden>
To: address@hidden
Subject: Re: [Help-glpk] [Fwd: Constraints on 2 successive elements of a
set]
Date: Tue, 20 Nov 2012 11:27:10 -0800 (PST)
Sure, that works. Didn't know about these conditions that one can add in the
definition of a set. Great!
However this does not work with a set containing some strings ... imagine
that instead of "J := 1 2 3;" I would define "J := one two three;" in the
data part to make the output more comprehensible.
Thanks anyway for this solution,
Patrick
Meketon, Marc-2 wrote:
>
> 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: address@hidden
> [mailto: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<mailto:address@hidden>>
>
> To: address@hidden<mailto: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<mailto: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.
>
> _______________________________________________
> Help-glpk mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-glpk
>
>
--
View this message in context:
http://old.nabble.com/-Fwd%3A--Constraints-on-2-successive-elements-of-a-set--tp34703082p34703320.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Help-glpk] [Fwd: Constraints on 2 successive elements of a set],
Andrew Makhorin <=