From 47972c9e62221b1b2e086c216b2a2207b46a4784 Mon Sep 17 00:00:00 2001 From: Emmanuele Sassi Date: Tue, 5 Jul 2022 19:38:55 +0200 Subject: [PATCH] - Implementazione gestione quantita' limitata di grezzi da utilizzare --- NestProcess.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/NestProcess.lua b/NestProcess.lua index e113aad..ef1c03d 100644 --- a/NestProcess.lua +++ b/NestProcess.lua @@ -163,7 +163,7 @@ for nIndex, nQty in pairs( QTY) do Raws[tonumber(nIndex)].Count = nQty end -local nTotRaws = Raws.Count +--local nTotRaws = Raws.Count -- Pezzi local Parts = {} @@ -181,7 +181,7 @@ local dTotPartLen = TotPartLen( Parts) -- calcolo media delle barre necessarie local NeededRawsForType = {} for RawIndex = 1, #Raws do - NeededRawsForType[RawIndex] = ceil( dTotPartLen / Raws[RawIndex].LenToFill) + NeededRawsForType[RawIndex] = min( ceil( dTotPartLen / Raws[RawIndex].LenToFill), Raws[RawIndex].Count) end local RawQtySum = 0 for NeededRawIndex = 1, #NeededRawsForType do @@ -256,20 +256,26 @@ while TotRawCount( Raws) > 0 and PartsToFill( Parts) > 0 do -- Eseguo ottimizzazione per ogni lunghezza di barra local Results = {} for RawIndex = 1, #Raws do + if Raws[RawIndex].Count > 0 then Results[RawIndex] = ExecMaximumFilling( Raws[RawIndex], PartsToNest) + else + Results[RawIndex] = { FillRatio = 0.001, LenToFill = 1000} + end end -- verifico quale e' quella con meno scarto local nMinWasteRawIndex = GDB_ID.NULL local dMinWaste = 100000 for ResultIndex = 1, #Results do + if Results[ResultIndex] then local dWaste = (1 - Results[ResultIndex].FillRatio) * Raws[ResultIndex].LenToFill if dWaste < dMinWaste then dMinWaste = dWaste nMinWasteRawIndex = ResultIndex + end end end -- verifico se ci sono pezzi - if Results[nMinWasteRawIndex].DiffParts > 0 then + if nMinWasteRawIndex > 0 and Results[nMinWasteRawIndex] and Results[nMinWasteRawIndex].DiffParts > 0 then -- creo gruppo di lavorazione local MachGroupName = NewMachGroupName() nMachGroup = EgtAddMachGroup( MachGroupName) @@ -295,12 +301,12 @@ while TotRawCount( Raws) > 0 and PartsToFill( Parts) > 0 do end end nRawTot = nRawTot + 1 - end -- Aggiorno per prossima iterazione Raws[nMinWasteRawIndex].Count = Raws[nMinWasteRawIndex].Count - 1 for i = 1, Results[nMinWasteRawIndex].DiffParts do local PartId = Results[nMinWasteRawIndex].Data[i].Id PartsToNest[PartId].Cnt = PartsToNest[PartId].Cnt - Results[nMinWasteRawIndex].Data[i].Count + end end nCycle = nCycle + 1 end