コード例 #1
0
 public static void Improve(Permutation assignment, DoubleMatrix weights, DoubleMatrix distances, DoubleValue quality, IntValue localIterations, IntValue evaluatedSolutions, bool maximization, int maxIterations, CancellationToken cancellation)
 {
     for (int i = localIterations.Value; i < maxIterations; i++)
     {
         InversionMove bestMove    = null;
         double        bestQuality = 0; // we have to make an improvement, so 0 is the baseline
         double        evaluations = 0.0;
         foreach (var move in ExhaustiveInversionMoveGenerator.Generate(assignment))
         {
             double moveQuality = QAPInversionMoveEvaluator.Apply(assignment, move, weights, distances);
             evaluations += 2 * (move.Index2 - move.Index1 + 1) / (double)assignment.Length;
             if (maximization && moveQuality > bestQuality ||
                 !maximization && moveQuality < bestQuality)
             {
                 bestQuality = moveQuality;
                 bestMove    = move;
             }
         }
         evaluatedSolutions.Value += (int)Math.Ceiling(evaluations);
         if (bestMove == null)
         {
             break;
         }
         InversionManipulator.Apply(assignment, bestMove.Index1, bestMove.Index2);
         quality.Value += bestQuality;
         localIterations.Value++;
         cancellation.ThrowIfCancellationRequested();
     }
 }
コード例 #2
0
 protected QAPInversionMoveEvaluator(QAPInversionMoveEvaluator original, Cloner cloner)
     : base(original, cloner)
 {
 }
コード例 #3
0
 protected QAPInversionMoveEvaluator(QAPInversionMoveEvaluator original, Cloner cloner)
   : base(original, cloner) {
 }