load("Eulix.mac")$

Start:elapsed_real_time()$

n:1000$ p:10$
rx:2.4E-5$ rv:7.4E-4$
sx:0.02$ sy:0.265$
ginf:0.01$
vg:100$ sv:0$
g(v):= ginf*v/(v+100)$
f(v):= 20.0*v/(v+1.0)$

debugmode(true)$
/* :break Eulix$ */
t_final: 12*365+4$

[Solution,y_root]: Eulix([p - sx*x -rx*x*v +g(v)*x,
                          rx*x*v -sy*y -g(v)*y,
                          n*g(v)*y +f(v) -sv*v -(rx+rv)*x*v],[x,y,v],
                          [1000.0,0,1.0],[t,0.0,t_final,1,v-t-245.0],
                          initial_step_size=1,absolute_tolerance=1e-8,logging=true,
                          'tabular='none)$
print("I've used ",elapsed_real_time()-Start,"seconds for computing the AIDS model")$
/* I've used  3.329 seconds for computing the AIDS model */
print("Solution triggered by condition",first(Solution)," at time ",second(Solution),
      "  and state:",third(Solution))$
print("y_root=",y_root)$
t1:second(Solution)$
y_final: Eulix([p - sx*x -rx*x*v +g(v)*x,
                rx*x*v -sy*y -g(v)*y,                                                                          
                n*g(v)*y +f(v) -sv*v -(rx+rv)*x*v],
                [x,y,v],y_root,[t,t1,t_final,1],         
                absolute_tolerance=1e-8,logging=true,
                'tabular='none)$                                     

print("solution at final time",t_final," is ",y_final)$

