procedure PreemptiveExternalStabilization
input:  step: current simulation step, agents: the list of agents; maxDifference: a threshold for social model outcome difference;
   minStepsToChange: the minimum number of simulation steps between changes; lastChange: a list with the last
   simulation step when a change was made to the internal model of an agent; environment: the environment of the agents;
   virtSimSteps: number of steps to run the virtual simulation; eps: a very small number; noChanges: the number of changes
   made to the system so far
output: updated noChanges
begin
 virtualEnvironment = Copy(environment)
 RunSimulation(virtualEnvironment, virtSimSteps)
 (stable, lcm) = ExternalStabilityTest(virtualEnvironment)
if not stable then
for each agent in agents do
  difference = modelDifference(, step) − modelDifference(, step − 1)
   if difference < maxDifference and  steplastChange() > minStepsToChange then
  a.SocialModels(a.FirstChoice).Outcome = a.SocialModels(a.SecondChoice).Outcome − eps
   lastChange() = step
   noChanges = noChanges + 1
   end if
end for
end if
return  noChanges
end procedure
Pseudocode 4: Preemptive external stabilization.