--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at http://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/groups/opt_out.
I think the cleanest approach would be to read in all the data first:
param Xmax = 7000;
param S {J, 1..Xmax, 1..Xmax};
read {t in 1..Xmax, l in 1..Xmax} S["dis",t,l] <Distance.txt;
Then define X and Y to be appropriate integers in the range 1..Xmax:
param Y integer >= 1;
param X integer > Y, <= Xmax;
Then define your model in terms of X and Y and index sets Y..X, and run your loop:
let Y := 1;
let X := 200;
for {1..68} {
solve;
let X := X+100;
let Y := Y+100;
}
If you don't have enough memory to hold all of your data, then you should turn to the previous suggestion to read the file multiple times but discard some of what is read.
Bob Fourer
From: am...@googlegroups.com [mailto:am...@googlegroups.com]
On Behalf Of babu9708011 .
Sent: Monday, February 24, 2014 6:31 PM
To: am...@googlegroups.com
Subject: Re: [AMPL 8082] Re: problem with reading data
Dear Professor Fourer:Thanks a lot for your reply. I am having difficulty with memory space and AMPL exits as I tried with your approach first. Then I implemented it with the other approach (thanks fbahr) and having difficulty with memory problem after some time as below:Error at _cmdno 577674 executing "read" command(file cpff.run, line 43, offset 881):Too much memory used -- 103493363336 bytes; couldn't get 32792 more.Highest address used = 103524425880.Could you please advise me how I can discard some of what is read earlier.
Thanks.Noor
On Wed, Feb 26, 2014 at 10:28 AM, Robert Fourer wrote:
I think the cleanest approach would be to read in all the data first:
param Xmax = 7000;
param S {J, 1..Xmax, 1..Xmax};
read {t in 1..Xmax, l in 1..Xmax} S["dis",t,l] <Distance.txt;
Then define X and Y to be appropriate integers in the range 1..Xmax:
param Y integer >= 1;
param X integer > Y, <= Xmax;
Then define your model in terms of X and Y and index sets Y..X, and run your loop:
let Y := 1;
let X := 200;
for {1..68} {
solve;
let X := X+100;
let Y := Y+100;
}
If you don't have enough memory to hold all of your data, then you should turn to the previous suggestion to read the file multiple times but discard some of what is read.
Bob Fourer
From: am...@googlegroups.com
On Behalf Of babu9708011 .
It's not clear to me why you define
param S {J, 1..Xmax, 1..Xmax};
rather than
param S {1..Xmax, 1..Xmax};
There are already 49 million numbers in {1..Xmax, 1..Xmax} and so if J is has more than the one element "dis" then I can see where an excessive number of parameter values might be created. On the other hand if J has only one element then I don't see why S should need to be indexed over it. How do you actually define and use J in your model?
Bob Fourer
From: am...@googlegroups.com [mailto:am...@googlegroups.com]
On Behalf Of babu9708011 .
Sent: Wednesday, February 26, 2014 3:21 PM
To: am...@googlegroups.com
Subject: Re: [AMPL 8106] Re: problem with reading data
--
As I understand it, you are reading 11 x 7000 x 7000 = 539,000,000 values into parameter S. If you really have 103,524,425,880 bytes on your computer, as your previous error message suggests, then I wouldn't expect "read" to run out of memory. But how much memory do you have?
You could consider extracting just the 70 different 200 x 200 matrices into separate files Distance1.txt, Distance2.txt, ... using a simple program outside of AMPL, and then reading those files in successive passes through the "for" loop. For example:
for {t in 1..70} {
read {t in 1.200, l in 1..200} S["dis",t,l] < ('Distance' & t & '.txt');
solve;
close ('Distance' & t & '.txt');
}
The "close" command isn't normally necessary, but you might need it to prevent the operating system from running out of file descriptors due to the large number of files open.
Bob Fourer
From: am...@googlegroups.com [mailto:am...@googlegroups.com]
On Behalf Of Noor
Sent: Saturday, March 1, 2014 10:04 PM
To: am...@googlegroups.com
Subject: Re: [AMPL 8135] Re: problem with reading data
In my model J has 11 elements and I am using 11 read commands to read all S.
On Behalf Of babu9708011 .
Sent: Wednesday, February 26, 2014 3:21 PM
To: am...@googlegroups.com
Subject: Re: [AMPL 8106] Re: problem with reading data