Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a discrete event simulation in MATLAB: A store sells widgits. Customers ar

ID: 2985349 • Letter: W

Question

Write a discrete event simulation in MATLAB:

A store sells widgits. Customers arrive as a Poisson process with rate lambda, and buys n widgits with probability P(n) = c / n^2. If there are not enough widgits in the store for a customer, she will buy all that remain. The manager has a policy that when the inventory level gets down to s, she orders S more widgits. The time for the order to get to the store is exponentially distributed with parameter mu. An order costs $(100+S). Each widgit sells for $10. The space to store the widgits costs $N per day, where N is the maximum number of widgits it can hold.

This is what I have to start, but I can't figure out how to make the necessary changes:

h = 2; % holding cost (Needs to be changed to N)

lambda = 10; % customer arrival rate

r = 10; % profit per item sold

L = 2; % time for order to arrive (Needs to be exponential with parameter mu)

g = 20; % customer oreder size parameter, G ~ U[1,g] (Needs to be Pn = c / n^2 where n = number bought)

s = 200; % order if inventory < s

S = 600; % order brings inventory up to S

c0 = 100; c1 = 1; % linear cost parameters for order (order should cost $(100+S))

x = 100; y = 0; % inventory level, # on order, (state variables)

C = 0; H = 0; R = 0; %initialize C = costs of orders, H = holding costs, R = total revenue

t0 = -log(rand)/lambda; t1 = inf; %times till next event

t = 0; T = 1000;

k = 1; time(k) = 0; inventory(k) = x; X = zeros(1,2*T*lambda);

while t < T

k = k+1; time(k) = t; inventory(k) = x; % construct X(t) = inventory at t

if t0 < t1 %new customer

H = H +(t0-t)*x*h;

t = t0; % move clock

D = ceil(g*rand); % cust order size

w = min(D,x);

R = R + w*r;

x = x - w;

if x< s & y == 0 % need to order more inventory

y = S - x;

t1 = t + L; % when order will arrive

end

t0 = t - log(rand)/lambda; % time of next arrival

elseif t1 < t0 % order comes in

H = H + (t1-t)*x*h;

t = t1; % move clock

C = C + (c0+c1*y); % pay for order

x = x + y; % new inventory level

y = 0; % no more on order

t1 = inf; % don't know when next order will come in yet

end

end

ProfitRate = (R - H - C)/T


Explanation / Answer

Please rate if you found the answer useful

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote