Я использую приведенные ниже коды, чтобы определить, какая станция имеет на данный момент самый длинный непрерывный период («узкое место»). Затем найдите продолжительность каждого узкого места с самым длинным непрерывным периодом на данный момент. Проблема в том, что когда код проходит цикл, чтобы найти текущий активный период каждой станции. Он всегда на мгновение объявляет станции, расположенные перед текущей станцией с узким местом, как станции с текущим самым длинным непрерывным периодом. Это делает невозможным определение реальной продолжительности каждой станции, которая является узким местом для таблицы cluip_table. Как я могу решить эту проблему, которая существует по своей сути из-за последовательности, в которой цикл проверяет наличие узкого места?
Первый код вызывается контроллером времени события каждый раз, когда изменяется время сим-тайма:
Первый код вызывается контроллером времени события каждый раз, когда изменяется время сим-тайма:
р>
-- param attribute: string, oldValue: time
param newValue: time
-- Variables to store the results
var current_longest_active_time, current_second_longest_active_time, begin_time_starv_st, begin_time_block_st, end_time_starv_st, end_time_block_st, Fail_duration : time
var current_BN_station: object
var new_capacity: integer
var BN_station, ShiftingBN_station: object
var current_station: object
var current_duration: time
var duration_of_previousBN: time
-- Initialize variables
/*current_longest_active_time := 0
current_second_longest_active_time := 0*/
for var i := 1 to shifting_table.YdimIndex loop
current_station := shifting_table["station_object", i]
if shifting_table["state_inactive", current_station] = true then
shifting_table["current_inactive_period", current_station] := newValue - shifting_table["end_active_period", current_station]
shifting_table["current_active_period", current_station] := 0
elseif shifting_table["state_inactive", current_station] = false then
shifting_table["current_active_period", current_station] := newValue - shifting_table["start_active_period", current_station]
end
next
//current_longest_active_time := shifting_table["current_longest_active_time", 7]
-- Loop through each row in the DataTable to compare values
for var i:=1 to shifting_table.YdimIndex
current_station := shifting_table["station_object", i] -- Reading station name
current_duration := shifting_table["current_active_period", i] -- Reading active period
-- Check if the current duration is longer than the stored longest duration
if current_duration > current_longest_active_time then
-- Shift the current longest to second longest
current_second_longest_active_time := current_longest_active_time
ShiftingBN_station := BN_station
if ShiftingBN_station = void
else
cluip_table["end_cluip", ShiftingBN_station] := EventController.simtime
end
-- Update the longest duration and station
current_longest_active_time := current_duration
BN_station := current_station
cluip_table["start_cluip", BN_station] := EventController.simtime
elseif current_duration > current_second_longest_active_time then
-- If the current duration is not the longest but longer than the second longest
current_second_longest_active_time := current_duration
ShiftingBN_station := current_station
end
shifting_table["current_longest_active_time", 7] := current_longest_active_time
shifting_table["current_bn", 7] := BN_station
Drain.CLUIP := shifting_table["current_bn", 7]
shifting_table["current_second_longest_active_time", 7] := current_second_longest_active_time
shifting_table["current_shifting_bn", 7] := ShiftingBN_station
-- Loop through all stations and assign non_bn_wip_limit_tier2 to those that are neither BN_station nor ShiftingBN_station
/*for var k := 1 to shifting_table.YdimIndex
current_station := shifting_table["station_object", k]
if shifting_table["current_active_period", current_station] < shifting_table["current_longest_active_time", 8] -- Skip BN_station and ShiftingBN_station
if current_station = Station1
else
current_station.pred.wip_limit := non_bn_wip_limit_tier2 -- Assign non_bn_wip_limit_tier2 to the buffer before the current station
end
end
next
if ShiftingBN_station =void
elseif ShiftingBN_station = Station1
else
ShiftingBN_station.pred.wip_limit := non_bn_wip_limit_tier1
end
if BN_station =void
elseif BN_station = Station5
BN_station.pred.wip_limit := bn_wip_limit
elseif BN_station = Station1
//BN_station.succ.wip_limit := bn_wip_limit
else
BN_station.pred.wip_limit := bn_wip_limit
BN_station.succ.wip_limit := bn_wip_limit
end*/
next``
The second code below is the method that updates the values in the cluip_table. It is called everytime the attribute CLUIP changes. Which becuase of the issue caused by the loop, is called much more often than it should. Also correct the formulation of this code because it keeps adding the time for the current longest uninterupted active period to values soo high, that they are even higher than the total simulation time
`param oldValue: object
if oldValue = void
//elseif newValue = void
else
cluip_table["cluip_duration", oldValue] := cluip_table["cluip_duration", oldvalue] + (cluip_table["end_cluip", oldvalue] - cluip_table["start_cluip", oldvalue])
//cluip_table["cluip_duration", oldValue] := cluip_table["cluip_duration", oldValue] + (cluip_table["start_cluip", oldValue] - cluip_table["end_cluip", oldValue])
end```
I also created a datatable, called 'cluip_table' that measures how long each station was the one with the current longest active period during the simulation run. Problem is that table keeps updating everytime the even controller is calling the method using change in simtime. Therefore the method keeps adding to the CLUIP duration everytime the attribute I created in the drain called 'CLUIP' that monitors the changes in the station with the current longest uninterupted period. Which leads to it adding huge values. To the CLUIP duration of each station. Precisely because it's being called more often than it should. Becuase the code loops trhough all the stations which leads to the errors.
I even tried adding a 'confirmation duration' before the cluip actually changes. But nothing I have done soo far has been able to overide the loop and the errors becuase of it
```-- Loop through each row in the DataTable to compare values
for var i:=1 to shifting_table.YdimIndex
current_station := shifting_table["station_object", i] -- Reading station name
current_duration := shifting_table["current_active_period", i] -- Reading active period
-- Check if the current duration is longer than the stored longest duration
if current_duration > current_longest_active_time then
-- Shift the current longest to second longest
current_second_longest_active_time := current_longest_active_time
ShiftingBN_station := BN_station
-- Update the longest duration and station
current_longest_active_time := current_duration
BN_station := current_station
elseif current_duration > current_second_longest_active_time then
-- If the current duration is not the longest but longer than the second longest
current_second_longest_active_time := current_duration
ShiftingBN_station := current_station
end
shifting_table["current_longest_active_time", 7] := current_longest_active_time
shifting_table["current_bn", 7] := BN_station
shifting_table["current_longest_active_time", 8] := current_second_longest_active_time
shifting_table["current_bn", 8] := ShiftingBN_station``
Подробнее здесь: https://stackoverflow.com/questions/790 ... ttleneck-a
SimTalk Plant Sim. Проблема с определением продолжительности, в течение которой каждая станция является узким местом в с ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Получите оба номера SIM -карты в телефона Android с двойной SIM -картой
Anonymous » » в форуме Android - 0 Ответы
- 20 Просмотры
-
Последнее сообщение Anonymous
-