0% found this document useful (0 votes)
57 views4 pages

Assignment - Dry Run of Genetic Algorithm For Classroom Seating Arrangement

The incremental

Uploaded by

Anas Rizwan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views4 pages

Assignment - Dry Run of Genetic Algorithm For Classroom Seating Arrangement

The incremental

Uploaded by

Anas Rizwan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment: Dry Run of Genetic Algorithm

for Classroom Seating Arrangement


Objective
In this assignment, you will perform a manual dry run of a Genetic Algorithm (GA) to
solve a classroom seating arrangement problem. You will simulate the steps of the GA,
including initial population generation, fitness calculation, selection, crossover,
and mutation, to find an optimal seating arrangement.

Problem Statement
You are tasked with organizing a classroom of 20 students. The objective is to arrange
the students in a 5x4 grid in a way that maximizes collaboration and minimizes
distractions. Some students prefer to sit near certain classmates, while others prefer
not to be seated next to specific students.

Classroom Layout: 5 rows, 4 columns (20 seats).


Constraints:
Collaboration: Certain students prefer to sit next to each other.
Distraction: Certain students should not sit next to each other.
Row preferences: Some students prefer to sit closer to the front or back
of the room.

Steps for the Dry Run


1. Initial Population Generation:

Generate 4 random seating arrangements (individuals) where each student


is assigned a unique seat in the classroom.
You will represent each arrangement as a list of student IDs.

Example:

Individual 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20]
Individual 2: [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5,
4, 3, 2, 1]

2. Fitness Calculation:

Calculate the fitness of each seating arrangement based on:

Number of collaboration preferences satisfied (students sitting


next to preferred classmates).
Number of distractions avoided (students not sitting next to
classmates they prefer to avoid).
Row preferences satisfaction (students sitting in preferred rows).

Example:

Collaboration Pairs: [(1, 2), (5, 6)] → Student 1 prefers to sit


next to Student 2.
Distraction Pairs: [(4, 7), (8, 9)] → Student 4 should not sit
next to Student 7.

3. Selection:

Choose the 2 best-performing seating arrangements based on their fitness


scores to serve as "parents" for the next generation.

4. Crossover:

Perform crossover by combining parts of two parents to create a child


seating arrangement.
For example, split one parent's seating at a random point and combine it
with the other parent's seating.

Example:

Parent 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]


Parent 2: [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
Child: [1, 2, 3, 4, 5, 9, 8, 7, 6, 10]

5. Mutation:

Randomly swap two students' seating positions to simulate mutation.


Example: Swap the seats of Student 3 and Student 7.

6. Repeat:

Perform the process for 3 generations. At each generation, recalculate


the fitness, select the best solutions, and apply crossover and
mutation.

Assignment Task
1. Step 1: Initial Population:

Generate 4 random seating arrangements and write them down. You can make
up random student IDs (e.g., 1 to 20).

2. Step 2: Fitness Calculation:

For each seating arrangement, calculate how many collaboration


preferences are satisfied, how many distraction pairs are avoided, and
how well row preferences are met. Write down the fitness score for each
arrangement.

3. Step 3: Selection:

Based on the fitness scores, select the 2 best seating arrangements to


be the parents for the next generation.

4. Step 4: Crossover:

Combine the seating arrangements of the two parents to create a child


arrangement.

5. Step 5: Mutation:
Apply mutation by swapping the positions of two randomly chosen
students.

6. Step 6: Repeat for 3 Generations:

Repeat the steps for 3 generations. After each generation, recalculate


the fitness, select the best seating arrangements, and perform crossover
and mutation.

Example of a Dry Run


Generation 1: Initial Population
Individual 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20]
Individual 2: [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3,
2, 1]
Individual 3: [5, 10, 1, 8, 9, 15, 4, 2, 7, 13, 6, 3, 20, 18, 16, 17, 14, 12,
19, 11]
Individual 4: [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15,
17, 19]

Fitness Calculation:
Fitness of Individual 1: Collaboration pairs satisfied = 2, Distraction pairs
avoided = 1, Row preferences met = 3 → Fitness = 6
Fitness of Individual 2: Collaboration pairs satisfied = 0, Distraction pairs
avoided = 0, Row preferences met = 2 → Fitness = 2
Fitness of Individual 3: Collaboration pairs satisfied = 3, Distraction pairs
avoided = 2, Row preferences met = 1 → Fitness = 6
Fitness of Individual 4: Collaboration pairs satisfied = 1, Distraction pairs
avoided = 2, Row preferences met = 2 → Fitness = 5

Selection:
Select Individual 1 and Individual 3 as the parents for crossover.

Crossover:
Split both parents' seating arrangements and combine them to form a new child.

Parent 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Parent 2: [5, 10, 1, 8, 9, 15, 4, 2, 7, 13]

Child: [1, 2, 3, 4, 5, 15, 4, 2, 7, 13]

Mutation:
Swap the positions of two randomly chosen students.
Mutated Child: [1, 2, 3, 7, 5, 15, 4, 2, 4, 13]

Generation 2: Repeat the Process


Continue the process for 2 more generations. After each generation, calculate
fitness, perform selection, crossover, and mutation.
Deliverables:
Submit a step-by-step dry run for 3 generations of the Genetic Algorithm.
Clearly show:
1. Initial population (seating arrangements).
2. Fitness calculations for each individual.
3. Selection of parents.
4. Crossover and mutation for new children.
5. Final seating arrangement after 3 generations.

You might also like