Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi mode clean #20

Open
wants to merge 44 commits into
base: communication-edit
Choose a base branch
from
Open

Multi mode clean #20

wants to merge 44 commits into from

Conversation

Xuan-1998
Copy link
Owner

No description provided.

Xuan Jiang and others added 30 commits July 18, 2024 12:52
…List and Dict general struct, add person struct and transfer point struct
newTrafficVehicleVec.push_back(vehicle);
}

newTrafficPersonVec.push_back(person);

Choose a reason for hiding this comment

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

Add dep_time into the vehicles. whether bus or auto.

@@ -213,6 +213,12 @@ void BPMTrafficPerson::randomPerson(int p, BTrafficPeople &people,
people.T[p] = 2.0f + 3.0f * (((float)qrand()) / RAND_MAX); //time heading 2.0-3s
}


if (carType == 2) { //bike car
Copy link
Owner Author

Choose a reason for hiding this comment

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

@Luze, what's this for? Did you add this when we need a bike? Should we delete this for now? AFAIK our simulation is not using this cpp file

// }
//}

return all_od_pairs_sets;
Copy link
Owner Author

Choose a reason for hiding this comment

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

Does this include both bus routes and vehicle routes?


}

for (size_t i = 0; i < busRoutes.size(); ++i) {
Copy link
Owner Author

Choose a reason for hiding this comment

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

@SLZ0106 This should be reading trip ID, and use the new bus_shcedule file Junzhe

ushort state;
ushort stateLine;
ushort totalInOutEdges;
uint edge[24];// up to six arms intersection
float nextEvent;
LNode* passengers;
Copy link
Owner Author

Choose a reason for hiding this comment

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

Should be changed into Dnode @YiboZh

struct B18TrafficPerson{
int id;
Node* transferPoints; //should take which bus line and drop at which intersection
float time_departure;
Copy link
Owner Author

Choose a reason for hiding this comment

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

TODO: This will be put into Dnode, so it will be deleted here @YiboZh

std::vector<std::array<abm::graph::vertex_t, 2>> all_od_pairs_without_mode;
all_modes.reserve(all_od_pairs_.size());
all_od_pairs_without_mode.reserve(all_od_pairs_.size());
for (const auto& od_pair_with_mode : all_od_pairs_) {
Copy link
Owner Author

Choose a reason for hiding this comment

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

all_modes will be used for replacing mode in .cu while running simulation

@@ -277,7 +365,21 @@ const std::vector<abm::graph::edge_id_t> B18TrafficSP::loadPrevPathsFromFile(
return const_paths_SP;
}

//merge multi path into one path
Copy link
Owner Author

Choose a reason for hiding this comment

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

TODO: When we are outputting the things from the simulator, we need to change the things to be output in people and route file.

@@ -204,14 +218,37 @@ void savePaths(const std::vector<personPath>& paths, const std::string& filename
file << personPathToString(path) << "\n";
}
}
std::vector<int> findBuses(
const std::vector<std::vector<int>>& busRoutes,
Copy link
Owner Author

Choose a reason for hiding this comment

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

to be deleted

@@ -539,11 +599,22 @@ void B18TrafficSimulator::simulateInGPU(const int ngpus, const int numOfPasses,
float totalNumSteps = 0;
float totalCO = 0;

std::ofstream outFile("output_time_diff.csv", std::ios::app);
Copy link
Owner Author

Choose a reason for hiding this comment

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

why we need this?

Copy link
Owner Author

Choose a reason for hiding this comment

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

for travel time

@@ -183,6 +243,73 @@ void b18InitCUDA_n(
for(int i = 0; i < ngpus; i++){
cudaStreamCreate( &streams[i]);
}

// Initialize people and vehicles
Copy link
Owner Author

Choose a reason for hiding this comment

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

newTrafficPersonVec.push_back(person);
}

for (size_t i = 0; i < busRoutes.size(); ++i) {
Copy link
Owner Author

Choose a reason for hiding this comment

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

vehicle and how it will follow its route?

Copy link
Owner Author

Choose a reason for hiding this comment

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

TODO: Auto follows original path, bus follows bus route @YiboZh

@@ -296,6 +421,22 @@ void b18InitCUDA_n(
// gpuErrchk(cudaMemPrefetchAsync(trafficLights_d, sizeT, 1, streams[1]));

}

Copy link
Owner Author

Choose a reason for hiding this comment

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

Dnode要初始化departure time

}

/*Add transfer function to simulate people change from a bus to another bus*/
__device__ void transferToNewVehicle(
Copy link
Owner Author

Choose a reason for hiding this comment

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

For bus to Auto

Copy link
Owner Author

Choose a reason for hiding this comment

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

TODO: new vehicle's bus should be initialized outside kernal

Copy link
Owner Author

Choose a reason for hiding this comment

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

potential solution: get route from person struct

Node* passengers; // a list of persons, key is the intersection id, value is the list of persons to drop off

//save travel time
float time_diff;
Copy link
Collaborator

@YiboZh YiboZh Aug 25, 2024

Choose a reason for hiding this comment

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

Move to person struct

@@ -2097,10 +2491,11 @@ void b18SimulateTrafficCUDA(float currentTime,
cudaSetDevice(i);
int numPeople_gpu = vehicles_vec[i]->size();
LC::B18TrafficVehicle* vehicles_ptr = thrust::raw_pointer_cast((*vehicles_vec[i]).data());
LC::B18TrafficPerson* person_ptr = trafficPerson_d;
Copy link
Collaborator

Choose a reason for hiding this comment

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

person_vec


struct B18TrafficPerson{
int id;
Node* transferPoints; //should take which bus line and drop at which intersection
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add num_step to this property to track travel time.
To be fix: init the first segment of trip in transfer point to save travel time

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