caproject.gms : Test Connect agent Projection

Description

This test ensures the correctness of the Connect agent "Projection".

Contributor: Michael Bussieck, February 2022


Small Model of Type : GAMS


Category : GAMS Test library


Main file : caproject.gms

$title 'Test Connect agent Projection' (CAPROJECT,SEQ=889)

$ontext
This test ensures the correctness of the Connect agent "Projection".

Contributor: Michael Bussieck, February 2022
$offtext


* On the major platforms (Windows, Linux, Mac), GMSPYTHONLIB gets automatically set 
* to use the internal Python installation in sysdir/GMSPython.
$if not setEnv GMSPYTHONLIB $abort.noError Embedded code Python not ready to be used
$log --- Using Python library %sysEnv.GMSPYTHONLIB%

set i /i1*i5/;
set j /j1*j5/;
set k /k1*k5/;

scalar q0, p0;
parameter q2(j,i), p2(j,i);
parameter q3(k,i,j), p3(i,j,k) /
'i1'.'j2'.'k4' 0.596558144
'i2'.'j4'.'k4' 0.511448928
'i3'.'j1'.'k5' 0.045066059
'i3'.'j2'.'k4' 0.783102004
'i3'.'j3'.'k1' 0.945749415
'i3'.'j4'.'k1' 0.596462556
'i4'.'j1'.'k5' 0.607341301
'i4'.'j2'.'k2' 0.362509471
'i4'.'j5'.'k4' 0.594067961
'i5'.'j1'.'k1' 0.679854079
'i5'.'j1'.'k2' 0.506588022
'i5'.'j4'.'k4' 0.159253884
/;

variable v0, v2(j,i);
variable v3(i,j,k), w3(k,j,i);

equation e3(i,j,k);

set t3(k,i,j), s3(i,j,k) /
'i1'.'j2'.'k4'
'i2'.'j4'.'k4'
'i3'.'j1'.'k5'
'i3'.'j2'.'k4'
'i3'.'j3'.'k1'
'i3'.'j4'.'k1'
'i4'.'j1'.'k5'
'i4'.'j2'.'k2'
'i4'.'j5'.'k4'
'i5'.'j1'.'k1' First
'i5'.'j1'.'k2' Last
'i5'.'j4'.'k4'
/;
set t2(j,i), s2(j,i);

v0.l = 0;
v3.l(s3) = p3(s3); v3.scale(s3) = p3(s3);
e3.l(s3) = p3(s3);

$onEchoV > p.gms
$if %TYPE%==VAR Variable one /L 1/, two /L 2/, three /L 3/; Variable combined(*);
$if %TYPE%==EQU Equation one /L 1/, two /L 2/, three /L 3/; Equation combined(*);
$if %TYPE%==PAR Scalar   one /1/,   two /2/,   three /3/;   Parameter combined(*);
$onEmbeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'one'}, {'name':'two'}, {'name':'three'}]
- Projection:
    name: ['one', 'two', 'three']
    newName: combined
- GAMSWriter:
    symbols:
      - name: combined
$offEmbeddedCode combined
$offEcho
$call.checkErrorLevel gams p.gms lo=%gams.lo% --TYPE=VAR
$call.checkErrorLevel gams p.gms lo=%gams.lo% --TYPE=EQU
$call.checkErrorLevel gams p.gms lo=%gams.lo% --TYPE=PAR

$log test newName missing
$onEmbeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'p3'}]
- Projection:
    name: p3(i,j,k)
$offEmbeddedCode
$if errorFree $abort 'Expect errors'
$clearErrors
$log test name missing
$onEmbeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'p3'}]
- Projection:
    newName: p3(i,j,k)
$offEmbeddedCode
$if errorFree $abort 'Expect errors'
$clearErrors
$log test correct dim on name
$onEmbeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'p3'}]
- Projection:
    name: p3(i,j)
    newName: p2(j,i)
$offEmbeddedCode
$if errorFree $abort 'Expect errors'
$clearErrors
$log test suffix on parameter symbol
$onEmbeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'p3'}]
- Projection:
    name: p3.l(i,j,k)
    newName: p2(j,i)
