Description
$onLocal allows unlimited nesting (default) $offLocal limits .local on the same symbol to one in control stack Contributor: Alex
Small Model of Type : GAMS
Category : GAMS Test library
Main file : local01.gms
$title Test .local in different context $on/offlocal (LOCAL01,SEQ=430)
$onText
$onLocal allows unlimited nesting (default)
$offLocal limits .local on the same symbol to one in control stack
Contributor: Alex
$offText
Set i /1*3/;
Alias (i,j,k);
Set aa(i,j) / 1.1, 2.2, 1.3 /
ii(i) / #i /;
Alias (ii,jj);
Parameter xxx(i,j) / 1.1 1, 1.3 13,
2.2 2,
3.3 3, 3.2 32 /
bb(i) / 1 1, 2 2, 3 3 /
f(i), ff(i), fDiff(i),
g(i,j), gg(i,j), gDiff(i,j);
$macro gtest gDiff(i,j) = g(i,j) xor gg(i,j); abort$card(gDiff) gDiff,gg,g
$macro ftest fDiff(i) = f(i) xor ff(i); abort$card(fDiff) fDiff,ff,f
option clear=gg; gg(i-1,j) = xxx(j,j); display gg;
option clear=g; g(i-1,i.local) = xxx(i,i); gtest;
option clear=gg; gg(i,j-1) = xxx(j,j); display gg;
option clear=g; g(i,i.local-1) = xxx(i,i); gtest;
option clear=gg; gg(aa(i,j-1)) = xxx(j,j); display gg;
option clear=g; g(aa(i,i.local-1)) = xxx(i,i); gtest;
option clear=gg; gg(i, j) = xxx(j,j); display gg;
option clear=g; g(i, i.local) = xxx(i,i); gtest;
option clear=g; g(ii, ii.local) = xxx(ii,ii); gtest;
option clear=g; g(ii(i),ii.local) = xxx(ii,ii); gtest;
option clear=g; loop(i, g(i,j) = xxx(j,j)); gtest;
option clear=g; loop(i, g(i,i.local) = xxx(i,i)); gtest;
option clear=g; loop(ii, g(ii,ii.local) = xxx(ii,ii)); gtest;
option clear=g; loop(ii(i), g(ii,ii.local) = xxx(ii,ii)); gtest;
option clear=gg; gg(i, j)$aa(i,j) = xxx(j,j); display gg;
option clear=g; g(aa(i, i.local)) = xxx(i,i); gtest;
option clear=g; g(aa(ii, ii.local)) = xxx(ii,ii); gtest;
option clear=g; g(aa(ii(i),ii.local)) = xxx(ii,ii); gtest;
option clear=gg; loop(i, gg(aa(j, j)) = xxx(j,j)); display gg;
option clear=g; loop(i, g(aa(i.local, i)) = xxx(i,i)); gtest;
option clear=g; loop(ii, g(aa(ii.local,ii)) = xxx(ii,ii)); gtest;
option clear=g; loop(ii(i), g(aa(ii.local,ii)) = xxx(ii,ii)); gtest;
option clear=gg; loop(i, loop(j, gg(aa(j, j)) = xxx(j,j))); display gg;
option clear=g; loop(i, loop(i.local, g(aa(i, i)) = xxx(i,i))); gtest;
option clear=g; loop(ii, loop(ii.local, g(aa(ii,ii)) = xxx(ii,ii))); gtest;
option clear=g; loop(ii(i), loop(ii.local, g(aa(ii,ii)) = xxx(ii,ii))); gtest;
option clear=gg; gg(i, j)$aa(i,j) = xxx(j,j); display gg;
option clear=g; g(aa(i, i.local)) = xxx(i,i); gtest;
option clear=g; g(aa(ii, ii.local)) = xxx(ii,ii); gtest;
option clear=g; g(aa(ii(i),ii.local)) = xxx(ii,ii); gtest;
option clear=ff; ff(j) = sum(i, xxx(i,i)); display ff;
option clear=f; f(j) = sum(j.local, xxx(j,j)); ftest;
option clear=f; f(jj) = sum(jj.local, xxx(jj,jj)); ftest;
option clear=f; f(jj(j)) = sum(jj.local, xxx(jj,jj)); ftest;
option clear=ff; ff(j) = sum(i$aa(i,i), xxx(i,i)); display ff;
option clear=f; f(j) = sum(j.local$aa(j,j), xxx(j,j)); ftest;
option clear=f; f(jj) = sum(jj.local$aa(jj,jj), xxx(jj,jj)); ftest;
option clear=f; f(jj(j)) = sum(jj.local$aa(jj,jj), xxx(jj,jj)); ftest;
option clear=ff; ff(j) = sum(aa(i,i), xxx(i,i)); display ff;
option clear=f; f(j) = sum(aa(j.local,j), xxx(j,j)); ftest;
option clear=f; f(jj) = sum(aa(jj.local,jj), xxx(jj,jj)); ftest;
option clear=f; f(jj(j)) = sum(aa(jj.local,jj), xxx(jj,jj)); ftest;
option clear=f; f(j.local) = sum(aa(j.local,j), xxx(j,j)); ftest;
option clear=f; f(jj.local) = sum(aa(jj.local,jj), xxx(jj,jj)); ftest;
option clear=f; f(jj.local(j)) = sum(aa(jj.local,jj), xxx(jj,jj)); ftest;
option clear=ff; ff(j) = sum(aa(i,k), xxx(k,k)); display ff;
option clear=f; f(j) = sum(aa(j.local,j.local), xxx(j,j)); ftest;
option clear=f; f(jj) = sum(aa(jj.local,jj.local), xxx(jj,jj)); ftest;
option clear=f; f(jj(j)) = sum(aa(jj.local,jj.local), xxx(jj,jj)); ftest;
option clear=f; f(j) = sum((k,j.local)$aa(k,j), xxx(j,j)); ftest;
option clear=f; f(jj) = sum((k,jj.local)$aa(k,jj), xxx(jj,jj)); ftest;
option clear=f; f(jj(j)) = sum((k,jj.local)$aa(k,jj), xxx(jj,jj)); ftest;
option clear=ff; ff(j) = sum((i, k)$aa(k,k), xxx(k,k)); display ff;
option clear=f; f(j) = sum((j.local, j.local)$aa(j,j), xxx(j,j)); ftest;
option clear=f; f(jj) = sum((jj.local,jj.local)$aa(jj,jj), xxx(jj,jj)); ftest;
option clear=f; f(jj(j)) = sum((jj.local,jj.local)$aa(jj,jj), xxx(jj,jj)); ftest;
option clear=ff; ff(j) = sum(aa(i, k), xxx(k,k)); display ff;
option clear=f; f(j) = sum(aa(j.local, j.local), xxx(j,j)); ftest;
option clear=f; f(jj) = sum(aa(jj.local,jj.local), xxx(jj,jj)); ftest;
option clear=f; f(jj(j)) = sum(aa(jj.local,jj.local), xxx(jj,jj)); ftest;
abort.noerror 'leave before we have bad code';
$if not errorfree $abort this should never happen
gg(i,j) = xxx(i.local,j);
$if errorfree $abort missing error message
$clearErrors
$offLocal
f(j.local) = sum(aa(j.local,j), xxx(j,j));
$if errorfree $abort should have reported local nesting
$clearErrors