Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/dzbarsky/bikeshare
Browse files Browse the repository at this point in the history
  • Loading branch information
dzbarsky committed Apr 29, 2015
2 parents 6769552 + 78ef01f commit c2f4996
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions model/model.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
range = [0, 0, 23, 1];
counts = dlmread(TRIPCOUNTS_FILENAME, '', range);

% Start states to rebalance to at each station at each hour
% Expects matrix where each row is an hour and each column is a station
STARTSTATES_FILENAME = 'optimal-allocations.matrix';
start_states = dlmread(STARTSTATES_FILENAME, '');
start_states = round(start_states);

%{
figure
Expand All @@ -57,6 +62,8 @@
cost = (5 * bikes + 7) / 100;
end

rebalanced = 0

% Simulate a single trip that take place in a given hour
function [] = simulate_trip(hour)

Expand Down Expand Up @@ -167,6 +174,16 @@
hour = floor(i / 6);
tripCount = trips_per_tick(hour);
% Simulate each trip that occurred this time tick.

if (mod(i,6) == 0)
for station = 1:STATION_NUM
givenState = start_states(hour + 1, station);
currentState = bikes(station);
rebalanced = rebalanced + abs(givenState - currentState);
bikes(station) = givenState;
end
end

for j = 1:tripCount
simulate_trip(hour);
end
Expand All @@ -189,6 +206,7 @@

end

rebalanced
% bikes;
% unhappy_customers;
% totalCost;
Expand Down

0 comments on commit c2f4996

Please sign in to comment.