0% found this document useful (0 votes)
13 views1 page

Schedule File Bus Number Route Name From Stop To Stop Start Time End Time Pas-Sengers From Stop To Stop Start Time End Time Ticketing File

The document outlines a genetic algorithm for optimizing bus schedules, detailing procedures for loading data, calculating fitness, mutating individuals, creating new individuals, and running the genetic algorithm. Key components include managing trip continuity, penalties for overlapping trips, and rewards based on passenger demand. The algorithm iteratively evaluates and improves bus schedules over a specified number of generations.

Uploaded by

Ayush Kishore
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)
13 views1 page

Schedule File Bus Number Route Name From Stop To Stop Start Time End Time Pas-Sengers From Stop To Stop Start Time End Time Ticketing File

The document outlines a genetic algorithm for optimizing bus schedules, detailing procedures for loading data, calculating fitness, mutating individuals, creating new individuals, and running the genetic algorithm. Key components include managing trip continuity, penalties for overlapping trips, and rewards based on passenger demand. The algorithm iteratively evaluates and improves bus schedules over a specified number of generations.

Uploaded by

Ayush Kishore
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/ 1

Algorithm 1 Bus Schedule Optimization using Genetic Algorithm

1: procedure LoadData(schedule file, ticketing file)


2: Load schedule data from schedule file with columns:
3: bus number, route name, from stop, to stop, start time, end time, pas-
sengers
4: Normalize stop names (remove spaces, convert to uppercase)
5: Remove trips where from stop = to stop or start time ≥ end time
6: Load ticketing data from ticketing file
7: Create OD matrix (pivot table: sum passengers for each stop pair)
8: return schedule, OD matrix
9: end procedure
10: procedure FitnessFunction(individual, OD matrix)
11: Initialize total penalty ← 0, total reward ← 0
12: for i ← 1 to length(individual) − 1 do
13: Extract trip segments (f rom stop, to stop, start time, end time)
14: Compute time gap gap ← next start − end time
15: if to stop ̸= next f rom then
16: total penalty ← total penalty + 10000 ▷ Strict continuity
penalty
17: end if
18: if gap < 0 then
19: total penalty ← total penalty + |gap| × 500 ▷ Overlapping trips
penalty
20: else if gap > 2 then
21: total penalty ← total penalty + gap × 50 ▷ Time gap penalty
22: end if
23: Retrieve passenger demand from OD matrix
24: total reward ← total reward + demand
25: end for
26: return (total penalty − total reward)
27: end procedure
28: procedure MutateIndividual(individual)
29: if length(individual) < 2 then
30: return individual
31: end if
32: for each trip in individual do
33: Fix last discontinuity if exists
34: Adjust f rom stop to previous to stop
35: Adjust start time with minor dwell time
36: Maintain duration
37: end for
38: return individual
39: end procedure
40: procedure CreateIndividual(bus group)
41: Initialize empty list route
42: for each row in bus group do
43: Append (f rom stop, to stop, start time, end time, passengers) to
route 1
44: end for
45: return route
46: end procedure
47: procedure RunGA(bus group, OD matrix, ngen, pop size)
48: Initialize DEAP genetic algorithm setup
49: Create initial population
50: for generation g in 1 to ngen do
51: Evaluate fitness of individuals
52: Select individuals for crossover
53: Apply mutation
54: end for
55: Return best individual

You might also like