Reagarding the set command

Iam an amateur LAMMPS user i have build a simulation box with 32000 atoms with the elements CoFeNiPd I want to set each type of element to have 8000 atoms in the simulation box which makes the alloy equi atomic in composition,The following is my code.The problem iam facing is that the majority of the elements in the simulation box are just palladium So may i know what to do to get a simulation box consisting of 25%of each element
units metal
dimension 3
boundary p p p
atom_style atomic
atom_modify map array

---------- Create Atoms ---------------------

lattice fcc 4
region box block 0 20 0 20 0 20 units lattice
create_box 4 box
lattice fcc 4 orient x 1 0 0 orient y 0 1 0 orient z 0 0 1
create_atoms 4 box
#replicate 20 20 20

set region box type/fraction  1 0.25 12541567
set region box type/fraction  2 0.25 12543796
set region box type/fraction  3 0.25 12541522
set region box type/fraction  4 0.25 12145

your logic is flawed. you always select the entire system to convert a 25% fraction into a new type. this will also select atoms that have already been changed.
instead, you have to only select atoms of type 1 for converting to a different type. but then you also have to factor in that the fraction changes, as number of type 1 atoms is reduced and thus the fraction to convert 25% or the total is increasing.