Hi Yedhuraj,
I see you are trying to simulate a pipeline where you are required to generate 75 good products and 25 products randomly and route to their individual bins.
From the model shared, I can see that you have implemented the bagging part correctly, but you couldn’t generate the entities as per the specification.
To generate 75 good products and 25 bad products randomly you could follow the below steps:
Create two “Entity Generator” blocks, one to generate good products and one to generate bad products. Set the ‘Generation method’ to ‘Time-based’. Also set the appropriate attributes.
- Random Number Generation:
Create a MATLAB function block to randomly generate numbers from 1 to 100. You could use “persistent” variables to keep track of what numbers have been generated already and what needs to be generated yet. A sample code is provided below:
if isempty(idx) || isempty(rand_values)
rand_values = randperm(100);
Utilize an "Entity Input Switch" block to direct the flow of good and bad entities. Set the switching criteria to “From control port”.
Implement a "Compare to Constant" block to evaluate the output from the MATLAB Function block against the value of 25. Following this comparison, employ a "Message Send" block to convey the result to the control port of the "Entity Input Switch" block. It is important to note that the output from the "Compare to Constant" block cannot be directly connected to the "Entity Input Switch" block and must be routed through a "Message Send" block.
By following the above steps, you should be able to achieve your goal.
To know more about the above-mentioned blocks, refer to the following documentation: