public SA_Queens startSolver(ParametersOfSolver parameter) { Console.WriteLine("------Start Solver :" + parameter.numberQueens); queens = new SA_Queens(parameter.numberQueens); parameter.generateNewSolution = queens.generateRandomState(parameter.numberQueens); return(queens); }
public void solver_SA(ParametersOfSolver parameter) { Console.WriteLine("-------------solver_SA---------------"); parameter.generateNeighbor = queens.constructNeighbor(); parameter.acceptNeighbor = queens.registerNeighborAsCurrent(); Console.WriteLine("-------------solver_passo Simulated_A---------------"); SimulatedAnnealing simulated_Annealing = new SimulatedAnnealing(parameter, queens); Console.WriteLine($"Energia do Sistema: {simulated_Annealing.getEnergySystem()} ---------------"); bool done = false; while (!done) { Console.WriteLine("-------------Realizando Tentativa---------------"); done = simulated_Annealing.simulationStep(); Console.WriteLine($"Energia do Sistema: {simulated_Annealing.getEnergySystem()} ---------------"); Console.WriteLine($"Energia do Sistema: {simulated_Annealing.getTemperatureSystem()} ---------------"); if (done) { break; } } Console.WriteLine("-------------Concluido---------------"); }
public SimulatedAnnealing(ParametersOfSolver parameter, SA_Queens queensUtil) { this.QueensUtil = queensUtil; parameterSA = new ParametersOfSA(); parameterSA.numberQueens = parameter.numberQueens; parameterSA.coolingFactor = parameter.coolingFactor; parameterSA.stabilizingFactor = parameter.stabilizingFactor; parameterSA.freezingTemperature = parameter.freezingTemperature; parameterSA.generateNewSolution = parameter.generateNewSolution; parameterSA.generateNeighbor = parameter.generateNeighbor; parameterSA.acceptNeighbor = parameter.acceptNeighbor; parameterSA.currentSystemEnergy = QueensUtil.generateRandomState(parameterSA.numberQueens); parameterSA.currentSystemTemperature = parameter.initialTemperature; parameterSA.currentStabilizer = parameter.initialstabilizer; }