MATLAB Answers

Generate multiple entities at a time step with fixed intergeneration time

3 views (last 30 days)
Mehwish Ahmed
Mehwish Ahmed on 29 Sep 2018
Answered: Krishna Akella on 4 Dec 2018
I have two entity generators, production and demand, with both a schedule for every day. This schedule is specified in a workspace variable (or spreadsheet). I want that multiple entities are generated at a time step, with a fixed intergeneration time of 1. The number of entities to be generated at each time step of 1 is specified in the variable. How could I implement this?
Is it also possible to specify that the production should happen before demand every day?
For example I have two workspace variables: ProductionSchedule and DemandSchedule. ProductionSchedule occurs at t = 0, 1, 2, 3, 4, 5, etc. with number of entities generated: N = 10, 15, 30, 25, 20, etc. So at time 0, 10 entities are generated, at time 1, 15 entities are generated. The same for DemandSchedule but then on time 0.5, 1.5, 2.5 etc to ensure that production happens before demand every day.
Thanks!

Answers (1)

Krishna Akella
Krishna Akella on 4 Dec 2018
Hi Mehwish,
Yes this can be done. You can set the Entity Generator's 'Time source' to 'MATLAB action'. In the action method you can access the workspace variables and set the value of dt (intergeneration time) to be 0 for N times, then set it back to the next IGT. For example:
persistent idx;
if isempty(idx)
idx = 1;
end
N = 5; % Read from workspace
IGT = 1; % Read from workspace
if idx < N
dt = 0;
idx = idx + 1;
else
dt = IGT; % Set equal to next IGT
% Reset idx
idx = 1;
end
You can see the example 'seExampleEstimatingAssemblyLineThroughput' that reads the generation schedule from an excel sheet. Although the batch size is always 1.
Hope that helps!
- Krishna

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by