No Differentiation (ไม่มีความแตกต่าง)
ก่อนที่เราจะรัน simulation เราต้องกำหนดพฤติกรรมของ choose_dead และ choose_replacements ก่อน เราจะเริ่มจากเวอร์ชันง่าย ๆ ของฟังก์ชันเหล่านี้ที่ไม่ได้พึ่งพา fitness:
# class Simulation
def choose_dead(self, fits):
n = len(self.agents)
is_dead = np.random.random(n) < 0.1
index_dead = np.nonzero(is_dead)[0]
return index_dead
ใน choose_dead นั้น n คือจำนวน agents และ is_dead คือ boolean array ที่มีค่า True สำหรับ agents ที่ตายใน time step นี้ ในเวอร์ชันนี้ agent ทุกตัวมีโอกาสตายเท่ากัน: 0.1 choose_dead ใช้ np.nonzero เพื่อค้นหา index ของสมาชิกที่ไม่เป็นศูนย์ของ is_dead (True ถือว่าไม่เป็นศูนย์)
# class Simulation
def choose_replacements(self, n, fits):
agents = np.random.choice(self.agents, size=n, replace=True)
replacements = [agent.copy() for agent in agents]
return replacements
ใน choose_replacements นั้น n คือจำนวน agents ที่สืบพันธุ์ใน time step นี้ มันใช้ np.random.choice เพื่อสุ่มเลือก agents จำนวน n ตัวแบบใส่คืนได้ (with replacement) จากนั้นเรียก copy บนแต่ละตัว และคืนค่ารายการของ object Agent ตัวใหม่
เมธอดเหล่านี้ไม่ได้ขึ้นกับ fitness ดังนั้น simulation นี้จึงไม่มีการอยู่รอดหรือการสืบพันธุ์ที่แตกต่างกัน ผลที่ตามมา เราควรจะไม่เห็นวิวัฒนาการ แต่เราจะรู้ได้อย่างไร?