$offEmbeddedCode
$if errorFree $abort 'Expect errors'
$clearErrors
$log test wrong suffix name
$onEmbeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'v3'}]
- Projection:
    name: v3.lower(i,j,k)
    newName: p2(j,i)
$offEmbeddedCode
$if errorFree $abort 'Expect errors'
$clearErrors
$log test aggregationMethod callable
$onEmbeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'p3'}]
- Projection:
    name: p3(i,j,k)
    newName: p2(j,k)
    aggregationMethod: groups
$offEmbeddedCode
$if errorFree $abort 'Expect errors'
$clearErrors
$log test aggregationMethod unknown
$onEmbeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'p3'}]
- Projection:
    name: p3(i,j,k)
    newName: p2(j,k)
    aggregationMethod: pingpong
$offEmbeddedCode
$if errorFree $abort 'Expect errors'
$clearErrors
$log test target parameter exists
$onEmbeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'p3'},{'name':'q3'}]
- Projection:
    name: p3(i,j,k)
    newName: q3(k,i,j)
$offEmbeddedCode
$if errorFree $abort 'Expect errors'
$clearErrors

put_utility 'log' / 'test parameter permutation';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'p3'}]
- Projection:
    name: p3(i,j,k)
    newName: q3(k,i,j)
- GAMSWriter:
    symbols: [{'name':'q3'}]
endEmbeddedCode q3
abort$(sum((i,j,k), abs(p3(i,j,k)-q3(k,i,j)))>1e-6) 'wrong q3', p3, q3;

put_utility 'log' / 'test variable level permutation';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'v3'}]
- Projection:
    name: v3.l(i,j,k)
    newName: q3(k,i,j)
- GAMSWriter:
    symbols: [{'name':'q3'}]
endEmbeddedCode q3
abort$(sum((i,j,k), abs(v3.l(i,j,k)-q3(k,i,j)))>1e-6) 'wrong q3', v3.l, q3;

put_utility 'log' / 'test variable scale permutation';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'v3'}]
- Projection:
    name: v3.scale(i,j,k)
    newName: q3(k,i,j)
- GAMSWriter:
    symbols: [{'name':'q3'}]
endEmbeddedCode q3
abort$(sum((s3(i,j,k)), abs(v3.scale(i,j,k)-q3(k,i,j)))>1e-6) 'wrong q3', v3.scale, q3;

put_utility 'log' / 'test equation level permutation';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'e3'}]
- Projection:
    name: e3.l(i,j,k)
    newName: q3(k,i,j)
- GAMSWriter:
    symbols: [{'name':'q3'}]
endEmbeddedCode q3
abort$(sum((i,j,k), abs(e3.l(i,j,k)-q3(k,i,j)))>1e-6) 'wrong q3', v3.l, q3;

put_utility 'log' / 'test variable permutation';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'v3'}]
- Projection:
    name: v3(i,j,k)
    newName: w3(k,j,i)
- GAMSWriter:
    symbols: [{'name':'w3'}]
endEmbeddedCode w3
abort$(sum((i,j,k), abs(v3.l(i,j,k)-w3.l(k,j,i)))>1e-6) 'wrong w3.l', v3.l, w3.l;
abort$(sum((i,j,k), abs(v3.scale(i,j,k)-w3.scale(k,j,i)))>1e-6) 'wrong w3.scale', v3.scale, w3.scale;

put_utility 'log' / 'test parameter projection (max)';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'p3'}]
- Projection:
    name: p3(i,j,k)
    newName: p2(j,i)
    aggregationMethod: max
- GAMSWriter:
    symbols: [{'name':'p2'}]
endEmbeddedCode p2
q2(j,i) = smax(k, p3(i,j,k));
abort$(sum((j,i), abs(p2(j,i)-q2(j,i)))>1e-6) 'wrong p2', p2, q2;

put_utility 'log' / 'test parameter projection (count)';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'p3'}]
- Projection:
    name: p3(i,j,k)
    newName: p2(j,i)
    aggregationMethod: count
- GAMSWriter:
    symbols: [{'name':'p2'}]
endEmbeddedCode p2
q2(j,i) = sum(k$p3(i,j,k),1);
abort$(sum((j,i), abs(p2(j,i)-q2(j,i)))>1e-6) 'wrong p2', p2, q2;

