MODULE ProiePred; IMPORT SIM, EVENT, CONT; FROM MYINOUT IMPORT WriteLn, WriteLongReal, WriteString, ReadLongReal, OpenInput, OpenOutput, CloseInput, CloseOutput; FROM EVENT IMPORT EventType; FROM CONT IMPORT VarCont, Value, SelectMethod, Method, StartInteg; VAR r, c, s, d, x0, z0 : LONGREAL; (* Parametres du modele. *) x, z : VarCont; (* Nb. de proies et de predateurs. *) Duree : LONGREAL; (* Duree de la simulation. *) FinSim : EventType; (* Fin de la simulation. *) UnPas : EventType; (* Evenement execute a chaque pas. *) PROCEDURE ProcFinSim; BEGIN SIM.Stop END ProcFinSim; PROCEDURE ProcUnPas; BEGIN WriteLongReal (SIM.Time (), 4, 12); WriteString(" ") ; WriteLongReal (Value (x), 4, 12); WriteString(" ") ; WriteLongReal (Value (z), 4, 12); WriteLn; END ProcUnPas; PROCEDURE Dx (t : LONGREAL) : LONGREAL; BEGIN RETURN r * Value (x) - c * Value (x) * Value (z) END Dx; PROCEDURE Dz (t : LONGREAL) : LONGREAL; BEGIN RETURN - s * Value (z) + d * Value (x) * Value (z) END Dz; BEGIN OpenInput (".DAT"); OpenOutput (".RES"); ReadLongReal (r); ReadLongReal (c); ReadLongReal (s); ReadLongReal (d); ReadLongReal (x0); ReadLongReal (z0); ReadLongReal (Duree); EVENT.Create (UnPas, ProcUnPas, "Un pas d'integration"); EVENT.Create (FinSim, ProcFinSim, "Fin de la simulation"); EVENT.Schedule (FinSim, Duree, NIL); CONT.Create (x, x0, Dx, NIL); CONT.Create (z, z0, Dz, NIL); SelectMethod (RungeKutta4, 5.0); StartInteg (x, UnPas, NIL); StartInteg (z, EventType (NIL), NIL); SIM.Start; CloseInput; CloseOutput END ProiePred.