Modeling, simulation, sensitivity analysis, and optimization of hybrid systems