.inc files Topic is solved

Problems with syntax of GAMS
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: .inc files

Post by Renger »

Hi
Everything works fine. You might be thinking that it doesn't work because the checking takes some time. Just try to read in a parameter in excel that fills a complete sheet, then you will notice the difference.

Code: Select all

$call gdxxrw.exe i=input.xlsx set=d rng=dem_price!a2 rdim=1 cdim=0 CheckDate
$gdxin input.gdx
Output in the console with the line "No new file written (CheckDate is active):

Code: Select all

--- call gdxxrw.exe i=input.xlsx set=d rng=dem_price!a2 rdim=1 cdim=0 CheckDate

GDXXRW           24.9.1 r63795 Released Aug 30, 2017 VS8 x86 32bit/MS Windows 
Input file : c:\Users\renge\Downloads\input.xlsx
Output file: c:\Users\renge\Downloads\input.gdx
No new file written (CheckDate is active)
Total time = 1453 Ms
--- GDXin=c:\Users\renge\Downloads\input.gdx
--- Starting execution: elapsed 0:00:01.600
*** Status: Normal completion
--- Job Untitled_16.gms Stop 11/01/18 07:52:04 elapsed 0:00:01.601
 
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
ferrib
User
User
Posts: 14
Joined: 5 years ago

Re: .inc files

Post by ferrib »

Hi Renger,

I checked the log and you are right CheckDate is working. I guess it is me who is using GDX in a wrong way. If i input many parameters using similar code will end up only saving the last parameter on GDX:

Set g;
$call gdxxrw.exe i=input.xlsx set=g rng=Bid_EN_price_gen_sell!a2 rdim=1 cdim=0
$gdxin input.gdx
$load g
$gdxin
display g;

Set d;
$call gdxxrw.exe i=input.xlsx set=d rng=Bid_EN_price_dem_buy!a2 rdim=1 cdim=0
$gdxin input.gdx
$load d
$gdxin
display d;

I will need to spend some time browsing the help files for GDX.

Thanks.
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: .inc files

Post by bussieck »

CheckDate checks if the GDX file is newer than the Excel file. But it should also contain the right parameters, so a code that uses the same GDX for different symbols together with CheckDate will never work. If you use different GDX names (using the output= parameter) you will be fine:

Code: Select all

$call gdxxrw.exe i=input.xlsx output=input_g set=g rng=Bid_EN_price_gen_sell!a2 rdim=1 cdim=0 CheckDate
$gdxin input_g.gdx
$load d
$call gdxxrw.exe i=input.xlsx output=input_d set=d rng=Bid_EN_price_dem_buy!a2 rdim=1 cdim=0 CheckDate
$gdxin input_d.gdx
$load d
You can improve the Excel reading significantly by reading multiple symbols in one gdxxrw. gdxxrw works in combination with Excel. So each individual call to gdxxrw opens (with Excel in background) your workbook input.xlsx. Depending on the size of this workbook this can take significant time. By batching the gdxxrw reading requests together and calling gdxxrw once you only open the workbook once. gdxxrw alllows you to put multiple requests in one call:

Code: Select all

$call gdxxrw.exe i=input.xlsx set=g rng=Bid_EN_price_gen_sell!a2 rdim=1 cdim=0 set=d rng=Bid_EN_price_dem_buy!a2 rdim=1 cdim=0 CheckDate
$gdxin input.gdx
$load g d
If you have many symbols to read you should use a parameter file and provide the filename with a @ sign (see gdxxrw docs at https://www.gams.com/latest/docs/T_GDXXRW.html):

Code: Select all

$onEcho > input.txt
i=input.xlsx
set=g rng=Bid_EN_price_gen_sell!a2 rdim=1 cdim=0
set=d rng=Bid_EN_price_dem_buy!a2 rdim=1 cdim=0
$offecho
$call gdxxrw.exe  @input.txt  CheckDate
$gdxin input.gdx
$load g d
-Michael
ferrib
User
User
Posts: 14
Joined: 5 years ago

Re: .inc files

Post by ferrib »

Thanks Michael, works like a charm!
Post Reply