static private void simulatedAnnealing(double T, double deltaT) { new_network = new Model.Network(network); while (T > 0) { new_network.resetEdges(); foreach (Model.Demand d in new_network.Demands) { generateRandomPath(d); d.flow(); } double min_price = network.Price(); if (network.Price() == 0) { min_price = double.MaxValue; } double ap = acceptanceProbability(new_network.Price(), min_price, T); if (new_network.Price() < min_price || ap > generator.NextDouble()) { Model.Network tmp = network; network = new_network; new_network = tmp; } Console.Write("\rMinimalna cena sieci: " + network.Price() + " "); T -= deltaT; } }
static private void simulatedAnnealing(double T, double deltaT) { new_network = new Model.Network(network); while(T>0) { new_network.resetEdges(); foreach (Model.Demand d in new_network.Demands) { generateRandomPath(d); d.flow(); } double min_price = network.Price(); if (network.Price() == 0) { min_price = double.MaxValue; } double ap = acceptanceProbability(new_network.Price(), min_price, T); if (new_network.Price() < min_price || ap > generator.NextDouble()) { Model.Network tmp = network; network = new_network; new_network = tmp; } Console.Write("\rMinimalna cena sieci: " + network.Price() + " "); T -= deltaT; } }