I'm a new user and would like to find the minimum value of soln1[30] obtained after repeating the following evaluation (below) for 1000 cycles (for instance). I can obtain sequential values of soln[30] if I reevaluate the entire notebook manually each time, but I want to be able to automate this process until a minimum value of soln1[30] is reached. The difficulty that I am encountering is that the entire notebook requires evaluation in order to generate a different random integer each time- I am having trouble figuring out how to force the evaluation to include the randominteger step using commands like Table, etc. I'm probably missing something simple- any help would be appreciated. Thanks in advance...
Clear[w, t, q, soln1] f1[t_] := 5*t; w = RandomInteger[{1111, 9999}]; a = IntegerDigits[w][[1]]; b = IntegerDigits[w][[2]]; c = IntegerDigits[w][[3]]; d = IntegerDigits[w][[4]]; p = 0.1; k = 0.6; end1 = a; p1 = end1 + p; end2 = p1 + b; p2 = end2 + p; end3 = p2 + c; p3 = end3 + p; end4 = p3 + d; soln1[t_] := Piecewise[{{f1[t], t < end1}, {k*f1[end1], end1 <= t < p1}, {f1'[t]*(t - p1) + k*f1[end1], p1 <= t < epnd2}, {k*f1[end2], end2 <= t < p2}, {f1'[t]*(t - p2) + k*f1[end2], p2 <= t < end3}, {k*f1[end3], end3 <= t < p3}, {f1'[t]*(t - p3) + k*f1[end3], p3 <= t <= 30}}]; soln1[30] 

soln1is intended to do. What do you want to vary and what do you want to keep invariant as you iterate? You can and should eliminate several variables.a, b, c, anddare all produced by RandomInteger[9]. No need for them to be defined outsidesoln1, if at all. $\endgroup$Module,DoandCompoundExpression(;). $\endgroup$