コード例 #1
0
 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;
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
                }
            }
        }
コード例 #4
0
        protected override int[] RandomSolution()
        {
            int[] solution;

            if (generatedSolutions < 2)
            {
                solution = QAPUtils.GRCSolution(Instance, 1.0);
            }
            else
            {
                solution = QAPUtils.RandomSolution(Instance);
            }

            generatedSolutions++;
            return(solution);
        }
コード例 #5
0
 protected override void Repair(int[] solution)
 {
     QAPUtils.Repair(Instance, solution);
 }
コード例 #6
0
 protected override double Fitness(int[] solution)
 {
     return(QAPUtils.Fitness(Instance, solution));
 }
コード例 #7
0
 protected override int[] GRCSolution()
 {
     return(QAPUtils.GRCSolution(Instance, RCLThreshold));
 }
 protected override int[] GetNeighbor(int[] solution)
 {
     return(QAPUtils.GetNeighbor(Instance, solution));
 }
コード例 #9
0
 protected override void PerturbateSolution(int[] solution, int perturbation)
 {
     QAPUtils.PerturbateSolution(solution, perturbation);
 }
コード例 #10
0
 protected override int[] InitialSolution()
 {
     return(QAPUtils.GRCSolution(Instance, RclTreshold));
 }
コード例 #11
0
 protected override void LocalSearch(int[] individual)
 {
     QAPUtils.LocalSearch2OptFirst(Instance, individual);
 }
コード例 #12
0
 protected override void Repair(int[] individual)
 {
     QAPUtils.Repair(Instance, individual);
 }
コード例 #13
0
 public override void LocalSearch(int[] solution)
 {
     QAPUtils.LocalSearch2OptBest(Instance, solution);
 }
コード例 #14
0
 protected override Tuple <int, int> GetTabu(int[] current, int[] neighbor)
 {
     return(QAPUtils.GetTabu(current, neighbor));
 }
コード例 #15
0
 protected override void Improve(int[] solution)
 {
     QAPUtils.LocalSearch2OptFirst(Instance, solution);
 }
コード例 #16
0
 protected override double Distance(int[] a, int[] b)
 {
     return(QAPUtils.Distance(Instance, a, b));
 }
コード例 #17
0
 protected override double Fitness(int[] individual)
 {
     return(QAPUtils.Fitness(Instance, individual));
 }