using ff2n(n) (two-level full factorial design) with n larger than 25 in my pc results in memory error

조회 수: 2 (최근 30일)
I want to get (two-level full factorial design) or all possible binary combination of number of bits larger than 25 but I get an error (the resulted matrix requires very large size). I want for for example to get the ff2n(30) in more than one matrix to solve this problem. I make my processing in the first matrix then remove that matrix and start processing on next one. I want to use ff2n because it's a very fast built-in function
  댓글 수: 4
dpb
dpb 2022년 2월 10일
>> 2^30 % number rows in design matrix
ans =
1.073741824E+09
>>
>> 2^30*30*8/1024/1024/1024 % memory required to hold one copy, GB
ans =
240
>>
Even if you were to generate only a tiny fraction of the total at a time, it will take some billion iterations and if each consumes only 100 ms of compute time,
>> 2^30*100E-3/60/60/24/365
ans =
3.404812988330796
>>
it would take 3-1/2 years to complete the task.
Mimo T
Mimo T 2022년 2월 14일
I am aware of this issue and my computation time is much less than this.

댓글을 달려면 로그인하십시오.

답변 (1개)

dpb
dpb 2022년 2월 14일
Well, if you really can beat my estimate of the total time per iteration of generating the factors and then doing whatever it is you think you're going to be doing with them to get the final result by several orders of magnitude, then you could theoretically solve the problem, yes. I figured by the time you added in the logic to handle a piece-wise solution and whatever the other calculations are needed using that design matrix, that probably wouldn't be too bad of an estimate.
But, the basic idea isn't too hard; in fact, ff2n is just an m-file implemented by a for...end loop over each column in turn. It is built on the idea that one will be able to hold the whole design matrix in memory, granted, but the logic isn't difficult to build pieces of whatever size you wish -- look at a smaller design matrix to get the drift...
>> ff2n(4)
ans =
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1
>>
As expected, there are sixteen rows (2^4) by the four factors columns.
NB: the first column is simply [0 1] for half of the rows -- 0 for first half, 1 for second. Then, the second column is the same except for each half is split into half. The third is then split yet again until the last column simply alternates levels.
So, you pick whatever size you want to generate at a time and build the associated vector pattern needed for that subsection of each column.
  댓글 수: 3
Mimo T
Mimo T 2022년 2월 15일
@dpb "NB: the first column is simply [0 1] for half of the rows -- 0 for first half, 1 for second. Then, the second column is the same except for each half is split into half. The third is then split yet again until the last column simply alternates levels.
So, you pick whatever size you want to generate at a time and build the associated vector pattern needed for that subsection of each column."
That's what I am trying to make, I tried to edit .m code. I want, for your example, to generate only the first 4 rows, then the second 4 rows untill the last.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by