I would like to solve my birth and death problem.
SeedRandom[124] With[{λ = 3, μ = 2, initialPopulation = 10, numOfReaction = 5, numOfSim = 1}, ListLinePlot[ sim = birthDeath[λ, μ, initialPopulation, numOfReaction], InterpolationOrder -> 0, PlotStyle -> {Black, Thick}, Frame -> True, GridLines -> Transpose@sim, FrameLabel -> {"Time", "Population"}, ImageSize -> 300]]
And one possible path is
sim={{0, 10}, {0.168871, 9}, {0.824082, 10}, {0.92576, 11}, {0.956336, 12}, {1.06251, 11}}
Differences@sim[[All, 1]]
deltaT={0.168871, 0.655211, 0.101678, 0.0305756, 0.106177}
after 0.168871s there is a death but it could be a birth and after 0.655211s there is birth but it could be death and so on.
Initial population is 10 and end up with population 11 after some number of birth and death.Number of reaction is constant which is 5 in this case namely 2 death, 3 birth. I would like to find All path between initial population and last population. I thought I can use Graph and find all path that satisfy the condition.
Do you think it is better to use Linear Integer Programming? Total population cannot be negative. Sum of #birth and #death=last population-initial population. birth and death are integer.
Assume I have $ 5\times5$ GridGraph
. I would like to find all path (not necessarily shortest ) under some condition.
- Start from initial population and always move to Right, Up Or Down at the beginning.
- You cannot move Right and Right consecutively. Meaning that after Right either move UP or Down if possible.
- Never move Left.
Here is the sample code I got from Help page which violets some rules I have.
s = 1; t = 16; g = GridGraph[{4, 4}, VertexSize -> {s -> Medium, t -> Medium}] path=FindPath[g, s, t, {GraphDistance[g, s, t]}, All] HighlightGraph[g, PathGraph[#]] & /@ path