public MaxMinAntSystem2OptBest4QAP(QAPInstance instance, int numberAnts, double rho, double alpha, double beta, int maxReinit) : base(instance.NumberFacilities, QAPUtils.Fitness(instance, QAPUtils.RandomSolution(instance)), numberAnts, rho, alpha, beta, maxReinit) { Instance = instance; }
public void Start(string fileInput, string fileOutput, int timeLimit) { QAPInstance instance = new QAPInstance(fileInput); int[] assignment = QAPUtils.GRCSolution(instance, 1.0); QAPUtils.LocalSearch2OptFirst(instance, assignment); QAPSolution solution = new QAPSolution(instance, assignment); solution.Write(fileOutput); }
public void Write(string file) { double cost = QAPUtils.Fitness(Instance, Assignment); using (StreamWriter writer = File.CreateText(file)) { writer.WriteLine(cost); writer.WriteLine(Instance.NumberFacilities); for (int i = 0; i < Instance.NumberFacilities; i++) { writer.WriteLine(Assignment[i] + 1); } } }
protected override int[] RandomSolution() { int[] solution; if (generatedSolutions < 2) { solution = QAPUtils.GRCSolution(Instance, 1.0); } else { solution = QAPUtils.RandomSolution(Instance); } generatedSolutions++; return(solution); }
protected override void Repair(int[] solution) { QAPUtils.Repair(Instance, solution); }
protected override double Fitness(int[] solution) { return(QAPUtils.Fitness(Instance, solution)); }
protected override int[] GRCSolution() { return(QAPUtils.GRCSolution(Instance, RCLThreshold)); }
protected override int[] GetNeighbor(int[] solution) { return(QAPUtils.GetNeighbor(Instance, solution)); }
protected override void PerturbateSolution(int[] solution, int perturbation) { QAPUtils.PerturbateSolution(solution, perturbation); }
protected override int[] InitialSolution() { return(QAPUtils.GRCSolution(Instance, RclTreshold)); }
protected override void LocalSearch(int[] individual) { QAPUtils.LocalSearch2OptFirst(Instance, individual); }
protected override void Repair(int[] individual) { QAPUtils.Repair(Instance, individual); }
public override void LocalSearch(int[] solution) { QAPUtils.LocalSearch2OptBest(Instance, solution); }
protected override Tuple <int, int> GetTabu(int[] current, int[] neighbor) { return(QAPUtils.GetTabu(current, neighbor)); }
protected override void Improve(int[] solution) { QAPUtils.LocalSearch2OptFirst(Instance, solution); }
protected override double Distance(int[] a, int[] b) { return(QAPUtils.Distance(Instance, a, b)); }
protected override double Fitness(int[] individual) { return(QAPUtils.Fitness(Instance, individual)); }