put_utility 'log' / 'test parameter projection (implicit first)';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'p3'}]
- Projection:
    name: p3(i,j,k)
    newName: p2(j,i)
- GAMSWriter:
    symbols: [{'name':'p2'}]
endEmbeddedCode p2
q2(j,i) = sum(k, p3(i,j,k));
q2('j1','i5') = 0.679854079;
abort$(sum((j,i), abs(p2(j,i)-q2(j,i)))>1e-6) 'wrong p2', p2, q2;

put_utility 'log' / 'test variable projection (implicit first)';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'v3'}]
- Projection:
    name: v3(i,j,k)
    newName: v2(j,i)
- GAMSWriter:
    symbols: [{'name':'v2'}]
endEmbeddedCode v2
abort$(sum((j,i), abs(v2.l(j,i)-q2(j,i)))>1e-6) 'wrong v2.l', v2.l, q2;
abort$(sum((j,i)$q2(j,i), abs(v2.scale(j,i)-q2(j,i)))>1e-6) 'wrong v2.scale', v2.scale, q2;

put_utility 'log' / 'test parameter projection (last)';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'p3'}]
- Projection:
    name: p3(i,j,k)
    newName: p2(j,i)
    aggregationMethod: last
- GAMSWriter:
    symbols: [{'name':'p2'}]
endEmbeddedCode p2
q2(j,i) = sum(k, p3(i,j,k));
q2('j1','i5') = 0.506588022;
abort$(sum((j,i), abs(p2(j,i)-q2(j,i)))>1e-6) 'wrong p2', p2, q2;

put_utility 'log' / 'test variable projection (last)';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'v3'}]
- Projection:
    name: v3(i,j,k)
    newName: v2(j,i)
    aggregationMethod: last
- GAMSWriter:
    symbols: [{'name':'v2'}]
endEmbeddedCode v2
abort$(sum((j,i), abs(v2.l(j,i)-q2(j,i)))>1e-6) 'wrong v2.l', v2.l, q2;
abort$(sum((j,i)$q2(j,i), abs(v2.scale(j,i)-q2(j,i)))>1e-6) 'wrong v2.scale', v2.scale, q2;

put_utility 'log' / 'test parameter projection (sum)';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'p3'}]
- Projection:
    name: p3(i,j,k)
    newName: p2(j,i)
    aggregationMethod: sum
- GAMSWriter:
    symbols: [{'name':'p2'}]
endEmbeddedCode p2
q2(j,i) = sum(k, p3(i,j,k));
abort$(sum((j,i), abs(p2(j,i)-q2(j,i)))>1e-6) 'wrong p2', p2, q2;

put_utility 'log' / 'test variable level projection (sum)';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'v3'}]
- Projection:
    name: v3.l(i,j,k)
    newName: p2(j,i)
    aggregationMethod: sum
- GAMSWriter:
    symbols: [{'name':'p2'}]
endEmbeddedCode p2
abort$(sum((j,i), abs(p2(j,i)-q2(j,i)))>1e-6) 'wrong p2', p2, q2;

put_utility 'log' / 'test variable scale projection (sum)';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'v3'}]
- Projection:
    name: v3.scale(i,j,k)
    newName: p2(j,i)
    aggregationMethod: sum
- GAMSWriter:
    symbols: [{'name':'p2'}]
endEmbeddedCode p2
abort$(sum((j,i), abs(p2(j,i)-q2(j,i)))>1e-6) 'wrong p2', p2, q2;

put_utility 'log' / 'test equation level projection (sum)';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'e3'}]
- Projection:
    name: e3.l(i,j,k)
    newName: p2(j,i)
    aggregationMethod: sum
- GAMSWriter:
    symbols: [{'name':'p2'}]
endEmbeddedCode p2
abort$(sum((j,i), abs(p2(j,i)-q2(j,i)))>1e-6) 'wrong p2', p2, q2;

put_utility 'log' / 'test parameter projection to scalar(sum)';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'p3'}]
- Projection:
    name: p3(i,j,k)
    newName: p0
    aggregationMethod: sum
- GAMSWriter:
    symbols: [{'name':'p0'}]
endEmbeddedCode p0
q0 = sum((i,j,k), p3(i,j,k));
abort$(abs(p0-q0)>1e-6) 'wrong p0', p0, q0;

