Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions ABC/PrefrencesABC.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ def calculate_diversity(groups: List[List[Student]]) -> float:
preference_score = 0

for group in groups:
scores = [student.get_score() for student in group]
scores = []
if group[0].experiment:
for i, student1 in enumerate(group):
for student2 in group[i+1:]:
scores.append(student1.get_score(student2))
else:
scores = [student.get_score() for student in group]

if len(scores) > 1: # סטיית תקן מוגדרת רק עבור יותר מנתון אחד
diversity = statistics.stdev(scores)
else:
Expand Down Expand Up @@ -173,7 +180,6 @@ def abc_algorithm_with_prefrences(students: List[Student], num_groups: int, num_
if best_fitness > GLOBAL_MAX_VAL:
GLOBAL_MAX_VAL = best_fitness
GLOBAL_MAX = solutions[scores.index(GLOBAL_MAX_VAL)]
print(f"Iteration {iteration + 1}, Best Fitness: {GLOBAL_MAX_VAL}")

# בסוף, מחזירים את הפתרון הטוב ביותר
return GLOBAL_MAX
3 changes: 0 additions & 3 deletions ABC/StandardABC.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ def abc_algorithm(students: List[Student], num_groups: int, num_iterations: int
solutions[i] = new_sol
scores[i] = calculate_diversity(new_sol)
stagnation[i] = 0
# הדפסת מידע על הדור
best_fitness = max(scores)
print(f"Iteration {iteration + 1}, Best Fitness: {best_fitness}")

# בסוף, מחזירים את הפתרון הטוב ביותר
best_index = scores.index(max(scores))
Expand Down
13 changes: 8 additions & 5 deletions Genetic/PreferencesGenetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ def calculate_diversity(groups: List[List[Student]]) -> float:
preference_score = 0

for group in groups:
scores = [student.get_score() for student in group]
scores = []
if group[0].experiment:
for i, student1 in enumerate(group):
for student2 in group[i+1:]:
scores.append(student1.get_score(student2))
else:
scores = [student.get_score() for student in group]

if len(scores) > 1: # סטיית תקן מוגדרת רק עבור יותר מנתון אחד
diversity = statistics.stdev(scores)
else:
Expand Down Expand Up @@ -188,10 +195,6 @@ def genetic_algorithm_with_preferences(students: List[Student], num_groups: int,
# עדכון האוכלוסייה
update_population(population, fitness_scores, mutated_child)

# הדפסת מידע על הדור
#best_fitness = max(fitness_scores)
#print(f"Generation {generation + 1}, Best Fitness: {best_fitness}")

# מחזירים את הפתרון הטוב ביותר
best_index = fitness_scores.index(max(fitness_scores))
return population[best_index]
4 changes: 0 additions & 4 deletions Genetic/StandardGenetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,6 @@ def genetic_algorithm(students: List[Student], num_groups: int, population_size:
# עדכון האוכלוסייה
update_population(population, fitness_scores, mutated_child)

# הדפסת מידע על הדור
best_fitness = max(fitness_scores)
print(f"Generation {generation + 1}, Best Fitness: {best_fitness}")

# מחזירים את הפתרון הטוב ביותר
best_index = fitness_scores.index(max(fitness_scores))
return population[best_index]
21 changes: 21 additions & 0 deletions experiments/ABC/Iterations_Fitness.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Iteration,AVG Score
1,88.7211497181652
2,88.7211497181652
3,89.1052713126468
4,89.22915077725476
5,89.25699984324228
6,89.53983026739552
7,89.75942600900592
8,90.19848966650157
9,90.19848966650157
10,90.19848966650157
11,90.19848966650157
12,90.28018097627236
13,90.53506593084174
14,90.63147377849803
15,90.63147377849803
16,90.63147377849803
17,90.63147377849803
18,90.790154029262
19,90.95219584823126
20,90.95443689370146
21 changes: 21 additions & 0 deletions experiments/ABC/Iterations_Time.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Iteration,AVG Time
1,0.006540608406066894
2,0.010796785354614258
3,0.01384124755859375
4,0.017898941040039064
5,0.021931099891662597
6,0.026218819618225097
7,0.031563854217529295
8,0.03766334056854248
9,0.037829041481018066
10,0.04230003356933594
11,0.04445006847381592
12,0.050631237030029294
13,0.05401666164398193
14,0.05841057300567627
15,0.06447982788085938
16,0.06548664569854737
17,0.06842453479766845
18,0.0749204158782959
19,0.07750654220581055
20,0.07419106960296631
Loading