trajectory optimization using ipopt