Completata funzione scelta miglior combinazione
This commit is contained in:
+42
-7
@@ -778,7 +778,7 @@ end
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- Ordina le feature in base a fase di lavorazione
|
||||
-- 1) Head : ( intestatura)
|
||||
-- 2) Standard : ( lavorazioni standard che non impattano sulal coda)
|
||||
-- 2) Standard : ( lavorazioni standard che non impattano sulla coda)
|
||||
-- 3) AdvanceTail : ( lavorazioni che richiedono taglio di separazione, ma che devono essere fatte prima perchè il taglio di separazione farebbe cadere il pezzo)
|
||||
-- 4) Split : ( taglio di separazione)
|
||||
-- 5) Tail : ( lavorazioni di coda, fatte dopo il taglio di separazione)
|
||||
@@ -1000,12 +1000,43 @@ local function IsCombinationAvailable( sCombination, nUnloadPos)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- funzione che decide le combinazioni di rotazione per lavorare la trave
|
||||
-- funzione che decide la migliore tra le combinazioni di rotazione disponibili
|
||||
local function GetBestCombination( ListToCompare)
|
||||
-- TODO da sistemare. Verificare i parametri come vengono passati
|
||||
|
||||
local ChosenCombination = ListToCompare[1]
|
||||
-- TODO da completare
|
||||
local nIndexBestCombination = 1
|
||||
if #ListToCompare == 1 then
|
||||
nIndexBestCombination = 1
|
||||
else
|
||||
for ListIndex = 2, #ListToCompare do
|
||||
local bBestComplete = ListToCompare[nIndexBestCombination].nNotComplete == 0 and ListToCompare[nIndexBestCombination].nNotExecute == 0
|
||||
local bOtherComplete = ListToCompare[ListIndex].nNotComplete == 0 and ListToCompare[ListIndex].nNotExecute == 0
|
||||
|
||||
-- prediligo combinazione completa
|
||||
if bBestComplete and not bOtherComplete then
|
||||
; -- la migliore resta la stessa
|
||||
elseif not bBestComplete and bOtherComplete then
|
||||
nIndexBestCombination = ListIndex
|
||||
-- altrimenti guardo il voto
|
||||
else
|
||||
-- se stesso voto
|
||||
if ListToCompare[nIndexBestCombination].dTotalRating == ListToCompare[ListIndex].dTotalRating then
|
||||
-- TODO il voto dovrebbe essere considerato già pesando le rotazioni, con un coefficiente o un peso fisso aggiuntivo
|
||||
-- scelgo soluzione con meno rotazioni
|
||||
if ListToCompare[nIndexBestCombination].nRotations > ListToCompare[ListIndex].nRotations then
|
||||
nIndexBestCombination = ListIndex
|
||||
end
|
||||
-- se voto diverso
|
||||
else
|
||||
-- scelgo soluzione con voto più alto
|
||||
if ListToCompare[nIndexBestCombination].dTotalRating < ListToCompare[ListIndex].dTotalRating then
|
||||
nIndexBestCombination = ListIndex
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ChosenCombination = ListToCompare[nIndexBestCombination]
|
||||
return ChosenCombination
|
||||
end
|
||||
|
||||
@@ -1147,7 +1178,7 @@ local function WriteCombinationLog( CombinationsList, BestCombination)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- funzione che decide le combinazioni di rotazione per lavorare la trave
|
||||
-- funzione che calcola le combinazioni di rotazione per lavorare la trave e sceglie la migliore
|
||||
local function GetBestResultFromCombinationsMatrix( ProcessingsOnPart)
|
||||
-- TODO funzione da sviluppare completamente
|
||||
local BestCombination = {}
|
||||
@@ -1188,7 +1219,7 @@ local function GetBestResultFromCombinationsMatrix( ProcessingsOnPart)
|
||||
-- se rotazione abilitata da combinazione
|
||||
if string.sub( sBitIndexCombination, nNextRot, nNextRot) == '1' then
|
||||
-- controllo se è stata scelta una strategia
|
||||
if ProcessingsOnPart.Rotation[nRotation][nProc].ChosenStrategy then
|
||||
if ProcessingsOnPart.Rotation[nNextRot][nProc].ChosenStrategy then
|
||||
local Proc = {}
|
||||
Proc.nRotation = nNextRot
|
||||
table.insert( Proc, ProcessingsOnPart.Rotation[nNextRot][nProc])
|
||||
@@ -1228,6 +1259,10 @@ local function GetBestResultFromCombinationsMatrix( ProcessingsOnPart)
|
||||
end
|
||||
end
|
||||
|
||||
-- ci deve essere almeno una combinazione, altrimenti errore
|
||||
if #CombinationsList < 1 then
|
||||
error( 'UNEXPECTED ERROR: NO combinations available')
|
||||
end
|
||||
BestCombination = GetBestCombination( CombinationsList)
|
||||
|
||||
-- scrittura nel log delle combinazioni possibili
|
||||
|
||||
Reference in New Issue
Block a user