-
Notifications
You must be signed in to change notification settings - Fork 0
/
trajectory.m
31 lines (28 loc) · 888 Bytes
/
trajectory.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
function [time,trajectory] = trajectory(d,theta,lambda,time0,delta_t,Q)
% generate the trajectory of inventory levels
% input parameter:
% theta: deteriorating rate
% d: initial demand
% lambda: a parameter governing the decreasing rate of the demand
% time0: the time of order arrival
% delta_t: the time resolution
% Q: the order quantity
% output parameter
% time: sampling time
% trajectory: inventory level
% calculate order cycle based on order quantity
T=Q2T(d,theta,lambda,Q);
% the moment when the inventory drops to 0
tT=time0+T;
% generate sampling time with time resolution as the step size
time=[time0:delta_t:tT]';
% two case
if theta == lambda
% if theta == lambda
trajectory=d*exp(-theta.*(time-time0)).*(tT-time);
else
% when theta != lambda
par=d/(theta-lambda);
trajectory=par*(exp(theta.*(tT-time)-lambda*T)-exp(-lambda.*(time-time0)));
end
end