EgtNumKernel :

- Aggiunta classe di calcolo per ottimizzazione ordine delle lavorazioni
- Aggiunti vincoli obbligatori e dipendenze suggerite a ShortestPath.
This commit is contained in:
Riccardo Elitropi
2025-04-23 10:09:41 +02:00
parent d9818970e7
commit 558b590810
13 changed files with 1552 additions and 172 deletions
+50 -10
View File
@@ -20,6 +20,17 @@
#include "stdafx.h"
#include "ShortestPath.h"
static void
SwapNodesForPntOpt( NODE* pFirst, NODE* pLast, NODE* pBest)
{
pFirst->pPrev = pLast->pPrev ;
pLast->pPrev->pNext = pFirst ;
pLast->pPrev = pBest ;
pLast->pNext = pBest->pNext ;
pBest->pNext = pLast ;
pLast->pNext->pPrev = pLast ;
}
/* ------------------------------------------------------------------------- */
long long unsigned
ShortestPath::PointOpt( NODE* pPath)
@@ -27,33 +38,62 @@ ShortestPath::PointOpt( NODE* pPath)
// ciclo di tentativi di spostamento di un punto
unsigned nCount = 1 ;
NODE* pFirst = pPath ;
NODE* pFirstDep = m_pCheckDep ;
do {
unsigned nBestImprove = 0 ;
NODE* pBest = nullptr ;
NODE* pLast = pFirst->pPrev ;
NODE* pLastDep = pFirstDep->pPrev ;
NODE* pKthDep = pFirstDep ;
for ( NODE* pKth = pFirst ; pKth != pLast->pPrev->pPrev ; pKth = pKth->pNext) {
// se non esistono dipendenze suggerite
unsigned nEXIST = ArcCost( pLast->pPrev->nPos, pLast->nPos) +
ArcCost( pLast->nPos, pFirst->nPos) +
ArcCost( pKth->nPos, pKth->pNext->nPos) ;
unsigned nTEST = ArcCost( pLast->pPrev->nPos, pFirst->nPos) +
ArcCost( pKth->nPos, pLast->nPos) +
ArcCost( pLast->nPos, pKth->pNext->nPos) ;
if ( nTEST < nEXIST && ( nEXIST - nTEST) > nBestImprove) {
nBestImprove = nEXIST - nTEST ;
pBest = pKth ;
if ( ! ExistSuggDependences()) {
if ( nTEST < nEXIST && ( nEXIST - nTEST) > nBestImprove) {
// nel caso di assenza di dipendenze
if ( ! ExistConstraints()) {
nBestImprove = nEXIST - nTEST ;
pBest = pKth ;
}
// nel caso di dipendenze
else {
CopyPathAdv( pPath, m_pCheckDep, pLast, pFirst, pKth, &pLastDep, &pFirstDep, &pKthDep) ;
SwapNodesForPntOpt( pFirstDep, pLastDep, pKthDep) ;
if ( IsPathRespectingContraints( m_pCheckDep)) {
nBestImprove = nEXIST - nTEST ;
pBest = pKth ;
}
}
}
}
// se esistono dipendenze suggerite
else {
CopyPathAdv( pPath, m_pCheckDep, pLast, pFirst, pKth, &pLastDep, &pFirstDep, &pKthDep) ;
SwapNodesForPntOpt( pFirstDep, pLastDep, pKthDep) ;
if ( IsPathRespectingContraints( m_pCheckDep)) {
int nBreak ;
IsPathRespectingSuggestedDependences( pPath, nBreak) ;
nEXIST += m_nMaxDistSuggDep * nBreak ;
IsPathRespectingSuggestedDependences( m_pCheckDep, nBreak) ;
nTEST += m_nMaxDistSuggDep * nBreak ;
if ( nTEST < nEXIST && ( nEXIST - nTEST) > nBestImprove) {
nBestImprove = nEXIST - nTEST ;
pBest = pKth ;
}
}
}
}
if ( nBestImprove == 0) {
pFirst = pFirst->pNext ;
nCount ++ ;
}
}
else {
pFirst->pPrev = pLast->pPrev ;
pLast->pPrev->pNext = pFirst ;
pLast->pPrev = pBest ;
pLast->pNext = pBest->pNext ;
pBest->pNext = pLast ;
pLast->pNext->pPrev = pLast ;
SwapNodesForPntOpt( pFirst, pLast, pBest) ;
nCount = 1 ;
}
} while ( nCount < m_nNumPnts) ;