Question: procedure to modify initial conditions in dsolve

I am writing a procedure that takes the "output" of a call to dsolve (with the options numeric and listprocedure and without specifying a range of integration) as an argument ('dsol') together with a minimally acceptable range of integration ('tf'). The output of the procedure is either the input 'dsol' itself, if dsolve has been able to integrate from 0 to 'tf', or a modified version where the initial conditions have been modified.

Say I want to integrate an ode system [u,v,w] between 0 and 100 starting from initial conditions [u0,v0,w0]. If dsolve fails to integrate as far as 100, then the procedure will change the initial conditions and try again. The procedure will stop after it has been able to integrate up to 100 without error. (In my problem, I know such initial conditions exist, but I'm having a hard time finding them, so I randomize within the procedure until I find them).

In the example below I have some "best guess" initial conditions [u0,v0,w0]. I consider random deviations from them (using a uniformly distribution). The procedure below is my best shot (for today, it is past bedtime). It doesn't quite work. Hopefully someone will spot the mistake or the missing step. Thanks!

ReInit := proc(dsol,tf::realcons)
    local sol, pts, ini ;
    interface(warnlevel=0) : # error messages still appear
    sol := dsol : # may not be needed, seemed like a good idea at the time
    if rhs(sol(tf)[1]) >= tf then
        return sol ; # if integration successfully reaches tf, then exit and return dsol
    else
        to 10 do  # raise if necessary
            pts := Statistics:-Sample(Uniform(-1e-4,1e-4),3) ; # 1e-4 controls how close to the initial guess I want to search
            ini := [ rhs(sol(0)[2])+pts[1]
                   , rhs(sol(0)[3])+pts[2]
                   , rhs(sol(0)[4])+pts[3]
                   ] ; # these are the modified initial conditions
            sol('initial'=ini) ; # this resets the initial conditions ... does it? My coding errors is about here I think
            if rhs(sol(tf)[1]) >= tf then break; return sol ; end if ; # loop until you can integrate up to tf
                                                                                              # and then return dsol with the new initial conditions
        end do ;
    end if ;
end proc :

To test the procedure, below is a test system:

sol :=
  dsolve(
      [ diff(u(t),t)=u(t)-v(t), diff(v(t),t)=u(t)-w(t), diff(w(t),t)=v(t)-w(t)
      , u(0)=2, v(0)=1, w(0)=2 ]
      , [u(t),v(t),w(t)]
    , 'type' = numeric
    , 'output' = listprocedure
  ) ;

ReInit(sol,100); # modify initial conditions until [u(100),v(100),w(100)] can be reached

Confession: In this test system, the problem is that maxfun is reached, so setting maxfun to a greater value can resolve the error message from this test system. All the same, it can be used to test my procedure. The problem I'm having in my less presentable problem is a "singularity" error message. What happens is that there is a unique converging trajectory, that may be found only with a very good guess of initial conditions, otherwise the following error message appears:


Error, (in unknown) cannot evaluate the solution further left of -141.83038, probably a singularity

Please Wait...