use and misuse of dynamic sets 09/24/01 10:55:40 PAGE 1 GAMS Rev 121 Linux/Intel 2 3 set 4 i/1*1000/ 5 j(i) 6 k(i,i) 7 l(i,i) /1*10 . 1*10/ 8 m(i) /1*10, 20*30/; 9 10 * define j to be a dynamic set - the first 300 elements of i 11 j(i)$(ord(i) < 300) = yes; 12 13 * k a dynamic set also - the cartesian product of i and j 14 k(i,j) = yes; 15 16 scalar n, val; 17 18 * card() operation legal for both static and dynamic sets 19 n = card(j); display n; 20 n = card(k); display n; 21 n = card(l); display n; 22 23 * ord() operation valid only for static sets; by using it here we are 24 * establishing m as a static set 25 loop(m, 26 val = ord(m); display val; 27 ); 28 29 * the following assignment requires m to be dynamic and is disallowed, 30 * since it has already been established as a static set. 31 m('40') = yes; **** $199 **** 199 Assigning to set used in 'ord' or lag **** this statement changes the content of a set **** previously used with 'ord' or lag/lead. 32 33 * the following statement doesn't work, since ord() is not defined on a 34 * dynamic set, and we have established j as dynamic above 35 loop(j, 36 val = ord(j); **** $197 **** 197 Lag or 'ord' illegal with non constant set **** or use of a * universe 37 display val; 38 ); **** 2 ERROR(S) 0 WARNING(S) COMPILATION TIME = 0.010 SECONDS 0.7 Mb LNX200-121 USER: Computer Sciences Dept. G010628:1627AS-LNX University of Wisconsin-Madison DC2621 **** FILE SUMMARY INPUT /afs/cs.wisc.edu/u/s/w/swright/public/html/635/examples/dynamic.gms OUTPUT /afs/cs.wisc.edu/u/s/w/swright/public/html/635/examples/dynamic.lst **** USER ERROR(S) ENCOUNTERED