put_utility 'log' / 'test variable level projection to scalar (sum)';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'v3'}]
- Projection:
    name: v3.l(i,j,k)
    newName: p0
    aggregationMethod: sum
- GAMSWriter:
    symbols: [{'name':'p0'}]
endEmbeddedCode p0
abort$(abs(p0-q0)>1e-6) 'wrong p0', p0, q0;

put_utility 'log' / 'test permutation of set';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'s3'}]
- Projection:
    name: s3(i,j,k)
    newName: t3(k,i,j)
- GAMSWriter:
    symbols: [{'name':'t3'}]
endEmbeddedCode t3
abort$(sum((i,j,k), s3(i,j,k) xor t3(k,i,j))>1e-6) 'wrong t3', s3, t3;

put_utility 'log' / 'test projection of set (implicit first)';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'s3'}]
- Projection:
    name: s3(i,j,k)
    newName: s2(j,i)
- GAMSWriter:
    symbols: [{'name':'s2'}]
endEmbeddedCode s2
t2(j,i) = sum(k, s3(i,j,k));
abort$(sum((j,i), s2(j,i) xor t2(j,i))>1e-6) 'wrong t3', s2, t2;

put_utility 'log' / 'test projection of set (implicit first)';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'s3'}]
- Projection:
    name: s3(i,j,k)
    newName: s2(j,i)
- GAMSWriter:
    symbols: [{'name':'s2'}]
endEmbeddedCode s2
t2(j,i) = sum(k, s3(i,j,k));
put_utility 'shell.checkErrorLevel' / 'test ' s2.te('j1','i5') ' = First';
abort$(sum((j,i), s2(j,i) xor t2(j,i))>1e-6) 'wrong t3', s2, t2;

put_utility 'log' / 'test projection of set (last)';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'s3'}]
- Projection:
    name: s3(i,j,k)
    newName: s2(j,i)
    aggregationMethod: last
- GAMSWriter:
    symbols:
      - name: s2
        mergeType: replace
endEmbeddedCode s2
put_utility 'shell.checkErrorLevel' / 'test ' s2.te('j1','i5') ' = Last';
abort$(sum((j,i), s2(j,i) xor t2(j,i))>1e-6) 'wrong t3', s2, t2;

set am "aggregation methods" / mad, max, mean, median, min, prod, sem, sum, std, nunique, first, last /;
loop(am,
  put_utility 'log' / 'test aggregation method p3->p2 ' am.tl:0;
  put_utility 'ecarguments' / '--AGGMETHOD=' am.tl:0;
  embeddedCodeV Connect:
  - GAMSReader:
      symbols: [{'name':'p3'}]
  - Projection:
      name: p3(i,j,k)
      newName: p2(j,i)
      aggregationMethod: %AGGMETHOD%
  - GAMSWriter:
      symbols: [{'name':'p2'}]
  endEmbeddedCode p2
)

loop(am,
  put_utility 'log' / 'test aggregation method p3->p0 ' am.tl:0;
  put_utility 'ecarguments' / '--AGGMETHOD=' am.tl:0;
  embeddedCodeV Connect:
  - GAMSReader:
      symbols: [{'name':'p3'}]
  - Projection:
      name: p3(i,j,k)
      newName: p0
      aggregationMethod: %AGGMETHOD%
  - GAMSWriter:
      symbols: [{'name':'p0'}]
  endEmbeddedCode p0
)

loop(am,
  put_utility 'log' / 'test aggregation method v3.l->p0 ' am.tl:0;
  put_utility 'ecarguments' / '--AGGMETHOD=' am.tl:0;
  embeddedCodeV Connect:
  - GAMSReader:
      symbols: [{'name':'v3'}]
  - Projection:
      name: v3.l(i,j,k)
      newName: p0
      aggregationMethod: %AGGMETHOD%
  - GAMSWriter:
      symbols: [{'name':'p0'}]
  endEmbeddedCode p0
)

