Cancel
Showing results for 
Search instead for 
Did you mean: 

Assembling by attribute problem

Experimenter
Experimenter

Hello,

We are developing an engine shop example in plant simulation. We have an engine with 9 parts that are cleaned, checked and than repaired or stored depending on if the part is broken. After that the Egine is assembled with its original parts. If the parts of Engine 1 are repaired and stored these parts should come back to exactly the same engine with the same arrivalTime (arrivalTime is the attribute that an engine gets when it is created). Our simulation goes well for a while but then, at a certain point of time, the assembly station makes engines from parts of different engines. This is not wat we want, and we cant seem to find why this happens. This can be checked in the table file engines in our model.

The code that should make this happend is the following code:
This is used as an exit control of our storage.

 

var i, k,Correct : integer
var MU1,MU2,MU3 : object
var ArrivalTime1, ArrivalTime2 : time
var Repair : boolean

--Initialisatie
Repair := false
Correct := 0
--Je wil pas MUs versturen naar de assembly als er 9 zijn, dus de if statement hoeft pas te beginnen als er meer dan 9 MUs aanwezig zijn
if EngineShop.Storage.NumMU > 8 
	--Zet repair op false 
	--Een while loop gaat door, totdat repair=false niet meer waar is
	
	--Loop over alle Mus in de Storage
	--Doe min 1 omdat je in de loop de huidige MU vergelijkt met de volgende
	
	for i := 1 to EngineShop.Storage.NumMU-1
		if Repair = false
			--Kijk welke MU het is en kom erachter welke arrivaltime het heeft	
			MU1 := EngineShop.Storage.ContentsList[1,i]
			ArrivalTime1 := MU1.arrivalTime
	
			MU2 := EngineShop.Storage.ContentsList[1,i+1]
			arrivalTime2 := MU2.arrivalTime
			--Controleer of de MUs dezelfde arrivaltime hebben
			if ArrivalTime1 = ArrivalTime2
				--Zo ja? Laat een teller lopen
				--Deze teller telt het aantal MUs met dezelfde arrivalTime
				Correct := Correct +1
				--Heeft de teller nummer 9 bereikt, dan mogen deze 9 MUs door!
				if Correct = 8
					--Zet repair op true zodat het de while loopt verlaat
				
					for k := i+1 downto i - 7
						MU3 := EngineShop.Storage.ContentsList[1,k]
						if MU3.name = "Fan"
							MU3.move(EngineShop.FanReady)
						elseif MU3.name = "FanBroken"
							MU3.move(EngineShop.FanReady)
	
						elseif MU3.name = "LPCompressor"
								MU3.move(EngineShop.LPCompressorReady)
						elseif MU3.name = "LPCompressorBroken"
							MU3.move(EngineShop.LpCompressorReady)
				
						elseif MU3.name = "HPCompressor"
							MU3.move(EngineShop.HPCompressorReady)
						elseif MU3.name = "HPCompressorBroken"
							MU3.move(EngineShop.HPCompressorReady)
	
						elseif MU3.name = "LPShaft"
							MU3.move(EngineShop.LPShaftReady)
						elseif MU3.name = "LPShaftBroken"
							MU3.move(EngineShop.LPShaftReady)
	
						elseif MU3.name = "HPShaft"
							MU3.move(EngineShop.HPShaftReady)
						elseif MU3.name = "HPShaftBroken"
							MU3.move(EngineShop.HPShaftReady)
	
						elseif MU3.name = "CombustionChamber"
						MU3.move(EngineShop.CombustionChamberReady)
						elseif MU3.name = "CombustionChamberBroken"
							MU3.move(EngineShop.CombustionChamberReady)
	
							elseif MU3.name = "HPTurbine"
							MU3.move(EngineShop.HPTurbineReady)
							elseif MU3.name = "HPTurbineBroken"
								MU3.move(EngineShop.HPTurbineReady)
	
						elseif MU3.name = "LPTurbine"
								MU3.move(EngineShop.LPTurbineReady)
							elseif MU3.name = "LPTurbineBroken"
											MU3.move(EngineShop.LPTurbineReady)
	
											elseif MU3.name = "Nozzle"
												MU3.move(EngineShop.NozzleReady)
												elseif MU3.name = "NozzleBroken"
													MU3.move(EngineShop.NozzleReady)
												end
											next -- voor het moven van MUs
											Repair := true
											Correct := 0
							end -- als het er geen 8 zijn
						else --als de arrivaltime niet gelijk zijn 
							--Zet het aantal gevonden matches terug naar 0
							Correct := 0 
				
					end -- als repair wel true is
		
					end
				next
			end


If there is some one who is familiar with such a problem and can find out where the failure comes from we would be very happy.

Thank you in advance!

Kind regards,

Jord

22 REPLIES 22

Re: Assembling by attribute problem

Phenom
Phenom

Before I start debugging your methods,

 

have you used the debugger  to find out the

 

programmed behaviour of your model /methods ?

 

If not , just set a break point (or a debug statement) at the beginning  of 

 

your method then it will stop stop whilst execution and you step through 

 

the method and check/ set  the conditions and variables.

Re: Assembling by attribute problem

Experimenter
Experimenter

hi phenom,

