I have a Code (a long one), part of it is below. The following piece basically multiplies an adjacency matrix with a vector of equilibrium values. Then tries to pick non-zero elements to be used in other sections of the Code. The entire Code is in DynamicModule with a Manipulate inside since I wanted to simulate the model with different random numbers.
My question is that, although I know "edgeWfinalsimul"my matrix a
exists with positive numbers, I cannot extract those numbers and hence the entire Code fails. The output from "edgeWfinalsimul" is { }.
Hope to receive some guidance. Thanks.
ClearAll[flowSSsimul, flowG0finalsimul, edgeWfinalsimul];
flowSSsimul =
Table[ Normal[G0][[i, j]]*tao[i]*alfa[j]*Subscript[x, i][t], {i, 1,
nn}, {j, 1,
nn} ]; (* \[Equal][Subscript[g, \
(nn,nn)]\[SmallCircle]Subscript[[Subscript[\[Tau], i]Subscript[\
\[Alpha], j]], \
(nn,nn)]\[SmallCircle]Subscript[[Subscript[Overscript[x, ^], i]], \
(nn,nn)]] *)
flowG0finalsimul =
flowSSsimul /.
posSSsimul[[1]]; (* actual flow at the SS based on SS-info stocks \
"posSSsimul[[1]]" *)
edgeWfinalsimul =
Reap[Sow[#, # > 0] & /@ Flatten[flowG0finalsimul];, True][[2]] //
Flatten;(* extracts EdgeWeights of "flowG0finalsimul"*)
where "flowG0finalsimul"The matrix a
is given as follows:
a = {{0, 0, 0, 7.55596 FE`alfa$$1563[4] FE`tao$$1563[1], 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 7.55596 FE`alfa$$$$1563[1], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7.55596 FE`alfa$$1563[19] FE`tao$$1563[1],
0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0.461227 FE`alfa$$1563[14] FE`tao$$1563[3], 0, 0, 0, 0, 0, 0}, {0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0.665655 FE`alfa$$1563[17] FE`tao$$1563[4], 0, 0, 0}, {0, 0, 0, 0,
0, 3.14909 FE`alfa$$1563[6] FE`tao$$1563[5], 0, 0, 0, 0,
3.14909 FE`alfa$$1563[11] FE`tao$$1563[5], 0, 0, 0, 0, 0, 0, 0, 0,
0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3.34426 FE`alfa$$1563[11] FE`tao$$1563[6], 0, 0, 0, 0, 0, 0, 0, 0,
0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0}, {0, 0, 0, 1.66264 FE`alfa$$1563[4] FE`tao$$1563[8],
1.66264 FE`alfa$$1563[5] FE`tao$$1563[8], 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0}, {0, 0., 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0., 0, 0, 0, 0.}, {0, 0, 0, 0, 0, 0, 0,
4.32564 FE`alfa$$1563[8] FE`tao$$1563[10], 0, 0, 0,
4.32564 FE`alfa$$1563[12] FE`tao$$1563[10], 0, 0, 0, 0,
4.32564 FE`alfa$$1563[17] FE`tao$$1563[10], 0, 0, 0}, {0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
1.02967 FE`alfa$$1563[14] FE`tao$$1563[11], 0, 0, 0, 0, 0, 0}, {0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0,
0, 0, 0, 154.893 FE`alfa$$1563[7] FE`tao$$1563[13], 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0,
0.152293 FE`alfa$$1563[6] FE`tao$$1563[14], 0, 0, 0, 0, 0, 0,
0.152293 FE`alfa$$1563[13] FE`tao$$1563[14], 0, 0, 0, 0,
0.152293 FE`alfa$$1563[18] FE`tao$$1563[14], 0, 0}, {0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0., 0, 0, 0, 0,
0, 0., 0., 0, 0., 0., 0, 0, 0, 0., 0, 0,
0.}, {5.96944 FE`alfa$$1563[1] FE`tao$$1563[17], 0, 0, 0, 0, 0, 0,
0, 0, 5.96944 FE`alfa$$1563[10] FE`tao$$1563[17], 0, 0, 0, 0, 0, 0,
0, 5.96944 FE`alfa$$1563[18] FE`tao$$1563[17], 0, 0}, {0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0,
1.93381 FE`alfa$$1563[3] FE`tao$$1563[19], 0, 0, 0, 0, 0, 0, 0, 0,
0, 1.93381 FE`alfa$$1563[13] FE`tao$$$$1563[4], 0, 0, 0}, {0, 0, 0, 0, 0, 3.14909 FE`alfa$$1563[6] FE`tao$$1563[5], 0, 0, 0, 0, 3.14909 FE`alfa$$1563[11] FE`tao$$1563[5], 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.34426 FE`alfa$$1563[11] FE`tao$$1563[6], 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1.66264 FE`alfa$$1563[4] FE`tao$$1563[8], .66264 FE`alfa$$1563[5] FE`tao$$1563[8], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0., 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0., 0, 0, 0, 0.}, {0, 0, 0, 0, 0, 0, 0, 4.32564 FE`alfa$$1563[8] FE`tao$$1563[10], 0, 0, 0, 4.32564 FE`alfa$$1563[12] FE`tao$$1563[10], 0, 0, 0, 0, 4.32564 FE`alfa$$1563[17] FE`tao$$1563[10], 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.02967 FE`alfa$$1563[14] FE`tao$$1563[11], 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 154.893 FE`alfa$$1563[7] FE`tao$$1563[13], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0.152293 FE`alfa$$1563[6] FE`tao$$1563[14], 0, 0, 0, 0, 0, 0, 0.152293 FE`alfa$$1563[13] FE`tao$$1563[14], 0, 0, 0, 0, 0.152293 FE`alfa$$1563[18] FE`tao$$1563[14], 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0., 0, 0, 0, 0, 0, 0., 0., 0, 0., 0., 0, 0, 0, 0., 0, 0, 0.}, {5.96944 FE`alfa$$1563[1] FE`tao$$1563[17], 0, 0, 0, 0, 0, 0, 0, 0, 5.96944 FE`alfa$$1563[10] FE`tao$$1563[17], 0, 0, 0, 0, 0, 0, 0, 5.96944 FE`alfa$$1563[18] FE`tao$$1563[17], 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 1.93381 FE`alfa$$1563[3] FE`tao$$1563[19], 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.93381 FE`alfa$$1563[13] FE`tao$$1563[19], 0, 0, 0, 0, 0, 0,
0}, {0, 0, 0., 0, 0, 0, 0., 0., 0., 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0}};
Now I try to extract all nonzero values with
nonzeroes = Reap[Sow[#, # > 0] & /@ Flatten[a];, True][[2]] // Flatten;
But for some reason, this does evaluate to the empty list {}
.
Hope to receive some guidance. Thanks.