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

Line 55, 556 in Road_network_sim.m #3

Open
TronYY opened this issue Nov 4, 2022 · 8 comments
Open

Line 55, 556 in Road_network_sim.m #3

TronYY opened this issue Nov 4, 2022 · 8 comments
Assignees
Labels

Comments

@TronYY
Copy link

TronYY commented Nov 4, 2022

Dear authors,

Thanks for your last reply, I can study the prediction module.

Here, I have questions about Line 552, 556 in Road_network_sim.m.
Line 552: Passengers.FlowsIn(1:predleftin,:) = Passengers.FlowsIn(1:predleftin,:); + double(FlowsIn{currentTime}(1:predleftin,:));
Line 556: Passengers.FlowsOut(1:predleftout,:) = Passengers.FlowsOut(1:predleftout,:) + double(FlowsOut{currentTime}(1:predleftout,:));

The number of rows in Passengers.FlowsIn and Passengers.FlowsOut is both horizon, i.e., 50 (For convenience, I only use FlowsIn to illustrate), which means 50 timesteps in 5 min.

Passengers.FlowsIn with shape (50*66) means how many cars will arrive at each station in the future 5min.

The number of rows in FlowsIn{currentTime} is the number of car arriving time buckets, where these cars start in the future 2h (25 timesteps, 2h/5min) form currentTime.

FlowsIn is loaded from GoodPrediction.ipynb. FlowsIn{currentTime} with shape (#time_bucket_arrival * 66) means from now (currentTime), in the future some time buckets, how many cars will arrive at 66 stations.

So the meaning of row in Passengers.FlowsIn and FlowsIn{currentTime} is different. Why the two variables can be directly added in Line 552?

Thank you.

@federico3
Copy link
Collaborator

federico3 commented Nov 6, 2022

@huevosabio , do you have a moment to take a look at this? Sorry to bother you!

If I understand correctly, the concern is that the units of Passengers.FlowsIn are "passengers per 6s time step", whereas the units of FlowsIn{currentTime} are "cars per 5-minute time step".

@TronYY
Copy link
Author

TronYY commented Nov 7, 2022

@huevosabio , do you have a moment to take a look at this? Sorry to bother you!

If I understand correctly, the concern is that the units of Passengers.FlowsIn are "passengers per 6s time step", whereas the units of FlowsIn{currentTime} are "cars per 5-minute time step".

Yes, this is my concern.

@huevosabio
Copy link
Owner

Hey @TronYY , allow me a couple of days to look at this, it's been 5 years and a quick glance doesn't yield a quick answer :)

@TronYY
Copy link
Author

TronYY commented Nov 8, 2022

Hey @TronYY , allow me a couple of days to look at this, it's been 5 years and a quick glance doesn't yield a quick answer :)

Dear authors,

Maybe I misunderstood the meaning of the variable horizon.

predleftin of Passengers.FlowsIn(1:predleftin,:) = Passengers.FlowsIn(1:predleftin,:); + double(FlowsIn{currentTime}(1:predleftin,:)); is defined in Line 545 of Road_network_sim.m :
predleftin = min(size(FlowsIn{currentTime},1), horizon),

where horizon is defined in Line 94:
predictionStep = 5*timeStep; % number of steps a prediction covers
horizon = 50; % longest travel time is 44 steps...

Here maybe I confused horizon and rebalancing horizon Thor = 5 timeStep = 5min. horizon here is MPC planning horizon and it is 50 * predictionStep = 50 * 5 * timeStep =250 timeStep= 4.17 hour. Right?
Then the units of Passengers.FlowsIn are "cars per 5-minute time step", the same as the units of FlowsIn{currentTime}, instead of " cars per 6 seconds". Then the plus in Line 552 makes sense.

@federico3
Copy link
Collaborator

I think this is highly plausible. Thank you for making your way through the code! Definitely a lesson on why one should document code - I promise we're better developers now!

@TronYY
Copy link
Author

TronYY commented Dec 31, 2022

Dearf authors,

Bother you again. Could you explain the Line 159 f_cost(FindSourceRelaxti(t,i)) = SourceRelaxCost*( 1 / (1.2 ^ (t-1)) ); in ModelPredictiveReb.m invoked by Road_network_sim.m(with LSTM predictor).

Why the dropping cost here is SourceRelaxCost*( 1 / (1.2 ^ (t-1)) )?

Since in MPC_MCF.m invoked by Road_network_sim_v2.m(with perfect/empty predictor), the dropping cost here is f_cost(FindDropPaxtij(t,i,j))= SourceRelaxCost; (Line 129). Here the dropping cost is consistent with your paper.

Thank you! Happy new year!

@federico3
Copy link
Collaborator

Sorry I missed this! This is to acknowledge that I saw your message, let me look into it in the coming days. It's really a Ramon question, but I will try to better understand what is happening here.

@federico3 federico3 reopened this Mar 21, 2023
@federico3
Copy link
Collaborator

federico3 commented Mar 22, 2023

Wow, looking at this code was a trip down memory lane. I have no firm answers, but a few suspicions.
My first guess is that the actual code used for the simulations was Road_network_sim_v2.m, for both the empty predictor and the LSTM predictor. To use Road_network_sim_v2 with the LSTM predictor, you would load('lstm_predictions.mat') instead of of ignored_assets/tod_predictions_empty.mat, and change SIMNAME appropriately.

We should have really had a single toggle to choose the sim name and load the right predictions accordingly, but alas.

In line with this, my guess is that ModelPredictiveReb was deprecated in favor of MPC_MCF. I would recommend using Road_network_sim_v2.m and changing the files that are loaded to try and reproduce the results in our paper.

The SourceRelaxCost in ModelPredictiveReb was probably an attempt at discounting costs with time, pushing the solver to care more about the present. It's a pretty standard thing to do, but I see we did not mention in the paper, which would make sense if we dropped it from the final formulation.

Again, this is a guess based on maybe 30 minutes of perusing code I wrote 6 years ago, so it may be incorrect. Sorry you have to wade through this code!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants