This model can be used to see if you can allocate say 2 GB of memory.
$ontext Check if memory can be allocated erwin@amsterdamoptimization.com $offtext * specify limit in MB * e.g. 2 GB = 2000 scalar maxmem / 2000 /; set i 'keep small to reduce memory here' /i1*i100/; alias (i,i1,i2,i3,i4,i5); parameter p(i,i,i,i,i); loop((i1,i2,i3)$(heapsize<maxmem), p(i1,i2,i3,i4,i5) = 1; ); scalar numcells "number of cells we could allocate (million)"; numcells = card(p)/1e6; scalar percell "approx bytes per cell"; percell = floor(heapsize/numcells); display numcells,percell; |
This is written in response to issue 1 in http://yetanothermathprogrammingconsultant.blogspot.com/2010/05/linux-issues.html.
As an aside it will print the number of bytes per nonzero element in a parameter. As GAMS stores all data sparse, this number is larger than 8 bytes. For 32 bit GAMS systems this number can be 24 bytes per nonzero and for 64 bit systems 32 bytes per nonzero can be expected (pointers need 64 bits instead of 32 bits so memory per cell goes up).
Notes:
- If your machine does not have > 4GB of memory, you can probably solve larger models using 32 bit GAMS on 64 bit Linux
- GAMS reports MB’s as 1000 × 1000 bytes. Other tools may use 210=1024 in this calculation.
No comments:
Post a Comment