When I run this code, all x1 attributes are initialized with the same generated random number. for example, all set to 2!!!
@dataclass
class Position:
x1: int = 0
x2: int = 0
@dataclass
class Particle:
position: Position
pbest: Position
velocity: Position
f : float = 0.0
def initialize():
particles=np.full(20,Particle(Position(),Position(),Position()))
for p in particles:
p.position.x1=random.randint(-5,5)