I’m a student studying Plant Simulation. I have this problem formulating my model CurrentState (frame CurrentState):
How can I program so that the pallet will only be created 4 times in P1 (in the morning shift or equivalent 7h30’)? As you can see in my method CreatePallet, I created a pallet with 500 parts in it but I can’t control the number of times it is created. I tried “repeat … until” like this but what it shows is not what I wanted:
i : integer;
k : integer;
k := 1;
for i := 1 to 500 loop
k := k +1;
until k > 5;
Another thing is, in frame CurrentState1, how I can simulate so that the products coming out of Machine2 will include the main products (which I named “Part” - to P4 and will continue the whole process) and the by-products (which I named “Half_part”) gathering in “Waiting”. These by-products will then come back to Machine 1 (when machine1 is not occupied) for the second round to undergo the same process but this time after Machine2 they will continue the subsequent steps and no new by-products are created and the process is completed.
So, with 4 times the parts passing Machine2, there should be 4 containers of by-products in Waiting. Then they all will go back to Machine1 the second time.
Because I can’t tell P1 to create the pallet only 4 times, I don’t know how to make by-products to come back to Machine1 when it’s busy all the time.
Thank you and best regards;
Why so difficult? Use a Source object instead!
Change "Interval adjustable" to "Number adjustable" and you will get the desired amount of MUs, e.g. 4.
Or, if you want create different items with the same Source, you can set MU Selection to Sequence. You then use a table to fill in the different items that you want to create. An Assembly object would be suitable to put MUs on top of other MUs.
The Start parameter can be set to 7:30:00 (h:mm:ss). Or you can also use a ShiftCalendar object if the procedure is to repeated on a daily basis.
At least 95% of what you describe can already be done with the standard objects, without any coding.
for creating the pallets, you can use a nested loop. Insert all locations into a array, then you can create all pallets into a loop:
is i,k : integer; buffer:object; do local buffers:object:=makeArray(p1,p2,p4,p6,waiting); for k:=1 to buffers.dim loop buffer:=buffers[k]; .MUs.pallet.create(buffer); for i := 1 to 500 loop .mus.part.create(buffer.cont); next; next; end;
to create by-products you can use the exit control rear of the machines
than you need one more loop in the init-method:
is i,k,m : integer; buffer:object; pallet:object; do local buffers:object:=makeArray(p1,p2,p4,p6,waiting); for k:=1 to buffers.dim loop buffer:=buffers[k]; if buffer /= p1 then --empty pallet pallet:=.MUs.pallet.create(buffer); else --4 pallets for m:=1 to 4 loop pallet:=.MUs.pallet.create(buffer); for i := 1 to 500 loop .mus.part.create(pallet); next; next; end; next; end;
the create method returns a reference on the created object; using this reference you can access e.g. the created pallet to fill it.
I did not mention the "Delivery table", it is unclear how you got there. When using "Interval adjustable" and MU Selection set to "Sequence", you can create batches of parts in the desired amounts. Under MU fill in the right class, under Number the desired amount of MUs and give a proper name (P1 etc.). There is a good decription of the Source object in the Help-pages!
Of course, if SimTalk feels comfortable, you can also go with Steffen Bangsow's suggestions.
Regarding the routing of MUs, you do need at least a little SimTalk. If the material flow does not get more complicated than you described, you can create a user-defined attribute for the MUs (e.g. FirstPassComplete: boolean). Then at the appropriate point you change this attribute. Subsequently you use a generic Exit control that check all passing MUs for this attribute and routes them. For those MUs that do one pass, you set it to true at the outset. This can also be done in the Source in the column Attributes.
Hi Mr Bangsow,
Thank you a lot for your code. It works perfectly on P1 and creates exactly 4 pallets full of parts as I need. Still I can't manage to create a pallet full of half_parts at Waiting whenever Machine2 has done with processing all the parts of the previous pallet. Given that Machine2 has to process 4 pallets passed on from Machine1, there supposed to be 4 pallets full of half_parts created in Waiting. The code I'm using can only do it once and I tried to resemble the loop you gave in your code but it fails somewhere along the way ...
I guess if I can't do it, I will need to find another way to interpret my result.
you need only to find the right trigger, in your case it is, when you move the empty pallet from p3 to p4.
It is in the load2 method (exit control of machine2). Here you can create the pallet with half parts on waiting:
is i : integer; do if ? = p3 then @.cont.move(machine2); elseif ? = machine2 then @.move(p4.cont); if p4.cont.full then p4.cont.move(gathering1); p3.cont.move(p4); --create a bin with halfparts local bin:object:=.MUs.pallet.create(waiting); for i := 1 to 500 loop .mus.part.create(bin); next; else p3.cont.cont.move(machine2); end; end; end;