The reactive power compensation optimization in distribution network has the important meaning in maintaining system voltage stability, decreasing network loss and reducing operation costs. In order to meet factual conditions, we assume the system operates in minimum, normal and maximum three load modes and the objective function of problem includes the costs of power loss and the dynamic reactive power compensation devices allocated. In this paper we use Artificial Immune Algorithm(AIA) and Particle Swarm Optimization Algorithm(PSO) to determine compensate nodes and use the back/forward sweep algorithm calculate load flows. After applied into 28-nodes system, the result demonstrates the method is feasible and effective.