Learning and Simulation Algorithms for Constraint Physical Systems