-
Notifications
You must be signed in to change notification settings - Fork 1
/
generateTestParameters.m
50 lines (43 loc) · 1.69 KB
/
generateTestParameters.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function [parameters] = generateTestParameters()
%GENERATETESTPARAMETERS generate a set of parameters for testing
%% setup
SEED = 123;
rng(SEED); % set the random seed for reproducibility
p = struct();
utils = support();
%% given data
p.N = 5; % number of stations
p.T = 3; % number of timesteps
p.C = 1000; % daily budget for incentives
p.lambda = 3; % cost to rebalance a bike manually
p.alphaO = 0.75; % cooperativeness parameter for switching origins
p.alphaD = 0.5; % cooperativeness parameter for switching destinations
p.b = randi([5, 10], p.N, 1); % station capacity
cO = rand(p.N, p.N) * 5;
cD = rand(p.N, p.N) * 2.5;
p.cO = cO(:);
p.cD = cD(:); % incentive required to change origin or desination station
p.s = floor(p.b / 2); % initial number of bicycles at each station
p.dO = populateDemandMatrix(p, -1); % O-D-t travel demand
p.dD = populateDemandMatrix(p, -1); % O-D-t travel demand
p.dOinc = populateDemandMatrix(p, 0); % O-D-t travel demand that has already accepted an incentive
p.dDinc = populateDemandMatrix(p, 0); % O-D-t travel demand that has already accepted an incentive
parameters = p;
end
function [demand] = populateDemandMatrix(p, n)
if n < 0
totalBikes = sum(p.s(:));
else
totalBikes = n;
end
demand = zeros(p.N, p.N, p.T);
while (sum(demand(:)) < totalBikes)
i = randi([1, p.N]);
j = randi([1, p.N]);
t = randi([1, p.T]);
if i ~= j % no demand from station to itself
demand(i, j, t) = demand(i, j, t) + 1;
end
end
demand = demand(:);
end