loop(am$(sameas('first',am) or sameas('last',am)),
  put_utility 'log' / 'test aggregation method v3->v2 ' am.tl:0;
  put_utility 'ecarguments' / '--AGGMETHOD=' am.tl:0;
  embeddedCodeV Connect:
  - GAMSReader:
      symbols: [{'name':'v3'}]
  - Projection:
      name: v3(i,j,k)
      newName: v2(j,i)
      aggregationMethod: %AGGMETHOD%
  - GAMSWriter:
      symbols: [{'name':'v2'}]
  endEmbeddedCode v2
)

loop(am$(sameas('first',am) or sameas('last',am)),
  put_utility 'log' / 'test aggregation method v3->v0 ' am.tl:0;
  put_utility 'ecarguments' / '--AGGMETHOD=' am.tl:0;
  embeddedCodeV Connect:
  - GAMSReader:
      symbols: [{'name':'v3'}]
  - Projection:
      name: v3(i,j,k)
      newName: v0
      aggregationMethod: %AGGMETHOD%
  - GAMSWriter:
      symbols: [{'name':'v0'}]
  endEmbeddedCode v0
)
put_utility 'ecarguments' / '';

put_utility 'log' / 'test drop text';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'s3'}]
- Projection:
    name: s3(i,j,k)
    newName: s3noText(j,i)
    text: ""
- PythonCode:
    code: |
      expected = [
        ['j1', 'i3', ''], ['j1', 'i4', ''], ['j1', 'i5', ''],
        ['j2', 'i1', ''], ['j2', 'i3', ''], ['j2', 'i4', ''],
        ['j3', 'i3', ''], ['j4', 'i2', ''],
        ['j4', 'i3', ''], ['j4', 'i5', ''],
        ['j5', 'i4', '']
      ]
      if connect._container.data['s3noText'].records.values.tolist() != expected:
        raise Exception("Unexpected Data")
endEmbeddedCode

put_utility 'log' / 'test asSet';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'s3'}, {'name':'p3'}, {'name':'v3'}, {'name':'e3'}]
- Projection:
    name: s3(i,j,k)
    newName: s2_p1(i)
- Projection:
    name: s3(i,j,k)
    newName: s2_p2(i)
    text: ""
- Projection:
    name: p3(i,j,k)
    newName: s2_p3(i)
    asSet: True
    text: "{k}"
- Projection:
    name: v3(i,j,k)
    newName: s2_p4(i)
    asSet: True
    text: "will not {k} be applied"
- Projection:
    name: v3.l(i,j,k)
    newName: s2_p5(i)
    asSet: True
    text: "{k}"
- Projection:
    name: e3(i,j,k)
    newName: s2_p6(i)
    asSet: True
    text: "will not {k} be applied"
- Projection:
    name: e3.l(i,j,k)
    newName: s2_p7(i)
    asSet: True
    text: "{k}"
- Projection:
    name: s3(i,j,k)
    newName: s2_p8(i)
    text: "{k}: {element_text}"
- PythonCode:
    code: |
      expected_p1 = [['i1', ''], ['i2', ''], ['i3', ''], ['i4', ''], ['i5', 'First']]
      expected_p2 = [['i1', ''], ['i2', ''], ['i3', ''], ['i4', ''], ['i5', '']]
      expected_p3 = [['i1', 'k4'], ['i2', 'k4'], ['i3', 'k5'], ['i4', 'k5'], ['i5', 'k1']]
      expected_p4 = [['i1', ''], ['i2', ''], ['i3', ''], ['i4', ''], ['i5', '']]
      expected_p5 = [['i1', 'k4'], ['i2', 'k4'], ['i3', 'k5'], ['i4', 'k5'], ['i5', 'k1']]
      expected_p6 = [['i1', ''], ['i2', ''], ['i3', ''], ['i4', ''], ['i5', '']]
      expected_p7 = [['i1', 'k4'], ['i2', 'k4'], ['i3', 'k5'], ['i4', 'k5'], ['i5', 'k1']]
      expected_p8 = [['i1', 'k4: '], ['i2', 'k4: '], ['i3', 'k5: '], ['i4', 'k5: '], ['i5', 'k1: First']]
      if connect._container.data['s2_p1'].records.values.tolist() != expected_p1:
        raise Exception("Unexpected Data")
      if connect._container.data['s2_p2'].records.values.tolist() != expected_p2:
        raise Exception("Unexpected Data")
      if connect._container.data['s2_p3'].records.values.tolist() != expected_p3:
        raise Exception("Unexpected Data")
      if connect._container.data['s2_p4'].records.values.tolist() != expected_p4:
        raise Exception("Unexpected Data")
      if connect._container.data['s2_p5'].records.values.tolist() != expected_p5:
        raise Exception("Unexpected Data")
      if connect._container.data['s2_p6'].records.values.tolist() != expected_p6:
        raise Exception("Unexpected Data")
      if connect._container.data['s2_p7'].records.values.tolist() != expected_p7:
        raise Exception("Unexpected Data")
      if connect._container.data['s2_p8'].records.values.tolist() != expected_p8:
        raise Exception("Unexpected Data")
