Optimal preventive maintenance for coherent systems whose failure occurs due to aging or external shocks