Application of microsimulation to the modelling of epidemics and terrorist attacks