endEmbeddedCode

put_utility 'log' / 'original order of j';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'s3'}]
- Projection:
    name: s3(i,j,k)
    newName: ij(i,j)
    text: ""
- GDXWriter:
    file: ij.gdx
    symbols:
      - name: ij
endEmbeddedCode
execute 'gdxdump ij.gdx uelTable=uni symb=uni > ij.txt'
$onEcho > ijExpected.txt

Set uni /
  'i1' ,
  'i2' ,
  'i3' ,
  'i4' ,
  'i5' ,
  'j1' ,
  'j2' ,
  'j3' ,
  'j4' ,
  'j5' /;
Symbol not found: uni
$offEcho
execute.checkErrorLevel 'diff -bw ij.txt ijExpected.txt > %system.NullFile%'

set suffix / level ,marginal, lower, upper, scale/;
Parameter pv3(j,i,k,suffix);
put_utility 'log' / 'test projection of variable as parameter v3->pv3';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'v3'}]
- Projection:
    name: v3(i,j,k)
    newName: pv3(j,i,k)
    asParameter: True
- GAMSWriter:
    symbols:
      - name: pv3
endEmbeddedCode pv3
abort$(sum((i,j,k), abs(v3.l(i,j,k) - pv3(j,i,k,'level')))>1e-6) 'wrong pv3', v3.l, pv3;

Parameter pv2(j,i,suffix);
put_utility 'log' / 'test projection of variable as parameter v3->pv2';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'v3'}]
- Projection:
    name: v3(i,j,k)
    newName: v2(j,i)
- Projection:
    name: v3(i,j,k)
    newName: pv2(j,i)
    asParameter: True
- GAMSWriter:
    symbols:
      - name: v2
      - name: pv2
endEmbeddedCode v2 pv2
abort$(sum((j,i), abs(v2.l(j,i) - pv2(j,i,'level')))>1e-6) 'wrong pv2', v2.l, pv2;

Parameter pv0(suffix);
put_utility 'log' / 'test projection of variable as parameter v3->pv0';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'v3'}]
- Projection:
    name: v3(i,j,k)
    newName: v0
- Projection:
    name: v3(i,j,k)
    newName: pv0
    asParameter: True
- GAMSWriter:
    symbols:
      - name: v0
      - name: pv0
endEmbeddedCode v0 pv0
abort$(abs(v0.l - pv0('level'))>1e-6) 'wrong pv0', v0.l, pv0;

put_utility 'log' / 'test projection of variable as parameter v0.l->q0';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'v0'}]
- Projection:
    name: v0.l
    newName: q0
- GAMSWriter:
    symbols:
      - name: q0
endEmbeddedCode q0
abort$(abs(v0.l - q0)>1e-6) 'wrong q0', v0.l, q0;

put_utility 'log' / 'test projection of variable as parameter v0->pv0';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'v0'}]
- Projection:
    name: v0
    newName: pv0
    asParameter: True
- GAMSWriter:
    symbols:
      - name: pv0
endEmbeddedCode pv0
abort$(abs(v0.l - pv0('level'))>1e-6) 'wrong pv0', v0.l, pv0;

put_utility 'log' / 'test case insensitivity';
embeddedCode Connect:
- GAMSReader:
    symbols: [{'name':'v0'}]
- Projection:
    name: V0.l
    newName: q0
- GAMSWriter:
    symbols:
      - name: q0
endEmbeddedCode q0
abort$(abs(v0.l - q0)>1e-6) 'wrong q0', v0.l, q0;