$title 'Test unload options new with GAMS 24.2' (UNLOAD10,SEQ=614) $onText With GAMS 24.2 some new options for execute_unload were introduced: - option gdxUELs=[squeezed|full]; If gdxUELs is set to squeezed (new default) only the UELs that are required by the exported symbols are exported (compared to all UELs with gdxUELs=full). Also, Aliases should be exported as Aliases and not as Sets anymore. - Execute_UnloadDI This new keyword does not only write the defined symbols to GDX but also the domain sets. Contributor: Lutz Westermann, August 2013 $offText set dummy / d1*d10 / i / i1* i3 /; * Export only i but all UELs option gdxUELs=full; execute_unload 'aFull' i; * Export only i with just the used UELs option gdxUELs=squeezed; execute_unload 'aSqzd' i; execute 'gdxdiff aFull.gdx aSqzd.gdx > %system.nullfile%'; abort$errorlevel 'GdxUELs option should not influenece the content of the written file'; execute 'wc -c aFull.gdx | sed s/a.*// > "%gams.scrdir%aFull.%gams.scrext%"'; execute 'wc -c aSqzd.gdx | sed s/a.*// > "%gams.scrdir%aSqzd.%gams.scrext%"'; $onEchoV > checkSize.gms scalar %fileA% size of %fileA% / $include "%inDir%%fileA%.%gams.scrext%" / %fileB% size of %fileB% / $include "%inDir%%fileB%.%gams.scrext%" /; $if set expectG abort$(%fileA%<=%fileB%) "wrong file sizes"; $if set expectE abort$(%fileA%<>%fileB%) "wrong file sizes"; $offEcho execute 'gams checkSize.gms --inDir="%gams.scrdir%" --fileA=aFull --fileB=aSqzd --expectG=1 lo=%GAMS.lo%'; abort$errorlevel 'GDX file with squeezed UELs should be smaller than the one with full UELs'; * GAMS 24.1 and older wrote aliases as sets * Execute_unload (squeezed) writes aliases as aliases alias (i,j); option gdxUELs=squeezed; execute_unload 'aliasExp.gdx' dummy,i,j; execute 'wc -c aliasAll.gdx | sed s/a.*// > "%gams.scrdir%aliasAll.%gams.scrext%"'; execute 'wc -c aliasExp.gdx | sed s/a.*// > "%gams.scrdir%aliasExp.%gams.scrext%"'; execute 'gams checkSize.gms --inDir="%gams.scrdir%" --fileA=aliasAll --fileB=aliasExp --expectG=1 lo=%GAMS.lo%'; abort$errorlevel 'GDX file with alias should be smaller than GDX file with set'; * This will write a set j and an alias k execute_unload 'rename.gdx' j=k,i=j; set ii(i) / i2*i3 / iii(ii) / i2 / h(ii) / i3 /; * The following exported the second symbol as alias of the first one mistakenly, see #3309 execute_unload "noAlias.gdx", dummy=i, i=dummy; execute "gdxdump noAlias.gdx | grep -iw alias"; abort$(errorlevel=0) 'GDX file noAlias.gdx should not contain an alias'; * Unload with domain information execute_unloaddi 'dom1.gdx' iii; execute_unload 'dom1want.gdx' iii,ii,i; execute 'gdxdiff dom1.gdx dom1want.gdx > %system.nullfile%'; abort$errorlevel 'Execute_unloaddi should write complete domain info'; * If domain is also exported explicitly with another name it will be an alias execute_unloaddi 'dom2.gdx' iii,h,i=k; execute_unloaddi 'dom2want.gdx' iii,h,ii,i,i=k; execute 'gdxdiff dom1.gdx dom1want.gdx > %system.nullfile%'; abort$errorlevel 'Execute_unloaddi should write complete domain info'; * If an alias is used as domain, the alias will be written as set parameter parj(j) /#j 1/; execute_unloaddi 'dom3.gdx' parj; execute_unload 'dom3want.gdx' parj,j; execute 'gdxdiff dom3.gdx dom3want.gdx CmpDomains > %system.nullfile%'; abort$errorlevel 'Execute_unloaddi should write complete domain info'; * If an alias is used as domain, the alias will be written as set and if the * aliased set is defined with itself as domain [k(k)], the alias will be written * as set with itself as domain [ka(ka)]. Set k(k) /k1*k3/; Alias (k,ka); Parameter park(ka) /#k 1/; execute_unloaddi 'dom4.gdx' park; $onEcho > dom4.gms Set ka(ka) /k1*k3/; Parameter park(ka) /#ka 1/; $offEcho execute 'gams dom4.gms lo=%GAMS.lo% gdx=dom4want'; execute 'gdxdiff dom4.gdx dom4want.gdx CmpDomains > %system.nullfile%'; abort$errorlevel 'Execute_unloaddi should write complete domain info'; * If domain conflicts with explicitly exported symbol, we should see an error $onEcho > wantError.gms set i /i/, ii(i) /i/, d /d/; execute_unloaddi 'error.gdx' ii, d=i; $if errorfree $abort 'If domain conflicts with explicitly exported symbol, we should see an error' $clearError $offEcho execute 'gams wantError.gms a=c lo=%GAMS.lo%'; abort$errorlevel 'If domain conflicts with explicitly exported symbol, we should see an error'; * Check that command line gdx export, execute_unload all and execute_unloaddi all lead to the same gdx file $onEcho > expAll.gms set dummy / d1*d10 / i / i1* i3 / ii(i,i) /i2.#i /; alias (i,j,k); execute_unload 'allEU'; execute_unloaddi 'allDI'; $offEcho execute 'gams expAll.gms lo=%GAMS.lo% gdx=allCL'; abort$errorlevel 'Error in expAll.gms'; execute 'gdxdiff allEU.gdx allCL.gdx > %system.nullfile%'; abort$errorlevel 'Execute_unload all and export from command line should create the same GDX file'; execute 'gdxdiff allDI.gdx allCL.gdx > %system.nullfile%'; abort$errorlevel 'Execute_unloadDI all and export from command line should create the same GDX file'; alias (*,u); execute_unload 'uniSqzd' u,i; option gdxUELs=Full; execute_unload 'uniFull' u,i; execute 'gdxdiff uniSqzd.gdx uniFull.gdx > %system.nullfile%'; abort$errorlevel 'Execute_unload containing a universe should write same file squeezed and full';