Как улучшить мой имитированный отжиг?
Я решаю проблему маршрутизации транспортных средств с помощью модели смешанного целочисленного программирования, используя имитационный отжиг для эвристической части моего кода и использую CPLEX для получения точного решения. мой выход SA для длинных экземпляров не очень хорош по сравнению с моим выходом CPLEX за 1 час работы. какие-нибудь советы по улучшению моего кода SA?
const int NUM_ITERATIONS = 100; //Number of iterations for simulated
annealing procedure
const double TEMP_FACTOR = .999; //Required parameter for simulated
annealing
const double START_TEMPERATURE = 500; //Required parameter for simulated
annealing
const int NUM_RUNS = 25; //Number of times to run program
мой код SA:
//Evaluating objective value for the neighboring feasible solution just created.
nextTourDist = 0;
for (i = 0; i<NumberOfCustomers + DepotEndPoints - 1; i++)
nextTourDist += distBetweenCustomers(CustomerCoordinates[(deliverySequence[i])][0], CustomerCoordinates[(deliverySequence[i])][1], CustomerCoordinates[(deliverySequence[i + 1])][0], CustomerCoordinates[(deliverySequence[i + 1])][1]);
nextTourDist += distBetweenCustomers(CustomerCoordinates[(deliverySequence[NumberOfCustomers - 0])][0], CustomerCoordinates[(deliverySequence[NumberOfCustomers - 0])][1], CustomerCoordinates[(deliverySequence[0])][0], CustomerCoordinates[(deliverySequence[0])][1]);
nextTourDist += 1000000 * IllegalTurns;
double objValDifference = nextTourDist - currentTourDist;
if (objValDifference >= 0)
{
acceptanceProbability = exp((-1.00*objValDifference) / temperature);
double randNum = (static_cast<double>(rand())) / (RAND_MAX + 1);
if (randNum < acceptanceProbability)
{
accept = true;
steps++;
}
else
{
accept = false;
}
}
else
{
accept = true;
steps++;
}
if (accept == true)
{
//Storing next into current.
for (i = 0; i<NumberOfCustomers + DepotEndPoints; i++)
currentTour[i] = nextTour[i];
currentTourDist = nextTourDist;
}
iterations++;
//Compare the current tour (after "iterations" iterations and "steps" steps are taken)
//to the best tour. If current tour better, set best tour = current tour.
if (currentTourDist < bestTourDist)
{
bestIteration = iterations;
bestStep = steps;
for (i = 0; i<NumberOfCustomers + DepotEndPoints; i++)
bestTour[i] = currentTour[i];
bestTourDist = currentTourDist;
}
temperature *= TEMP_FACTOR;
}