Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/17/11 18:22:28 (13 years ago)
Author:
cneumuel
Message:

#1215

  • support for maximization problems
  • made base level algorithms stoppable
  • optimization for multiple goals possible (AverageQuality, AverageDeviation, AverageEvaluatedSolutions)
  • lots of fixes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/AlgorithmExecutor.cs

    r5653 r6018  
    1010      executor.StartSync();
    1111    }
     12    public static void StartSync(this IAlgorithm algorithm, CancellationToken cancellationToken) {
     13      var executor = new AlgorithmExecutor(algorithm, cancellationToken);
     14      executor.StartSync();
     15    }
    1216  }
    1317
     
    1822    private IAlgorithm algorithm;
    1923    private AutoResetEvent waitHandle = new AutoResetEvent(false);
     24    private CancellationToken cancellationToken;
     25    private bool useCancellationToken = false;
    2026
    2127    public AlgorithmExecutor(IAlgorithm algorithm) {
     
    2329    }
    2430
     31    public AlgorithmExecutor(IAlgorithm algorithm, CancellationToken cancellationToken) {
     32      this.algorithm = algorithm;
     33      this.cancellationToken = cancellationToken;
     34      this.useCancellationToken = true;
     35    }
     36
    2537    public void StartSync() {
    2638      algorithm.Stopped += new EventHandler(algorithm_Stopped);
    2739      algorithm.Paused += new EventHandler(algorithm_Paused);
    28       algorithm.Start();
     40     
     41      if(useCancellationToken && algorithm is EngineAlgorithm && ((EngineAlgorithm)algorithm).Engine is SequentialEngine.SequentialEngine) {
     42        ((SequentialEngine.SequentialEngine)((EngineAlgorithm)algorithm).Engine).Start(cancellationToken);
     43      } else {
     44        algorithm.Start();
     45      }
     46
    2947      waitHandle.WaitOne();
    3048      waitHandle.Dispose();
Note: See TracChangeset for help on using the changeset viewer.