Hi everybody,

The idea was to simulate a system of viral infections with random mutations in Mathematica, which I programmed as follows:

...

v1[0] = 1;

v2[0] = 0;

v3[0] = 0;

...

Do[o[t_] = RandomReal[]; a[t_] = RandomReal[];

v1[t_] =

v1[t - 1] + h v1[t - 1] (r (1 + ix) - p x1[t - 1] - q z[t - 1]);

w2[t_] =

v2[t - 1] + h v2[t - 1] (r (1 + ix) - p x2[t - 1] - q z[t - 1]);

w3[t_] =

v3[t - 1] + h v3[t - 1] (r (1 + ix) - p x3[t - 1] - q z[t - 1]);

x1[t_] =

x1[t - 1] +

h (c v1[t - 1] -

u x1[t - 1] (1 + v1[t - 1] + v2[t - 1] + v3[t - 1]));

x2[t_] =

x2[t - 1] +

h (c v2[t - 1] -

u x2[t - 1] (1 + v1[t - 1] + v2[t - 1] + v3[t - 1]));

x3[t_] =

x3[t - 1] +

h (c v3[t - 1] -

u x3[t - 1] (1 + v1[t - 1] + v2[t - 1] + v3[t - 1]));

z[t_] = z[t - 1] + h (( 1 - ix) k - u z[t - 1]);

v2[t_] = If[ w2[t] <= 0 && o[t] > 0.95, a[t], w2[t]];

v3[t_] =

If[ w3[t] <= 0 && o[t] > 0.95 && w2[t] > 0, a[t], w3[t]];

X1[t] = x1[t]; X2[t] = x2[t]; X3[t] = x3[t]; V1[t] = v1[t];

V2[t] = v2[t]; V3[t] = v3[t]; W2[t] = w2[t]; W3[t] = w3[t];

Z[t] = z[t]; U[t] = o[t]; A[t] = a[t], {t, 1, T}];

v[t] is the virus strain and x[t] is the anti-viral reaction (here 3 strains). However, in this case I have to programme each virus mutant a priori, set its value to zero and to a positive value whenever the condition is fulfilled. That implies that for 20 possible mutations I have to write down 20 equations both for x[t] and v[t].

Does anybody know, if there is a way to make Mathematica automatically add two equations to the do function whenever the condition is met?

Thanks!