Skip to content

added crossover file and updated mutation file#28

Open
Meowwwwwwwwwwwwwwwwwwwww wants to merge 4 commits intomainfrom
mutation
Open

added crossover file and updated mutation file#28
Meowwwwwwwwwwwwwwwwwwwww wants to merge 4 commits intomainfrom
mutation

Conversation

@Meowwwwwwwwwwwwwwwwwwwww
Copy link
Collaborator

updated crossover function and updated mutation file

mutated_sections = []

for section in schedule.keys():
if self.mutate_time_slots_in_section(schedule, section):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please traverse according to the correct chromosome structure.

if len(section_list) < 2:
print(f"Not enough time slots to mutate in section '{section}'.")
class Mutation:
def mutate_time_slots_in_section(self, schedule, section):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should return the mutated chromosome.


Returns:
bool: True if mutation was performed, False otherwise.
"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the mutation rate is missing here. Could you please add it?

mutated_sections = mutate_all_sections(schedule)
# Create an instance of the Mutation class with a mutation rate of 100%
mutation_rate = 1.0
mutator = Mutation(mutation_rate=mutation_rate)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use randomized mutation rate

@@ -1,97 +1,151 @@
import random
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we have mutation2.py with same code as of mutation.py

class ScheduleCrossover:
def __init__(self):
# schedules for week1 and week2
self.week1 = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import from samples.

}

self.new_offspring = None # Will hold the result after crossover

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Add error handling to check if a crossover_day exists in both weeks:
  2. Validate the schedule structure before performing the crossover.(If the structure of week1 or week2 changes,the program could crash ).

# Example weekly schedule
weekly_schedule = {
"Monday": {
"A": [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import chromosomes from samples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants