public override void AllocateDemand(SpectrumPathAllocator allocator) { Path pathUp = GetDemandPathUp(); Path pathDown = GetDemandPathDown(); allocator.AllocateFirstFreeSpectrumOnPath(pathUp); allocator.AllocateFirstFreeSpectrumOnPath(pathDown); }
public double Start() { _allocator = new SpectrumPathAllocator(_topologyGraph.Edges); int iterations = 0; var timer = new Stopwatch(); double timeStart = 0.0; timer.Start(); Random rnd = new Random(); PathAllocator pathAllocator = new PathAllocator(_scenario, _topologyGraph.NumberOfNodes); DemandsVector currentSolution = new DemandsVector(_scenario, pathAllocator); currentSolution = createInitialSolution(currentSolution); allocateDemands(currentSolution); _currentFitness = _topologyGraph.ComputeCost(); timer.Stop(); _scenario.ObjectiveFunctionResult = _bestFitness; _scenario.ElapsedAlgorithmTime = timer.ElapsedMilliseconds; return(timer.ElapsedMilliseconds); }
public double Start(double initialTemperature, double alpha, double finalTemperature, Scenario scenario) { _initialTemperature = initialTemperature; _currentTemperature = initialTemperature; _alpha = alpha; _finalTemperature = finalTemperature; _scenario = scenario; _bestEnergy = 0; _currentEnergy = 0; _nextEnergy = 0; _topologyGraph = new Graph(_scenario); _allocator = new SpectrumPathAllocator(_topologyGraph.Edges); int iterations = 0; var timer = new Stopwatch(); double timeStart = 0.0; timer.Start(); Random rnd = new Random(); PathAllocator pathAllocator = new PathAllocator(_scenario, _topologyGraph.NumberOfNodes); DemandsVector currentSolution = new DemandsVector(_scenario, pathAllocator); currentSolution = createInitialSolution(currentSolution); allocateDemands(currentSolution); _currentEnergy = _topologyGraph.ComputeCost(); int initialEnergy = _currentEnergy; DemandsVector bestSolution = new DemandsVector(currentSolution); _bestEnergy = _currentEnergy; while (_currentTemperature > _finalTemperature) { DemandsVector nextSolution = new DemandsVector(createNextSolution(currentSolution)); allocateDemands(nextSolution); _nextEnergy = _topologyGraph.ComputeCost(); if (_nextEnergy < _currentEnergy) { _currentEnergy = _nextEnergy; currentSolution = new DemandsVector(nextSolution); if (_nextEnergy < _bestEnergy) { _bestEnergy = _nextEnergy; bestSolution = new DemandsVector(nextSolution); } } else if (computeProbablity() > rnd.NextDouble()) //this returns a value in range (0.0, 0.1) by default with no arguments { _currentEnergy = _nextEnergy; currentSolution = new DemandsVector(nextSolution); } _currentTemperature = _currentTemperature * _alpha; iterations++; if (iterations > 10000) { _currentTemperature = 0.0; } } timer.Stop(); _scenario.ObjectiveFunctionResult = _bestEnergy; _scenario.ElapsedAlgorithmTime = timer.ElapsedMilliseconds; return(timer.ElapsedMilliseconds); }
public override void AllocateDemand(SpectrumPathAllocator allocator) { Path path = GetDemandPath(); allocator.AllocateFirstFreeSpectrumOnPath(path); }
public abstract void AllocateDemand(SpectrumPathAllocator allocator);