public static void Improve(IRandom random, Permutation assignment, DoubleMatrix weights, DoubleMatrix distances, DoubleValue quality, IntValue localIterations, IntValue evaluatedSolutions, bool maximization, int maxIterations, int neighborhoodSize, CancellationToken cancellation)
 {
     for (int i = localIterations.Value; i < maxIterations; i++)
     {
         ScrambleMove bestMove    = null;
         double       bestQuality = 0; // we have to make an improvement, so 0 is the baseline
         double       evaluations = 0.0;
         for (int j = 0; j < neighborhoodSize; j++)
         {
             var    move        = StochasticScrambleMultiMoveGenerator.GenerateRandomMove(assignment, random);
             double moveQuality = QAPScrambleMoveEvaluator.Apply(assignment, move, weights, distances);
             evaluations += 2.0 * move.ScrambledIndices.Length / assignment.Length;
             if (maximization && moveQuality > bestQuality ||
                 !maximization && moveQuality < bestQuality)
             {
                 bestQuality = moveQuality;
                 bestMove    = move;
             }
         }
         evaluatedSolutions.Value += (int)Math.Ceiling(evaluations);
         if (bestMove == null)
         {
             break;
         }
         ScrambleManipulator.Apply(assignment, bestMove.StartIndex, bestMove.ScrambledIndices);
         quality.Value += bestQuality;
         localIterations.Value++;
         cancellation.ThrowIfCancellationRequested();
     }
 }
 protected QAPScrambleMoveEvaluator(QAPScrambleMoveEvaluator original, Cloner cloner)
   : base(original, cloner) {
 }
Пример #3
0
 protected QAPScrambleMoveEvaluator(QAPScrambleMoveEvaluator original, Cloner cloner)
     : base(original, cloner)
 {
 }