$title 'Test gdxLoad' (LOAD18,SEQ=940) $onText Test execution time function gdxLoad. Contributor: Lutz Westermann, June 2023 $offText $onEcho > data.gms Set i / i1*i3 /; Parameter p(i) / i2 2, i3 3 / err(i,i) / #i.#i 22 / q(i) / #i 11 /; $offEcho $call.checkErrorLevel gams data.gms gdx=data lo=%GAMS.lo% Set i / i1*i2 / err(i); Parameter pInit(i) / i1 1 / pWant(i) p(i), q(i); * By default, gdxLoad replaces existing data p(i) = pInit(i); gdxLoad 'data.gdx', p; pWant('i2') = 2; err(i) = p(i)<>pWant(i); abort$card(err) 'Unexpected p', p, pWant; * Now merge instead of replace p(i) = pInit(i); option replace=off; gdxLoad 'data.gdx', p; pWant('i1') = 1; pWant('i2') = 2; err(i) = p(i)<>pWant(i); abort$card(err) 'Unexpected p', p, pWant; * The default is to read filterd, now try domain check p(i) = pInit(i); option filtered=off; gdxLoad 'data.gdx', p; abort$(execError=0) 'Expected domain violation'; execError = 0; * Now try everything that matches * - p and q should be loaded * - i should be ignored, since it is used as domain set * - err should be ignored since it has a mismatch in the declaration * Note that $onImplicitAssign avoids an error because q did not get assigned explicitly Parameter qWant(i) / #i 11 /; p(i) = pInit(i); option filtered=on; $onImplicitAssign gdxLoad 'data.gdx'; err(i) = p(i)<>pWant(i); abort$card(err) 'Unexpected p', p, pWant; err(i) = q(i)<>qWant(i); abort$card(err) 'Unexpected q', q, qWant;