Question: Your code must be included in a two stand - alone . jl files, with the correct file names. One file should contain all of

Your code must be included in a two stand-alone .jl files, with the correct file names. One file should contain all of your data structures and functions. The second file should initialise all variables to values you choose and run the main event loop. Note that the second file is for your own benefit for the moment, to test your code. It will be replaced in Part 3 of this exercise with a simulation harness. 2. You should use only the packages specified for this assessment. Do not use any packages other than these. 3. Your code must specify three data structures abstract type Event end mutable struct Entity ... mutable struct State ... Each will contain fields as required. The state structure should contain any queues or lists required, for instance, the event list. The Event type is an abstract type that will have sub-types for each event in your simulation, for instance: Arrive (arrival) and Brkdwn (breakdown) events. The Entity struct should contain fields to record important event times in the lifetime of the entity. The State struct will, as in the Car Park simulations (Module 3), contain a time, event list (queue) and queues for all resources in the system. It will contain other details as needed, such as the state of repair of the machine and the number of events so far. You should create convenient constructor functions for each of these types, that allow you to create an object when not all of its fields are known. For instance, a function State() that returns an initial system State variable with any required queues or lists created, but empty, and the clock time set to 0.0.4. Note that when the machine breaks down, the time of completion of the current kit home unit will be extended. That is, we need to change the time, i.e., the priority, of the corresponding departure event. Note that the order of the two items in the queue has been swapped. However, be careful if you also store the time of an event in the Event structure because that would not be updated in the code above. 5. Your functions code must have a set of updater! functions with signatures: function updater!( S::, R::, E:: ) Each update function should process one of your event types so you will need one function per event type. Each update function should modify the state S appropriately, including adding any new events created from this one; and moving any entities from queues to servers and so on. These functions must not have side affects. That is, they should not write out any information to files, or interact with global variables (but note that the ! indicates that they should modify mutable variables.) However, your functions may throw an error if the input is invalid. These functions need not return anything, but sometimes it is useful for them to return a customer/ order entity to the main loop in order to write out information about that. 6. Your code must have this data structure for passing parameters struct Params seed::Int av interarrival::Float64 # lambda1 av cutting time::Float64 # lambda2 av breakdown time::Float64 # lambda3 av fixing time::Float64 # lambda4 end Then define a Params variable Ps = Params(,,,,)7. Your functions code should have an initialise function that takes as input the parameters of the system and returns an initial system state and creates the random number generators that you are going to use. In order to make your code easy to extend or modify, we will encapsulate these random number generators into structures that are easy to pass around. Your code will use four random number generators. Store these in another data structure: struct RandNGs rng::StableRNGs.LehmerRNG interarrival t::Function cutting t::Function breakdown t::Function fixing t::Function end Your initialise function should create a set of random number generators to populate the above structure. Create an initialisation constructor function for RandNGs using code similar to that below (the parameters used here to create these should come from variable Ps::Params). rng = StableRNG(Ps.seed) interarrival t()= rand(rng, Exponential(Ps.av interarrival)) cutting t()= Ps.av cutting time breakdown time()= rand(rng, Exponential(Ps.av breakdown time)) fixing time()= rand(rng, Exponential(Ps.av fixing time))5 Note that, although construction times are deterministic, we use the same functional form to be consistent. Your initialise function should create a set of random number generators to populate the
above structure. Create an initialisation constructor function for RandNGs using code similar to
that below (the parameters used here to create these should come from variable Ps::Params).
rng = StableRNG(Ps.seed)
interarrival t()= rand(rng, Exponential(Ps.av interarrival))
cutting t()= Ps.av cutting time
breakdown time()= rand(rng,
Exponential(Ps.av breakdown time))
fixing time()= rand(rng, Exponential(Ps.av fixing time))

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 Programming Questions!