Assuming that there will always be enough cars issued from the station, consider a one-way direction.
Bus_on_e is the number of cars issued and Bus_on_e - bus_on_s is the number of cars online
Initialization t=0
bus_on_e=0;
bus_on_s=0;
Number of stations station(i)(j)=0 ;
Number of people who will get off at station free(i)(j)=0;
Start (in steps of 6 seconds) (every 6 seconds there will be a possible bus on the line to a particular station)
Number of people who will get off at station change:station(i)(j)= station(i)(j)+p(i)(j)*6
Number of people who will get off at station Change:free(i)(j)=free(i)(j)+f(i)(j)*6
Travel through all the online car locations (does the car arrive at the station bus_opp(i)? = station position) i=bus_on_s:1:bus_on_e
Yes
No
Determine if the car is at the end of the line bus_opp(n)? =end?
Change car position bus_opp(n)+=(6*20/60)
Yes
No
Decrease the number of cars online bus_on_s+=1
Change the number of people on the car Num(n)=Num(n)+station(i)(j)-free(i)(j )
Car stops traveling at end bus_opp(n)=10000
Change car position bus_opp(n)+=(6*20/60)
Calculate the satisfaction rate
Calculate the satisfaction rate
Determine if it's time to depart (shortest interval between departures is 60 seconds) Now-last (previous departure time)? = T (departure interval)
Yes
No
Increase the number of cars bus_on_e+=1, bus_on_e+1 that is, the number of the car
Initialize the car bus_opp(bus_on_e+1)=0;
Initialize the number of the car to the number of people at the first station Num(bus_on_e+1) =station(i)(1)
End: t=60*60*18;