Out of memory - an alternative to this algorithm?
이전 댓글 표시
I am working on Markov Chain problem involving a large, sparse transition matrix. Unfortunately, in generating the transition matrix as I do, my system quickly runs out of memory. Is my algorithm (seen below) causing this problem unnecessarily early, or is it just the nature of the problem that prevents computation on my system?
n = 5;
L = 0.1;
r = [];
c = [];
s = [];
for i = 1:combinations % combinations the number of combinations in E_perms, a matrix holding (1/L + 1)^n possible states. This can obviously be extremenly large.
state_0 = u(i,:);
[states_1,transition_probs] = transitionProbability(state_0,k,L,E_perms); % A function that generates a vector of possible states after state_0, and the associated probabilites of transitioning to them. Note that only a small subset of all states can be reached from state_0 so the final transition matrix is very sparse.
for ii = 1:size(states_1(:,1))
[~,indx] = ismembertol(states_1(ii,:),u,0.00001,'ByRows', true);
r = [r i];
c = [c indx];
s = [s transition_probs(ii,1)];
end
end
transition_matrix = accumarray([r',c'],s',[],[],[],1);
댓글 수: 1
KSSV
2017년 7월 12일
combinations is not given......a function is also not given..
채택된 답변
추가 답변 (1개)
This note seems to be important:
combinations the number of combinations in E_perms, a matrix holding
(1/L + 1)^n possible states. This can obviously be extremenly large.
For the given data, n = 5, L = 0.1, you get 161'051. Is this "extremely large" already? How large is E_perms and u? What is k? Is transitionProbability a user defined function?
카테고리
도움말 센터 및 File Exchange에서 Sparse Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
