help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] Single index for multidimensional sets


From: glpk xypron
Subject: Re: [Help-glpk] Single index for multidimensional sets
Date: Tue, 17 Jul 2012 17:01:00 +0200

Hello Mate,

a index symbol is always scalar and never a tuple. But you can use string 
concatenation for merging your indices:

set S1;
set S2;
set S3 := setof {s1 in S1, s2 in S2: s1!=s2} s1&","&s2;
set S4 := setof {s1 in S1, s2 in S2: s1<s2}  s1&","&s2;

param p{S3}, default 3;

var x{s3 in S3};

s.t. constraint1{s3 in S3}:
  x[s3]>=p[s3];

s.t. constraint2{s4 in S4}:
  x[s4] >= 2 * p[s4];

data;
set S1 := s11 s12;
set S2 := s21 s22 s23;
end;

Best regards

Xypron
-------- Original-Nachricht --------
> Datum: Tue, 17 Jul 2012 15:30:07 +0200
> Von: Mate Hegyhati <address@hidden>
> An: address@hidden
> Betreff: [Help-glpk] Single index for multidimensional sets

> Dear All,
> 
> is it somehow possible to use a single index symbol for addressing an
> n-tuple? In one of my problems I have a 3 dimensional set, that is used
> as a basis for other sets, etc. I'm trying to do something like this:
> 
> set S1;
> set S2;
> set S3 := setof {s1 in S1, s2 in S2: s1!=s2} (s1,s2);
> 
> param p{s1 in S1, s2 in S2}, default 3;
> 
> var x{s3 in S3}; # this is, that should be (s1,s2) in S3
> 
> s.t. constraint1 {s3 in S3}: # similar here
>   x[s3]>=p[s3];
> 
> s.t. constraint2{s1 in S1, s2 in S2: s1<s2}:
>   x[s1,s2] >= 2 * p[s1,s2];
> 
> It is not working, and according to the manual, an index should match
> the dimension of the set. Is it somehow possible to avoid writing
> (s1,s2) everywhere?
> 
> Thank You very much in advance, best regards,
> 
> Mate Hegyhati



reply via email to

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