Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/11/17 15:42:12 (7 years ago)
Author:
abeham
Message:

#1614:

  • fixed some bugs introduced in last commit (project file, tests)
  • fixed ApproximateLocalSearch due to change in move evaluator that outputs an absolute quality of the move and not a delta
  • added evaluated solution counting to approximate local search
  • GRASP+PR: restructured main loop and combined iteration initialization with variable creator outside
Location:
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Evaluation/GQAPNMoveEvaluator.cs

    r15506 r15507  
    130130
    131131      MoveEvaluationParameter.ActualValue = moveEvaluation;
     132      MoveQualityParameter.ActualValue = new DoubleValue(problemInstance.ToSingleObjective(moveEvaluation));
    132133      return base.Apply();
    133134    }
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment-3.3.csproj

    r15504 r15507  
    102102    <Compile Include="GQAPAssignment.cs" />
    103103    <Compile Include="GQAPInstance.cs" />
     104    <Compile Include="Interfaces\Parameter\IAssignmentAwareGQAPOperator.cs" />
    104105    <Compile Include="Operators\Crossovers\CordeauCrossover.cs" />
    105106    <Compile Include="SolutionCreators\SlackMinimizationSolutionCreator.cs" />
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/LocalImprovers/ApproximateLocalSearch.cs

    r15506 r15507  
    106106    /// <param name="maximumIterations">The maximum number of iterations that should be performed each time the candidate list is generated.</param>
    107107    /// <param name="problemInstance">The problem instance that contains the data.</param>
     108    /// <param name="evaluatedSolutions">The number of evaluated solutions.</param>
    108109    /// <param name="oneMoveProbability">The probability for performing a 1-move, which is the opposite of performing a 2-move.</param>
    109110    public static void Apply(IRandom random, IntegerVector assignment,
    110111      DoubleValue quality, ref Evaluation evaluation, IntValue maxCLS, IntValue maximumIterations,
    111       GQAPInstance problemInstance, PercentValue oneMoveProbability) {
     112      GQAPInstance problemInstance, IntValue evaluatedSolutions, PercentValue oneMoveProbability) {
    112113      var capacities = problemInstance.Capacities;
    113114      var demands = problemInstance.Demands;
    114       //var weights = problemInstance.Weights;
    115       //var distances = problemInstance.Distances;
    116       //var installationCosts = problemInstance.InstallationCosts;
     115      var evaluations = 0.0;
     116      var deltaEvaluationFactor = 1.0 / assignment.Length;
    117117      while (true) {
    118118        int count = 0;
     
    126126         
    127127          var moveEval = GQAPNMoveEvaluator.Evaluate(move, assignment, evaluation, problemInstance);
     128          evaluations += move.NewAssignments.Count * deltaEvaluationFactor;
    128129          double moveQuality = problemInstance.ToSingleObjective(moveEval);
    129130
    130           if (moveEval.ExcessDemand <= 0.0 && moveQuality < 0.0) {
     131          if (moveEval.ExcessDemand <= 0.0 && moveQuality < quality.Value) {
    131132            CLS.Add(Tuple.Create(move, moveQuality, moveEval));
    132133            sum += 1.0 / moveQuality;
     
    135136        } while (CLS.Count < maxCLS.Value && count < maximumIterations.Value);
    136137
    137         if (CLS.Count == 0)
     138        if (CLS.Count == 0) {
     139          evaluatedSolutions.Value += (int)Math.Ceiling(evaluations);
    138140          return; // END
    139         else {
     141        } else {
    140142          var ball = random.NextDouble() * sum;
    141143          var selected = CLS.Last();
     
    148150          }
    149151          NMoveMaker.Apply(assignment, selected.Item1);
    150           quality.Value += selected.Item2;
     152          quality.Value = selected.Item2;
    151153          evaluation = selected.Item3;
    152154        }
     
    163165        MaximumIterationsParameter.ActualValue,
    164166        ProblemInstanceParameter.ActualValue,
     167        EvaluatedSolutionsParameter.ActualValue,
    165168        OneMoveProbabilityParameter.ActualValue);
    166169      EvaluationParameter.ActualValue = evaluation;
Note: See TracChangeset for help on using the changeset viewer.