Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/30/17 23:10:29 (6 years ago)
Author:
abeham
Message:

#1614:

  • Added LAHC and pLAHC-s
  • Changed all algorithms to update high frequency results only every second
Location:
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/LocalSearch
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/LocalSearch/IteratedLS.cs

    r15562 r15563  
    3333  [Creatable(CreatableAttribute.Categories.SingleSolutionAlgorithms)]
    3434  [StorableClass]
    35   public sealed class IteratedLS : ContextAlgorithm<LocalSearchContext> {
     35  public sealed class IteratedLS : StochasticAlgorithm<LocalSearchContext> {
    3636
    3737    public override bool SupportsPause {
     
    9292
    9393    protected override void Run(CancellationToken cancellationToken) {
     94      var lastUpdate = ExecutionTime;
     95
    9496      while (!StoppingCriterion()) {
    9597        var lsevaluations = 0;
     
    109111
    110112        IResult result;
    111         if (Results.TryGetValue("Iterations", out result))
    112           ((IntValue)result.Value).Value = Context.Iterations;
    113         else Results.Add(new Result("Iterations", new IntValue(Context.Iterations)));
    114         if (Results.TryGetValue("EvaluatedSolutions", out result))
    115           ((IntValue)result.Value).Value = Context.EvaluatedSolutions;
    116         else Results.Add(new Result("EvaluatedSolutions", new IntValue(Context.EvaluatedSolutions)));
     113        if (ExecutionTime - lastUpdate > TimeSpan.FromSeconds(1)) {
     114          if (Results.TryGetValue("Iterations", out result))
     115            ((IntValue)result.Value).Value = Context.Iterations;
     116          else Results.Add(new Result("Iterations", new IntValue(Context.Iterations)));
     117          if (Results.TryGetValue("EvaluatedSolutions", out result))
     118            ((IntValue)result.Value).Value = Context.EvaluatedSolutions;
     119          else Results.Add(new Result("EvaluatedSolutions", new IntValue(Context.EvaluatedSolutions)));
     120          lastUpdate = ExecutionTime;
     121        }
    117122        if (Results.TryGetValue("BestQuality", out result))
    118123          ((DoubleValue)result.Value).Value = Context.BestQuality;
     
    127132        if (cancellationToken.IsCancellationRequested) break;
    128133      }
     134      IResult result2;
     135      if (Results.TryGetValue("Iterations", out result2))
     136        ((IntValue)result2.Value).Value = Context.Iterations;
     137      else Results.Add(new Result("Iterations", new IntValue(Context.Iterations)));
     138      if (Results.TryGetValue("EvaluatedSolutions", out result2))
     139        ((IntValue)result2.Value).Value = Context.EvaluatedSolutions;
     140      else Results.Add(new Result("EvaluatedSolutions", new IntValue(Context.EvaluatedSolutions)));
    129141    }
    130142
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/LocalSearch/MultistartLS.cs

    r15562 r15563  
    3333  [Creatable(CreatableAttribute.Categories.SingleSolutionAlgorithms)]
    3434  [StorableClass]
    35   public sealed class MultistartLS : ContextAlgorithm<LocalSearchContext> {
     35  public sealed class MultistartLS : StochasticAlgorithm<LocalSearchContext> {
    3636
    3737    public override bool SupportsPause {
     
    7171
    7272    protected override void Run(CancellationToken cancellationToken) {
     73      var lastUpdate = ExecutionTime;
     74
    7375      while (!StoppingCriterion()) {
    7476        var lsevaluations = 0;
     
    8991
    9092        IResult result;
    91         if (Results.TryGetValue("Iterations", out result))
    92           ((IntValue)result.Value).Value = Context.Iterations;
    93         else Results.Add(new Result("Iterations", new IntValue(Context.Iterations)));
    94         if (Results.TryGetValue("EvaluatedSolutions", out result))
    95           ((IntValue)result.Value).Value = Context.EvaluatedSolutions;
    96         else Results.Add(new Result("EvaluatedSolutions", new IntValue(Context.EvaluatedSolutions)));
     93        if (ExecutionTime - lastUpdate > TimeSpan.FromSeconds(1)) {
     94          if (Results.TryGetValue("Iterations", out result))
     95            ((IntValue)result.Value).Value = Context.Iterations;
     96          else Results.Add(new Result("Iterations", new IntValue(Context.Iterations)));
     97          if (Results.TryGetValue("EvaluatedSolutions", out result))
     98            ((IntValue)result.Value).Value = Context.EvaluatedSolutions;
     99          else Results.Add(new Result("EvaluatedSolutions", new IntValue(Context.EvaluatedSolutions)));
     100          lastUpdate = ExecutionTime;
     101        }
    97102        if (Results.TryGetValue("BestQuality", out result))
    98103          ((DoubleValue)result.Value).Value = Context.BestQuality;
     
    107112        if (cancellationToken.IsCancellationRequested) break;
    108113      }
     114
     115      IResult result2;
     116      if (Results.TryGetValue("Iterations", out result2))
     117        ((IntValue)result2.Value).Value = Context.Iterations;
     118      else Results.Add(new Result("Iterations", new IntValue(Context.Iterations)));
     119      if (Results.TryGetValue("EvaluatedSolutions", out result2))
     120        ((IntValue)result2.Value).Value = Context.EvaluatedSolutions;
     121      else Results.Add(new Result("EvaluatedSolutions", new IntValue(Context.EvaluatedSolutions)));
    109122    }
    110123  }
Note: See TracChangeset for help on using the changeset viewer.