Multiple-phase trajectory optimization for formation flight in civil aviation