Question: DONT USE AI AND provide R script wherever required. Just answer questions 3 and 4 , for R code use only ( just ) runif

DONT USE AI AND provide R script wherever required. Just answer questions 3 and 4, for R code use only (just) runif(n), Start every R script with the command set.seed(1).
In Foodys, a food delivery company ,for safety, each scooter has to go through a checkup after it has worked for c consecutive days. Further, scooters are subject to breakdowns: the time a scooter is in service before breaking down follows an exponential distribution with rate per day. The company hires two mechanics. However, mechanic1 is specifically assigned for checkups and mechanic2 for repairs. Scooters that need a checkup go to mechanic1 and queue waiting for a checkup. Scooters that break down go to mechanic2 and queue waiting for repair. Suppose Foodys owns N scooters out of which n are working during Foodys working hours and the rest N n are either at mechanic1 for a checkup, mechanic2 for repair, or in Foodys parking lot waiting to be used. When a scooter goes for a checkup or breaks down, it is replaced with one of the scooters in the parking lot. The first n working scooters are not subject to a checkup until they have had their first breakdown, but scooters in the parking lot are assigned a checkup time the minute they start working.
1 The first time Foodys is under-resourced:
Foodys is concerned about having more than N n scooters at the mechanics and thus having to work with less than n scooters. Suppose they start with n scooters working and N n at the parking lot ready to be used when needed. Assume that the time mechanic 1 takes to do a checkup follows an exponential distribution with rate 1 per day, and mechanic 2 repair times also follow an exponential distribution with rate 2 per day. Let T be the first time that Foodys works with less than n scooters. We want to estimate E[T].
(i) Using N =20, n =10, c =2,=0.25,1=1.5, and 2=2, build a simulation model to estimate E[T]. When you build your simulation model define your variables, events, event lists, output variables. Write down the pseudocode of each event case as we did in lecture. Implement your model by writing an R script to estimate E[T] using K =500 iterations.
(Question3) Correct the distribution of the mechanics:
Foodys informs you that the distributions for the mechanics are not as given in part 1. For mechanic1, the density function is f(x)=1/2(1+ x)e^-x,0< x <\infty . For mechanic 2, the distribution function(CDF) is F(x)=1 e^\alpha x\beta ,0< x <\infty , where \alpha =3 and \beta =2.
(i) For each mechanic, use a different method to simulate the service times. Justify why you used that method. Write two R functions, one for each mechanic, that simulate the service times.
(ii) Generate 10000 iid values from each function and plot their histogram with the densities of the distributions to show that they have indeed been simulated correctly (multiply the densities with a constant so that they align with the histogram and explain how you got that constant).
(Qeustion4) CEOs visit to r cities: Foodys CEO needs to visit cities 1,2,..., r with city 0 being the city she is currently located at. Suppose a non-negative reward v(i, j) is associated with the CEO going from city i to city j. So if the CEO visits the cities in permutation x1 to xr then the reward of this choice x =(x1,..., xr) is:
V (x)=(sum i=1 to r) v(xi1, xi), where x0=0. Note that there is no reward for coming back to city 0. To generate v(i, j), set seed to 1 and generate v(i, j) using Uniform(0,1) random variables starting from i =0 and j =1 to 10,
then v(1, j) for j =2 to 10, v(2, j) for j =1,3,4,..,10 and so on.
(i) Use MCMC and r =10 to simulate high reward itineraries for the CEO. Define the stationary distribution that we want our Markov Chain to converge in such a way that high valued solutions are given extremely high probability and include a tunable parameter. Find 3 values of this parameter where the generated Markov Chain behaves differently in the long run for each of
these 3 values and demonstrate this using plots and averages.
(ii) If you could change this parameter during one simulation of the stationary distribution, how would you change it in order to improve the solutions. Demonstrate that you can get better solutions than the fixed 3 values that you used in (i) by running it in R. Present all your results.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!