In drilling field, many complex design problem of global optimization problem will appear, the complexity is multivariate, nonlinear, extreme value. The solving of this kind of problem is also the hot and difficult point in the optimization of trajectory, for the well trajectory optimization design and control, many scholars have designed out many algorithms, but there are more or less defects. Take the highest accuracy of the target as the target function and use the artificial fish swarm algorithm and Matlab software to optimize trajectory. The numerical results indicate the correctness and reliability of the algorithm. The algorithm is simple in structure, small amount of calculation and convergence is much better and can quickly get an approximation global optimal solution, so artificial fish optimization algorithm can be used for the optimization design of trajectory. © 2015 ejge.