Yes i have used the debugger. And I think it's counting 8 matches of arrivalTime and then just sending a random part, which it shouldn't do. But i don't know why it does that, because most of the time it works well. I can't find out what exactly goes wrong.

Re: Assembling by attribute problem

Siemens Phenom Siemens Phenom
Siemens Phenom
It's always hard to debug other peoples code, but it looks fine to me (I would use switch-case rather than elseif, but that is not relevant atm).

However, I think I know the problem. Since some parts are sent to repair and others directly to storage, there is a chance that new products enter the store before the older ones are still in repair. E.g you have the first Turbine in repair and the other eight parts in storage. If turbine 2 does not need to be repaired it enters the storage before turbine 1. The assembly then acknowledges that it has 9 different parts, and they are all the ones with the lowest arrival time in the store, therefore the engine 1 is constructed with turbine 2 instead, since that fulfills the condition of having the lowest arrival time oaf all turbines in the storage. (Since turbine 1 is still in repair, and therefore not found in the storage)

Re: Assembling by attribute problem

Creator
Creator

Hi MarcusA,

 

I'm working together with Jord and the problem you suggest is one we (at least we think we did) tackled. The code checks if there are 9 parts with the same arrivaltime. Turbine 2 cannot have the same arrivaltime as the first 8 parts that came in with Turbine 1 (the interval of the engines with 9 parts is 12 hours). 9 parts can only be sent if they have the same arrivaltime. Since storage sorts the parts with the lowest arrivaltimes first, all the parts with the same arrivaltime are together in line. If there are then 9 parts with the same arrival they are sent together to the ready proc stations since it takes the 9 parts that have been checked and have the same arrivaltime. 

 

This is how it should work. 

Re: Assembling by attribute problem

Siemens Phenom Siemens Phenom
Siemens Phenom

But does the storage check if all nine parts with the same arrival time is present in the store, or does it just check that there is a part of the correct type regardless of the arrival time? Because I think that is the problem, not checking if all 9 parts for the engine are found i the store. If all parts for the first engine, except Turbine1, is in the store it will use the first available Turbine that enters the store.

 

So if you are waiting for a turbine and turbine2 enters the store before turbine1 (that is in repair), turbine2 will be used.

 

I'll admit that I might be misunderstanding your code, as I find it a bit cluttered and hard to read. I'd appreciate if you could de-clutter it a bit (for example, use OR statements in the elseif:s rather than extra elseif:s)

elseif MU3.name = "HPTurbine" OR MU3.name = "HPTurbineBroken"

Re: Assembling by attribute problem

Creator
Creator

The storage checks if 9 parts with the same arrivaltime are in store. It tries to find 8 matches (9 parts) with the arrivaltimes. So it matches arrivaltimes of parts in the storage contentslistst. When 8 mathces are found (correct = 8) then it sends the corresponding mu's to the ready stations. However, after some time it stops doing that correctly but we dont understand why that happens after some time. 

 

for i := 1 to EngineShop.Storage.NumMU-1
		if Repair = false
			--Kijk welke MU het is en kom erachter welke arrivaltime het heeft	
			MU1 := EngineShop.Storage.ContentsList[1,i]
			ArrivalTime1 := MU1.arrivalTime
	
			MU2 := EngineShop.Storage.ContentsList[1,i+1]
			arrivalTime2 := MU2.arrivalTime
			--Controleer of de MUs dezelfde arrivaltime hebben
			if ArrivalTime1 = ArrivalTime2
				--Zo ja? Laat een teller lopen
				--Deze teller telt het aantal MUs met dezelfde arrivalTime
				Correct := Correct +1
				--Heeft de teller nummer 9 bereikt, dan mogen deze 9 MUs door!
				if Correct = 8
					--Zet repair op true zodat het de while loopt verlaat
				
					for k := i+1 downto i - 7

Re: Assembling by attribute problem

Siemens Phenom Siemens Phenom
Siemens Phenom

I think that the problem is found somewhere in the

for k := i+1 downto i - 7

loop, but I'm not sure. I would actually recommend you to rethink the logic completly.

 

My suggestion is that when the sorter contains more than nine items you compare if the 1st and the 9th MUs have the same arrival time (since you sort them, you also know that MUs 2-8 have the same arrival time as well).

If true, send MUs 1-9 to the correct stations. If false, wait for the next part to enter and be sorted into the correct order.

if EngineShop.Storage.ContentsList[1].arrivalTime = EngineShop.Storage.ContentsList[9].arrivalTime 
//send MUs 1 through 9 to next station
end

Re: Assembling by attribute problem

Creator
Creator

That is one method to it, but then if 8 parts from engine one are in store (1-8) and 9 parts of engine 2 are in store (9-17) it does not send engine 2. And we want to send and engine when the 9 parts are ready, but some engines will move quicker through the process since the repair times are different. Therefore engines with a later arrivaltime should be able to move as well. 

Re: Assembling by attribute problem

Siemens Phenom Siemens Phenom
Siemens Phenom
Could you not make it iterative then? If parts 1 and 9 doesn't match, check for the second lowest arrival time. If that is part 7, then compare part 7 and 15 (i.e. the estimated 9th part for engine 2). Continue either until you have found a complete set of parts or you reach the end of the storage.