Condition Based Maintenance: Simulation and Optimization