How to combine more than 2 entities to 1 entity by Composite Entity Creator?

5 views (last 30 days)
Hello,
I want to simulate a situation where I put several identical items onto pallets, treating each loaded pallet as one item. I'm aware of the entity batch creator, but it requires a fixed capacity. For instance, I have 36 items, and a pallet can hold 30 items. So, I'd like to group 30 items (30 entities) into one pallet (1 entity), and the remaining 6 items (6 entities) into another pallet (1 entity).
I tried using the Composite Entity Creator by sending 30 entities together and then 6 entities, but it only combined 2 entities into 1. Ultimately, I ended up with 18 entities.
If anyone could offer guidance or share a resource for me to learn more, I'd really appreciate it. Please let me know if my explanation is unclear or if you need more information to understand better.
Thank you, Chi
  2 Comments
Ayush
Ayush on 11 Sep 2023
Edited: Ayush on 11 Sep 2023
Can you provide the Simulink model file so as to get a better understanding at what you are trying to achieve ?
Chi Wai Wong
Chi Wai Wong on 11 Sep 2023
Hi Ayush,
Really apperciated your reply.
I created 2 example and attched here to explain what I would like to achieve.
I would like to combine multiple the entities into 1 entity when those entities arrived together.
In the example 1, I set 30 entities arrived together and add the entity composite creator inside. But required at least 2 input. (In my actual case, the entities arrived together with different amount such as 30, 1, 6, 29.......)
In the example 2, 1 split 30 entities into 2 input. After they past the entity composite creator, 30 entities combined into 15 entities which not 1 entity even they arrived together.
Is it possible to combine the mulitple entities (more than 2) into 1 entity?
Please feel free to let me know if you need more information.
Thanks
Chi

Sign in to comment.

Accepted Answer

Ayush
Ayush on 15 Sep 2023
Hi Chi,
I understand that you combine more than 2 entities into 1 entity by using the Composite Entity Creator. I have also understood the provided Simulink model and your purpose of using the Composite Entity Creator therein.
Here are some possible workarounds:
1. Using the Composite Entity Creator: To use this block for the desired use case you would need to change the block parameter “Number of Input Ports” to dynamically control the number of entity inputs to combine into a single entity. Since each input port of the Composite Entity Creator block would take the output of each Entity Generator Block.
This can be done programmatically using add_block”, add_line and “delete_block functions iteratively based on the size of the entity store as per your example model provided. Please refer to the below documentations to know more about the “add_block”, add_line and “delete_block functions respectively:
Here is code snippet for reference:
model = 'example1'; % Name of the Simulink model
% You would need to iteratively generate and connect the blocks % and delete it too once one pallet ends to start the next one.
% Add the required amount of Entity Generator blocks
add_block('sldelib/Entity Generator', [model, '/EntityBlock'], 'Position', [100, 100, 200, 200]);
add_block('sldelib/Entity Generator', [model, '/EntityBlock2'], 'Position', [150, 150, 200, 200]);
add_block('sldelib/Entity Generator', [model, '/EntityBlock3'], 'Position', [50, 50, 200, 200]);
% Add the Composite Entity Creator block and set its Number of % Input Ports parameter to the same number of blocks created % for the Entity Generator Block
add_block('sldelib/Composite Entity Creator', [model, '/CompositeEntityCreator'], 'Position', [300, 100, 400, 200]);
set_param("example1/CompositeEntityCreator","NumberInputPorts","3")
% Connect the Entity Generator block output to the Composite % Entity Creator input corresponding to the input port number
add_line(model, 'EntityBlock/1', 'CompositeEntityCreator/1');
add_line(model, 'EntityBlock2/1', 'CompositeEntityCreator/2');
add_line(model, 'EntityBlock3/1', 'CompositeEntityCreator/3');
2. Using the Entity Batch Creator: You can also use this block to create a single entity having similar properties by modifying the block parameter “Number of entities in batch” programmatically by adding a MATLAB function block in your model.
It takes the desired batch size (pallet size) and the entity store as an input and then sets the parameter of the “Entity Batch Creator” block using the “set_param” function and outputs the entity to create a batch of the desired size. Please refer to the below documentations to know more about the “MATLAB Function” block and the “set_param” function respectively:
Here is code snippet for reference:
% Inside the MATLAB function block
load_system("example1.slx")
set_param("example1/Entity Batch Creator", "NumberOfEntitiesInBatch", "30")
% rest of the code
Hope it helps,
Regards,
Ayush Misra
  2 Comments
Chi Wai Wong
Chi Wai Wong on 15 Sep 2023
Thank you Ayush. Really appercaited your input here.
I will try both of your methods to see which one could match my needs.
Chi Wai Wong
Chi Wai Wong on 16 Sep 2023
Edited: Chi Wai Wong on 16 Sep 2023
Hi Ayush,
When you have a chance, could you please help to provide more guideline for me?
I tried your second suggestion, I have added the Matlab function block in the file with the set_param code but I got the following error message.
"Function 'set_param' not supported for code generation."
I am still new to Simulink. Really apperciate on your help. Attached the file for your better understanding.
Please let me know if you need more information from my end.
Thanks
Chi

Sign in to comment.

More Answers (0)

Categories

Find more on SimEvents in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!