An Optimization Strategy For Hexapod Gait Transition