Constrained dynamic systems: Generalized modeling and state estimation