# Dynamic Demand-Responsive Feeder Bus Network Design for a Short Headway Trunk Line
## 3 Methodology
### Algorithm
```
Step 0: Initialization:  Set s=1, Best Cost=positive infinite, \(T\)=\(T_{0}\), alpha=0.99, previous station help=0, next station help=0, vehicle (\(s\); \(s\); 1 to \(S\))=4, min vehicle(\(s\); \(s\); 1 to \(S\)) = 0 Step 1: Clustering: Define passenger's cluster Step 2: Create random solution  Considering the length of trip (number of passengers (\(s\)) +vehicles(\(s\))-1) Step 3: Sort the initial solution based of desired departure time of passengers for each feeder bus set x as a random solution Step 4: Find optimal solution:  If It!=\(t\)!t!tmax, THEN  go to step 5, otherwise go to step 7 END IF Step 5: IF #12\(\times\)12 max, THEN  go to step 5.1, otherwise go to step 6 END IF Step 5.1: Creating neighborhood:  set x_new_ = a neighborhood of \(x\) Step 5.2: Run Path Creator Algorithm Step 5.3: IF best cost for x \(\times\) best cost for x_new, THEN  set x=x_new_ and go to step 5.6, otherwise go to step 5.4 END IF Step 5.4: p = exp(-cost x_new_ - cost x)/\(T\)-Cost x Step 5.5: Accept x = x_new_ by -probability and reject- and \(x\)= x_new_ by (1-p) and go to step 5.6 Step 5.6: Cost calculation for x_new_ - best_ 5.7: IF best cost for x_new_ - best cost, THEN  set bestbest= x_new  END IF Step 5.8: IF x_new_ is feasible (considering time ratio), and best cost for x_new_ - feasible_best cost, THEN  set feasible_bestbest= x_new  END IF Step 5.9: Reducing the temperature:  set \(T\)= alpha-70 (0-alpha=1) Step 5.10: set I2=I2=I2+1 and go to step 5 Step 6: Set It!=1!t!t+1 and go to step 4 Step 7: IF feasible_bestso is empty, THEN  min vehicle (\(s\))= vehicle (\(s\))+1 and go to step 8, otherwise go to step 15 END IF Step 8: Calculate the following proportion for stations \(s\)-1 and \(s\)+1: number of passengers (s)/vehicle(s) Step 9: IF \(s\)-1 exists and vehicle (s-1)> min vehicle (\(s\)-1), THEN  go to step 10, otherwise go to step 12 END IF Step 10: IF proportion for station \(s\) is \(\leq\) the proportion for station \(s\)+1 or vehicle (\(s\)+1) \(\leq\) min vehicle (\(s\)+1) go to step 11, otherwise go to step 12 END IF Step 11: Set previous station help (\(s\))= previous station help (\(s\))+1 and vehicle (\(s\)-1) = vehicle (\(s\)-1)-1, \(s\)=-1, and go to step 2 Step 12: IF \(s\)+1 exists and vehicle (\(s\)+1)> min vehicle (\(s\)+1) THEN  go to step 13, otherwise go to step 14 END IF Step 13: Set next station help (\(s\))= next station help(\(s\))+1 and vehicle (\(s\)+1) = vehicle (\(s\)+1)-1 and go to step 2 Step 14: Show \"The problem is not feasible; more vehicles is needed\" Step 15: IF \(s\)<5, THEN  set s=s+1 and go to step 2, otherwise go to step 16 END IF Step 17: END
```  
**Algorithm 1**Pseudocode for the developed SA algorithm to solve the model  
```
Step 1: Initialization:  Set s=1, Best Cost=positive infinite, \(T\)=\(T_{0}\), alpha=0.99, previous station help=0, \(\text{\sc}\Figure 2: The developed SA algorithm to solve the model. ```
Step 0: Initialization:  Set _used_capacity=0, maximum_used_capacity =0, c Step 1: Calculate updated latest pickup time of passengers based on the sequence of passengers Step 2: Add the first passenger to the path Step 3: Update total traveled distance  Total traveled distance  Total traveled distance = Distance to current passenger Step 4: Iarrival time to current passenger > Earliest pick up time of the passenger Arrival time to the passenger = traveled distance/sped, else The vehicle should wait for the passenger  Arrival time to the passenger = Earliest pick up time of the passenger END IF Step 5: Update time Time = Arrival time to the current passenger Step 6: Update used_capacity  used_capacity = 1  end: Step 7: Update maximum_used_capacity  IF used_capacity > maximum_used_capacity  maximum_used_capacity = 1  end:
```

**Algorithm 2**Pseudocode for the developed SA path creator algorithm

Figure 3: The path creator algorithm.