saezlab / CARNIVAL

CAusal Reasoning for Network Identification with integer VALue programming in R
https://saezlab.github.io/CARNIVAL/
57 stars 29 forks source link

Memory issues when writing constraints #15

Closed vvvieira closed 3 years ago

vvvieira commented 4 years ago

https://github.com/saezlab/CARNIVAL/blob/7a67f9fd1072ac683407890f40e55c20be09b931/R/write_constraints_6.R#L21

Converting adj from sparse to dense matrix is leading to memory issues on larger problems (>30000 nodes/reactions take up more than 8 Gb).

Since this variable is only needed to identify which rows sum up to 0, line 21 could be removed and this line below could probably replace the idx1 definition, although this is not as efficient as it could be.

idx1 <- where(sapply(1:dim(adj)[1], function(x){sum(adj[x,])}) == 0)

enio23 commented 4 years ago

Indeed using dense matrix can lead to memory issues for very very large PKN's. Can someone test the slution of @skapur on a case study simply by replacing lines 21-23 with the line that Vitor wrote? Then try this out on a couple of examples to be sure this works. However believe that solution given should work.

ivanovaos commented 3 years ago

Fixed in new dev version. No adj matrix is needed anymore.