- Migliorato calcolo tempo per rating strategia/soluzione
- 'dTimeToMachine' ora obbligatorio nei Result (da sistemare tutte le strategie) - Piccola modifica ai nomi delle variabili, qualità e completamento diventano double e non più interi - Riduzione numero scelte in parametri generici
This commit is contained in:
+40
-31
@@ -673,6 +673,7 @@ local function CollectFeatures( Part, dRotIndex)
|
||||
end
|
||||
-- se ci sono strategie disponibili, aggiungo a lista delle feature da lavorare
|
||||
if Proc.AvailableStrategies and #Proc.AvailableStrategies > 0 then
|
||||
Proc.AvailableStrategies.dAllStrategiesTotalTime = 0
|
||||
nProcCount = nProcCount + 1
|
||||
Proc.nIndexInVProc = nProcCount
|
||||
table.insert( vProc, Proc)
|
||||
@@ -891,22 +892,11 @@ local function GetIndexBestStrategyFromComparison( AvailableStrategies, Part, nI
|
||||
-- se le due strategie hanno stesso stato e sono entrambe applicabili (quindi entrambe complete o entrambe non-complete)
|
||||
if AvailableStrategies[nIndex1].Result.sStatus ~= 'Not-Applicable' and AvailableStrategies[nIndex2].Result.sStatus ~= 'Not-Applicable' and
|
||||
AvailableStrategies[nIndex1].Result.sStatus == AvailableStrategies[nIndex2].Result.sStatus then
|
||||
local dCompositeRatingStrategy1 = AvailableStrategies[nIndex1].Result.dCompositeRating
|
||||
local dCompositeRatingStrategy2 = AvailableStrategies[nIndex2].Result.dCompositeRating
|
||||
if Part.GeneralParameters.GEN_sMachiningStrategy == 'BALANCED' then
|
||||
dCompositeRatingStrategy1 = dCompositeRatingStrategy1 * ( 1 / AvailableStrategies[nIndex1].Result.dTimeToMachine)
|
||||
dCompositeRatingStrategy2 = dCompositeRatingStrategy2 * ( 1 / AvailableStrategies[nIndex2].Result.dTimeToMachine)
|
||||
elseif Part.GeneralParameters.GEN_sMachiningStrategy == 'FASTEST' then
|
||||
dCompositeRatingStrategy1 = ( dCompositeRatingStrategy1 * 0.25) * ( 1 / ( AvailableStrategies[nIndex1].Result.dTimeToMachine * 0.75))
|
||||
dCompositeRatingStrategy2 = ( dCompositeRatingStrategy2 * 0.25) * ( 1 / ( AvailableStrategies[nIndex2].Result.dTimeToMachine * 0.75))
|
||||
elseif Part.GeneralParameters.GEN_sMachiningStrategy == 'HIGH_QUALITY' then
|
||||
dCompositeRatingStrategy1 = ( dCompositeRatingStrategy1 * 0.75) * ( 1 / ( AvailableStrategies[nIndex1].Result.dTimeToMachine * 0.25))
|
||||
dCompositeRatingStrategy2 = ( dCompositeRatingStrategy2 * 0.75) * ( 1 / ( AvailableStrategies[nIndex2].Result.dTimeToMachine * 0.25))
|
||||
end
|
||||
|
||||
-- si predilige strategia con rating composito più alto
|
||||
if dCompositeRatingStrategy1 > dCompositeRatingStrategy2 then
|
||||
if AvailableStrategies[nIndex1].Result.dCompositeRating > AvailableStrategies[nIndex2].Result.dCompositeRating then
|
||||
dChosenIndex = nIndex1
|
||||
elseif dCompositeRatingStrategy2 > dCompositeRatingStrategy1 then
|
||||
elseif AvailableStrategies[nIndex2].Result.dCompositeRating > AvailableStrategies[nIndex1].Result.dCompositeRating then
|
||||
dChosenIndex = nIndex2
|
||||
-- altrimenti si prende la strategia con indice più basso
|
||||
else
|
||||
@@ -978,7 +968,13 @@ local function CalculateStrategies( vProcSingleRot, Part)
|
||||
-- eseguo la strategia solo come calcolo fattibilità e voto. Non si applicano le lavorazioni. Si passa la Proc e i parametri personalizzati
|
||||
_, Proc.AvailableStrategies[nIndexCurrentStrategy].Result = CurrentStrategy.Script.Make( false, Proc, Part, Proc.AvailableStrategies[nIndexCurrentStrategy])
|
||||
|
||||
Proc.AvailableStrategies[nIndexCurrentStrategy].Result = FeatureLib.CalculateCompositeRating( Proc.AvailableStrategies[nIndexCurrentStrategy].Result)
|
||||
-- TODO da capire se dare un tempo molto alto oppure se dare errore perchè non deve mai capitare. Per ora si setta tempo alto
|
||||
-- se tempo non calcolato, si setta un tempo molto alto, 99 minuti
|
||||
if not Proc.AvailableStrategies[nIndexCurrentStrategy].Result.dTimeToMachine then
|
||||
Proc.AvailableStrategies[nIndexCurrentStrategy].Result.dTimeToMachine = 99
|
||||
end
|
||||
|
||||
Proc.AvailableStrategies.dAllStrategiesTotalTime = Proc.AvailableStrategies.dAllStrategiesTotalTime + Proc.AvailableStrategies[nIndexCurrentStrategy].Result.dTimeToMachine
|
||||
-- se scelta strategia in modalità base o standard, esco subito alla prima che trovo completa
|
||||
if Part.GeneralParameters.GEN_sMachiningStrategy == 'FIRST_IN_LIST' and Proc.AvailableStrategies[nIndexCurrentStrategy].Result.sStatus == 'Complete' then
|
||||
break
|
||||
@@ -991,6 +987,8 @@ local function CalculateStrategies( vProcSingleRot, Part)
|
||||
Proc.AvailableStrategies[nIndexCurrentStrategy].Result.sStatus = 'Not-Applicable'
|
||||
end
|
||||
end
|
||||
-- si calcola il composite rating delle strategie
|
||||
Proc.AvailableStrategies = FeatureLib.CalculateStrategiesCompositeRating( Proc.AvailableStrategies, Part.GeneralParameters.GEN_sMachiningStrategy)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1076,7 +1074,7 @@ end
|
||||
local function AddFeatureResultToGlobalList( Proc, OptionalParameters)
|
||||
local sStrategyId
|
||||
local sStatus
|
||||
local nCompletionIndex
|
||||
local dCompletionIndex
|
||||
local dCompositeRating
|
||||
local sInfo
|
||||
|
||||
@@ -1090,14 +1088,14 @@ local function AddFeatureResultToGlobalList( Proc, OptionalParameters)
|
||||
if ChosenStrategyTable then
|
||||
sStrategyId = ChosenStrategyTable.sStrategyId
|
||||
sStatus = ChosenStrategyTable.Result.sStatus
|
||||
nCompletionIndex = ChosenStrategyTable.Result.nCompletionIndex
|
||||
dCompletionIndex = ChosenStrategyTable.Result.dCompletionIndex
|
||||
dCompositeRating = ChosenStrategyTable.Result.dCompositeRating
|
||||
sInfo = ChosenStrategyTable.Result.sInfo
|
||||
end
|
||||
elseif Proc.ChosenStrategy then
|
||||
sStrategyId = Proc.ChosenStrategy.sStrategyId
|
||||
sStatus = Proc.ChosenStrategy.Result.sStatus
|
||||
nCompletionIndex = Proc.ChosenStrategy.Result.nCompletionIndex
|
||||
dCompletionIndex = Proc.ChosenStrategy.Result.dCompletionIndex
|
||||
dCompositeRating = Proc.ChosenStrategy.Result.dCompositeRating
|
||||
sInfo = Proc.ChosenStrategy.Result.sInfo
|
||||
end
|
||||
@@ -1114,7 +1112,7 @@ local function AddFeatureResultToGlobalList( Proc, OptionalParameters)
|
||||
ChosenStrategy = {
|
||||
sStrategyName = sStrategyId,
|
||||
sStatus = sStatus,
|
||||
nCompletionIndex = nCompletionIndex,
|
||||
dCompletionIndex = dCompletionIndex,
|
||||
dCompositeRating = dCompositeRating,
|
||||
sInfo = sInfo
|
||||
}
|
||||
@@ -1323,7 +1321,7 @@ local function GetBestCombination( ListToCompare, Part)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- GEN_sPieceRotation = 'MODERATE_IMPACT' oppure 'NO_CONSTRAINT'
|
||||
-- GEN_sPieceRotation = 'NO_CONSTRAINT'
|
||||
else
|
||||
-- si sceglie soluzione con più feature complete
|
||||
if ListToCompare[ListIndex].nComplete > ListToCompare[nIndexBestCombination].nComplete then
|
||||
@@ -1331,12 +1329,6 @@ local function GetBestCombination( ListToCompare, Part)
|
||||
elseif ListToCompare[ListIndex].nComplete == ListToCompare[nIndexBestCombination].nComplete then
|
||||
local dBestTotalRating = ListToCompare[nIndexBestCombination].dTotalRating
|
||||
local dOtherTotalRating = ListToCompare[ListIndex].dTotalRating
|
||||
-- se la rotazione ha un moderato impatto, si calcola che ogni rotazione aumenta il dTotalRating del 10%
|
||||
if Part.GeneralParameters.GEN_sPieceRotation == 'MODERATE_IMPACT' then
|
||||
-- TODO IMPROVEMENT: si potrebbe avere un tempo di rotazione e aggiungere quello alla somma dei tempi delle lavorazioni delle feature
|
||||
dBestTotalRating = dBestTotalRating * ( 1 + ( ListToCompare[nIndexBestCombination].nRotations / 10))
|
||||
dOtherTotalRating = dOtherTotalRating * ( 1 + ( ListToCompare[ListIndex].nRotations / 10))
|
||||
end
|
||||
|
||||
-- scelgo soluzione con voto più alto
|
||||
if dBestTotalRating < dOtherTotalRating then
|
||||
@@ -1414,10 +1406,12 @@ local function GetProcBestMachRotationFromList( ListToCompare, Part)
|
||||
-- se ci sono almeno 2 possibili soluzioni, scelgo la posizione migliore di lavorazione
|
||||
if #ListToCompare > 1 then
|
||||
-- formatto lista strategie disponibili come se le aspetta la funzione di compare
|
||||
local AvailableStrategiesInRot = {}
|
||||
local AvailableStrategiesInRot = { dAllStrategiesTotalTime = 0}
|
||||
for i = 1, #ListToCompare do
|
||||
table.insert( AvailableStrategiesInRot, ListToCompare[i][1].ChosenStrategy)
|
||||
AvailableStrategiesInRot.dAllStrategiesTotalTime = AvailableStrategiesInRot.dAllStrategiesTotalTime + ListToCompare[i][1].ChosenStrategy.Result.dTimeToMachine
|
||||
end
|
||||
AvailableStrategiesInRot = FeatureLib.CalculateStrategiesCompositeRating( AvailableStrategiesInRot, Part.GeneralParameters.GEN_sMachiningStrategy)
|
||||
for nIndexCurrentStrategy = 1, #AvailableStrategiesInRot do
|
||||
-- la scelta tra le differenti strategie tra le rotazioni utilizza gli stessi criteri della scelta strategie all'interno della feature stessa
|
||||
nIndexChosenProcInRot = GetIndexBestStrategyFromComparison( AvailableStrategiesInRot, Part, nIndexCurrentStrategy, nIndexChosenProcInRot)
|
||||
@@ -1429,7 +1423,9 @@ local function GetProcBestMachRotationFromList( ListToCompare, Part)
|
||||
|
||||
Proc = ListToCompare[nIndexChosenProcInRot][1]
|
||||
Data.nIndexRotation = ListToCompare[nIndexChosenProcInRot].nRotation
|
||||
Data.dCompositeRating = ListToCompare[nIndexChosenProcInRot][1].ChosenStrategy.Result.dCompositeRating
|
||||
Data.dTimeToMachine = ListToCompare[nIndexChosenProcInRot][1].ChosenStrategy.Result.dTimeToMachine
|
||||
Data.dQuality = ListToCompare[nIndexChosenProcInRot][1].ChosenStrategy.Result.dQuality
|
||||
Data.dCompletionIndex = ListToCompare[nIndexChosenProcInRot][1].ChosenStrategy.Result.dCompletionIndex
|
||||
Data.bComplete = ListToCompare[nIndexChosenProcInRot][1].ChosenStrategy.Result.sStatus == 'Completed'
|
||||
Data.bNotComplete = ListToCompare[nIndexChosenProcInRot][1].ChosenStrategy.Result.sStatus == 'Not-Completed'
|
||||
Data.bNotApplicable = ListToCompare[nIndexChosenProcInRot][1].ChosenStrategy.Result.sStatus == 'Not-Applicable'
|
||||
@@ -1440,7 +1436,7 @@ end
|
||||
-- funzione che calcola le combinazioni di rotazione per lavorare la trave e sceglie la migliore
|
||||
local function GetCombinationListFromMatrix( ProcessingsOnPart, PartInfo)
|
||||
local BestCombination = {}
|
||||
local CombinationsList = {}
|
||||
local CombinationsList = { dAllCombinationsTotalTime = 0}
|
||||
|
||||
--
|
||||
-- scrittura nel log della matrice delle rotazioni
|
||||
@@ -1454,7 +1450,9 @@ local function GetCombinationListFromMatrix( ProcessingsOnPart, PartInfo)
|
||||
local SingleCombination = {}
|
||||
local nUnloadPos = PartInfo.CombinationList[i].nUnloadPos
|
||||
SingleCombination.nRotations = 0
|
||||
SingleCombination.dTotalRating = 0
|
||||
SingleCombination.dTotalTimeToMachine = 0
|
||||
SingleCombination.dTotalQuality = 0
|
||||
SingleCombination.dTotalCompletionIndex = 0
|
||||
SingleCombination.nComplete = 0
|
||||
SingleCombination.nNotComplete = 0
|
||||
SingleCombination.nNotExecute = 0
|
||||
@@ -1514,7 +1512,9 @@ local function GetCombinationListFromMatrix( ProcessingsOnPart, PartInfo)
|
||||
bRot180 = true
|
||||
end
|
||||
|
||||
SingleCombination.dTotalRating = SingleCombination.dTotalRating + Data.dCompositeRating
|
||||
SingleCombination.dTotalTimeToMachine = SingleCombination.dTotalTimeToMachine + Data.dTimeToMachine
|
||||
SingleCombination.dTotalQuality = SingleCombination.dTotalQuality + Data.dQuality
|
||||
SingleCombination.dTotalCompletionIndex = SingleCombination.dTotalCompletionIndex + Data.dCompletionIndex
|
||||
SingleCombination.nComplete = SingleCombination.nComplete + EgtIf( Data.bComplete, 1, 0)
|
||||
SingleCombination.nNotComplete = SingleCombination.nNotComplete + EgtIf( Data.bNotComplete, 1, 0)
|
||||
SingleCombination.nNotExecute = SingleCombination.nNotExecute + EgtIf( Data.bNotApplicable, 1, 0)
|
||||
@@ -1537,10 +1537,19 @@ local function GetCombinationListFromMatrix( ProcessingsOnPart, PartInfo)
|
||||
end
|
||||
-- aggiungo rotazioni
|
||||
SingleCombination.nRotations = EgtIf( bRot90, 1, 0) + EgtIf( bRot180, 1, 0)
|
||||
|
||||
-- aggiungo tempo totale considerando le rotazioni -- TODO per il momento la rotazione impiega 1 minuto. Serve configurare?
|
||||
SingleCombination.dTotalTimeToMachine = SingleCombination.dTotalTimeToMachine + ( SingleCombination.nRotations * 1)
|
||||
|
||||
-- aggiungo la combinazione all'elenco delle combinazioni disponibili
|
||||
table.insert( CombinationsList, SingleCombination)
|
||||
-- aggiorno tempo totale di tutte le combinazioni
|
||||
CombinationsList.dAllCombinationsTotalTime = CombinationsList.dAllCombinationsTotalTime + SingleCombination.dTotalTimeToMachine
|
||||
end
|
||||
|
||||
-- si calsola il total rating
|
||||
CombinationsList = FeatureLib.CalculateCombinationsCompositeRating( CombinationsList, PartInfo.GeneralParameters.GEN_sMachiningStrategy)
|
||||
|
||||
return CombinationsList
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user