An efficient binary optimization method named binary particle swarm optimization (BPSO) algorithm was used to optimize an array of plasmonic nano-rods in order to design an optical switch. In the proposed switch, the optical switch has been excited by two monochromatic incident plan-waves with the same frequency and two angles of incident h = 0 and h = 90. When only the signal with h = 0 is applied, the incident wave is transmitted and when both signals are applied to the switch simultaneously, the coherent perfect absorption occurs and the two incident waves are suppressed. Therefore, the signal with h = 90 acts as control signal. BPSO, a swarm of birds including a matrix with binary entries responsible for controlling nano-rods in the array, shows the presence with symbol of ('1') and the absence with ('0').