Changeset 17321


Ignore:
Timestamp:
10/06/19 22:51:53 (8 days ago)
Author:
abeham
Message:

#2521: fixed compile errors in Tests

Location:
branches/2521_ProblemRefactoring/HeuristicLab.Tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Problems.QuadraticAssignment-3.3/QAPMoveEvaluatorTest.cs

    r17226 r17321  
    2121
    2222using System;
     23using System.Threading;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Data;
     
    113114        double moveAfter = QAPSwap2MoveEvaluator.Apply(assignment, currentMove,
    114115                moveBefore, symmetricWeights, symmetricDistances, lastMove);
    115         double before = symmetricProblem.Evaluate(assignment);
    116         double after = symmetricProblem.Evaluate(nextAssignment);
     116        double before = symmetricProblem.Evaluate(assignment, CancellationToken.None);
     117        double after = symmetricProblem.Evaluate(nextAssignment, CancellationToken.None);
    117118
    118119        Assert.IsTrue(moveAfter.IsAlmost(after - before), "Failed on symmetric matrices: " + Environment.NewLine
     
    122123        moveAfter = QAPSwap2MoveEvaluator.Apply(assignment, currentMove,
    123124                moveBefore, asymmetricWeights, asymmetricDistances, lastMove);
    124         before = asymmetricProblem.Evaluate(assignment);
    125         after = asymmetricProblem.Evaluate(nextAssignment);
     125        before = asymmetricProblem.Evaluate(assignment, CancellationToken.None);
     126        after = asymmetricProblem.Evaluate(nextAssignment, CancellationToken.None);
    126127
    127128        Assert.IsTrue(moveAfter.IsAlmost(after - before), "Failed on asymmetric matrices: " + Environment.NewLine
     
    131132        moveAfter = QAPSwap2MoveEvaluator.Apply(assignment, currentMove,
    132133                moveBefore, nonZeroDiagonalWeights, nonZeroDiagonalDistances, lastMove);
    133         before = nonZeroDiagonalProblem.Evaluate(assignment);
    134         after = nonZeroDiagonalProblem.Evaluate(nextAssignment);
     134        before = nonZeroDiagonalProblem.Evaluate(assignment, CancellationToken.None);
     135        after = nonZeroDiagonalProblem.Evaluate(nextAssignment, CancellationToken.None);
    135136
    136137        Assert.IsTrue(moveAfter.IsAlmost(after - before), "Failed on non-zero diagonal matrices: " + Environment.NewLine
     
    149150
    150151        // SYMMETRIC MATRICES
    151         double before = symmetricProblem.Evaluate(assignment);
     152        double before = symmetricProblem.Evaluate(assignment, CancellationToken.None);
    152153        Swap2Manipulator.Apply(assignment, index1, index2);
    153         double after = symmetricProblem.Evaluate(assignment);
     154        double after = symmetricProblem.Evaluate(assignment, CancellationToken.None);
    154155        double move = QAPSwap2MoveEvaluator.Apply(assignment, new Swap2Move(index1, index2, assignment), symmetricWeights, symmetricDistances);
    155156        Assert.IsTrue(move.IsAlmost(before - after), "Failed on symmetric matrices");
    156157
    157158        // ASYMMETRIC MATRICES
    158         before = asymmetricProblem.Evaluate(assignment);
     159        before = asymmetricProblem.Evaluate(assignment, CancellationToken.None);
    159160        Permutation clone = (Permutation)assignment.Clone();
    160161        Swap2Manipulator.Apply(assignment, index1, index2);
    161         after = asymmetricProblem.Evaluate(assignment);
     162        after = asymmetricProblem.Evaluate(assignment, CancellationToken.None);
    162163        move = QAPSwap2MoveEvaluator.Apply(clone, new Swap2Move(index1, index2), asymmetricWeights, asymmetricDistances);
    163164        Assert.IsTrue(move.IsAlmost(after - before), "Failed on asymmetric matrices");
    164165
    165166        // NON-ZERO DIAGONAL ASSYMETRIC MATRICES
    166         before = nonZeroDiagonalProblem.Evaluate(assignment);
     167        before = nonZeroDiagonalProblem.Evaluate(assignment, CancellationToken.None);
    167168        clone = (Permutation)assignment.Clone();
    168169        Swap2Manipulator.Apply(assignment, index1, index2);
    169         after = nonZeroDiagonalProblem.Evaluate(assignment);
     170        after = nonZeroDiagonalProblem.Evaluate(assignment, CancellationToken.None);
    170171        move = QAPSwap2MoveEvaluator.Apply(clone, new Swap2Move(index1, index2), nonZeroDiagonalWeights, nonZeroDiagonalDistances);
    171172        Assert.IsTrue(move.IsAlmost(after - before), "Failed on non-zero diagonal matrices");
     
    183184
    184185        // SYMMETRIC MATRICES
    185         double before = symmetricProblem.Evaluate(assignment);
     186        double before = symmetricProblem.Evaluate(assignment, CancellationToken.None);
    186187        InversionManipulator.Apply(assignment, Math.Min(index1, index2), Math.Max(index1, index2));
    187         double after = symmetricProblem.Evaluate(assignment);
     188        double after = symmetricProblem.Evaluate(assignment, CancellationToken.None);
    188189        double move = QAPInversionMoveEvaluator.Apply(assignment, new InversionMove(index1, index2, assignment), symmetricWeights, symmetricDistances);
    189190        Assert.IsTrue(move.IsAlmost(before - after), "Failed on symmetric matrices");
    190191
    191192        // ASYMMETRIC MATRICES
    192         before = asymmetricProblem.Evaluate(assignment);
     193        before = asymmetricProblem.Evaluate(assignment, CancellationToken.None);
    193194        Permutation clone = (Permutation)assignment.Clone();
    194195        InversionManipulator.Apply(assignment, index1, index2);
    195         after = asymmetricProblem.Evaluate(assignment);
     196        after = asymmetricProblem.Evaluate(assignment, CancellationToken.None);
    196197        move = QAPInversionMoveEvaluator.Apply(clone, new InversionMove(index1, index2), asymmetricWeights, asymmetricDistances);
    197198        Assert.IsTrue(move.IsAlmost(after - before), "Failed on asymmetric matrices");
    198199
    199200        // NON-ZERO DIAGONAL ASYMMETRIC MATRICES
    200         before = nonZeroDiagonalProblem.Evaluate(assignment);
     201        before = nonZeroDiagonalProblem.Evaluate(assignment, CancellationToken.None);
    201202        clone = (Permutation)assignment.Clone();
    202203        InversionManipulator.Apply(assignment, index1, index2);
    203         after = nonZeroDiagonalProblem.Evaluate(assignment);
     204        after = nonZeroDiagonalProblem.Evaluate(assignment, CancellationToken.None);
    204205        move = QAPInversionMoveEvaluator.Apply(clone, new InversionMove(index1, index2), nonZeroDiagonalWeights, nonZeroDiagonalDistances);
    205206        Assert.IsTrue(move.IsAlmost(after - before), "Failed on non-zero diagonal matrices");
     
    222223
    223224        // SYMMETRIC MATRICES
    224         double before = symmetricProblem.Evaluate(assignment);
     225        double before = symmetricProblem.Evaluate(assignment, CancellationToken.None);
    225226        Permutation clone = new Cloner().Clone(assignment);
    226227        TranslocationManipulator.Apply(assignment, index1, index2, insertPoint);
    227         double after = symmetricProblem.Evaluate(assignment);
     228        double after = symmetricProblem.Evaluate(assignment, CancellationToken.None);
    228229        double move = QAPTranslocationMoveEvaluator.Apply(clone, new TranslocationMove(index1, index2, insertPoint, assignment), symmetricWeights, symmetricDistances);
    229230        Assert.IsTrue(move.IsAlmost(after - before), "Failed on symmetric matrices");
    230231
    231232        // ASYMMETRIC MATRICES
    232         before = asymmetricProblem.Evaluate(assignment);
     233        before = asymmetricProblem.Evaluate(assignment, CancellationToken.None);
    233234        clone = new Cloner().Clone(assignment);
    234235        TranslocationManipulator.Apply(assignment, index1, index2, insertPoint);
    235         after = asymmetricProblem.Evaluate(assignment);
     236        after = asymmetricProblem.Evaluate(assignment, CancellationToken.None);
    236237        move = QAPTranslocationMoveEvaluator.Apply(clone, new TranslocationMove(index1, index2, insertPoint, assignment), asymmetricWeights, asymmetricDistances);
    237238        Assert.IsTrue(move.IsAlmost(after - before), "Failed on asymmetric matrices");
    238239
    239240        // NON-ZERO DIAGONAL ASYMMETRIC MATRICES
    240         before = nonZeroDiagonalProblem.Evaluate(assignment);
     241        before = nonZeroDiagonalProblem.Evaluate(assignment, CancellationToken.None);
    241242        clone = new Cloner().Clone(assignment);
    242243        TranslocationManipulator.Apply(assignment, index1, index2, insertPoint);
    243         after = nonZeroDiagonalProblem.Evaluate(assignment);
     244        after = nonZeroDiagonalProblem.Evaluate(assignment, CancellationToken.None);
    244245        move = QAPTranslocationMoveEvaluator.Apply(clone, new TranslocationMove(index1, index2, insertPoint, assignment), nonZeroDiagonalWeights, nonZeroDiagonalDistances);
    245246        Assert.IsTrue(move.IsAlmost(after - before), "Failed on non-zero diagonal matrices");
     
    255256
    256257        // SYMMETRIC MATRICES
    257         double before = symmetricProblem.Evaluate(assignment);
     258        double before = symmetricProblem.Evaluate(assignment, CancellationToken.None);
    258259        double move = QAPScrambleMoveEvaluator.Apply(assignment, scramble, symmetricWeights, symmetricDistances);
    259260        ScrambleManipulator.Apply(assignment, scramble.StartIndex, scramble.ScrambledIndices);
    260         double after = symmetricProblem.Evaluate(assignment);
     261        double after = symmetricProblem.Evaluate(assignment, CancellationToken.None);
    261262        Assert.IsTrue(move.IsAlmost(after - before), "Failed on symmetric matrices");
    262263
    263264        // ASYMMETRIC MATRICES
    264         before = asymmetricProblem.Evaluate(assignment);
     265        before = asymmetricProblem.Evaluate(assignment, CancellationToken.None);
    265266        move = QAPScrambleMoveEvaluator.Apply(assignment, scramble, asymmetricWeights, asymmetricDistances);
    266267        ScrambleManipulator.Apply(assignment, scramble.StartIndex, scramble.ScrambledIndices);
    267         after = asymmetricProblem.Evaluate(assignment);
     268        after = asymmetricProblem.Evaluate(assignment, CancellationToken.None);
    268269        Assert.IsTrue(move.IsAlmost(after - before), "Failed on asymmetric matrices");
    269270
    270271        // NON-ZERO DIAGONAL ASYMMETRIC MATRICES
    271         before = nonZeroDiagonalProblem.Evaluate(assignment);
     272        before = nonZeroDiagonalProblem.Evaluate(assignment, CancellationToken.None);
    272273        move = QAPScrambleMoveEvaluator.Apply(assignment, scramble, nonZeroDiagonalWeights, nonZeroDiagonalDistances);
    273274        ScrambleManipulator.Apply(assignment, scramble.StartIndex, scramble.ScrambledIndices);
    274         after = nonZeroDiagonalProblem.Evaluate(assignment);
     275        after = nonZeroDiagonalProblem.Evaluate(assignment, CancellationToken.None);
    275276        Assert.IsTrue(move.IsAlmost(after - before), "Failed on non-zero diagonal matrices");
    276277      }
  • branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Script Sources/GAQAPScriptSource.cs

    r13408 r17321  
    11using System;
    22using System.Linq;
    3 
     3using System.Threading;
    44using HeuristicLab.Analysis;
    55using HeuristicLab.Data;
     
    4242    for (int i = 0; i < popSize; i++) {
    4343      population[i] = new Permutation(PermutationTypes.Absolute, qap.Weights.Rows, random);
    44       qualities[i] = qap.Evaluate(population[i]);
     44      qualities[i] = qap.Evaluate(population[i], CancellationToken.None);
    4545    }
    4646    var bestQuality = qualities.Min();
     
    5252        nextGen[i] = PartiallyMatchedCrossover.Apply(random, parents[i * 2], parents[i * 2 + 1]);
    5353        if (random.NextDouble() < mutationRate) Swap2Manipulator.Apply(random, nextGen[i]);
    54         nextQual[i] = qap.Evaluate(nextGen[i]);
     54        nextQual[i] = qap.Evaluate(nextGen[i], CancellationToken.None);
    5555        if (nextQual[i] < bestQuality) {
    5656          bestQuality = nextQual[i];
Note: See TracChangeset for help on using the changeset viewer.