Mathematical Modelling And Optimal Control Of Constrained Systems