Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5352 for trunk


Ignore:
Timestamp:
01/21/11 22:51:59 (14 years ago)
Author:
abeham
Message:

#1333

  • Removed changes to IntCounter that would make it thread-safe, if a thread-safe operator is needed a separate one should be implemented
  • Moved counting of evaluated solutions out of the parallel region
Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithm.cs

    r5346 r5352  
    135135    }
    136136    private GeneticAlgorithmMainLoop GeneticAlgorithmMainLoop {
    137       get { return (GeneticAlgorithmMainLoop)((Assigner)SolutionsCreator.Successor).Successor; }
     137      get { return (GeneticAlgorithmMainLoop)((SubScopesCounter)SolutionsCreator.Successor).Successor; }
    138138    }
    139139    [Storable]
     
    156156      RandomCreator randomCreator = new RandomCreator();
    157157      SolutionsCreator solutionsCreator = new SolutionsCreator();
    158       Assigner assigner = new Assigner();
     158      SubScopesCounter subScopesCounter = new SubScopesCounter();
    159159      GeneticAlgorithmMainLoop geneticAlgorithmMainLoop = new GeneticAlgorithmMainLoop();
    160160      OperatorGraph.InitialOperator = randomCreator;
     
    168168
    169169      solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
    170       solutionsCreator.Successor = assigner;
    171 
    172       assigner.Name = "Initialize EvaluatedSolutions";
    173       assigner.LeftSideParameter.ActualName = "EvaluatedSolutions";
    174       assigner.RightSideParameter.ActualName = PopulationSizeParameter.Name;
    175       assigner.Successor = geneticAlgorithmMainLoop;
     170      solutionsCreator.Successor = subScopesCounter;
     171
     172      subScopesCounter.Name = "Initialize EvaluatedSolutions";
     173      subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions";
     174      subScopesCounter.Successor = geneticAlgorithmMainLoop;
    176175
    177176      geneticAlgorithmMainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithmMainLoop.cs

    r5346 r5352  
    134134      UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
    135135      Placeholder evaluator = new Placeholder();
    136       IntCounter intCounter1 = new IntCounter();
     136      SubScopesCounter subScopesCounter = new SubScopesCounter();
    137137      SubScopesProcessor subScopesProcessor2 = new SubScopesProcessor();
    138138      BestSelector bestSelector = new BestSelector();
    139139      RightReducer rightReducer = new RightReducer();
    140140      MergingReducer mergingReducer = new MergingReducer();
    141       IntCounter intCounter2 = new IntCounter();
     141      IntCounter intCounter = new IntCounter();
    142142      Comparator comparator = new Comparator();
    143143      ResultsCollector resultsCollector2 = new ResultsCollector();
     
    175175      evaluator.OperatorParameter.ActualName = "Evaluator";
    176176
    177       intCounter1.Name = "Increment EvaluatedSolutions";
    178       intCounter1.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
    179       intCounter1.Increment = null;
    180       intCounter1.IncrementParameter.ActualName = PopulationSizeParameter.Name;
     177      subScopesCounter.Name = "Increment EvaluatedSolutions";
     178      subScopesCounter.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
    181179
    182180      bestSelector.CopySelected = new BoolValue(false);
     
    185183      bestSelector.QualityParameter.ActualName = "Quality";
    186184
    187       intCounter2.Increment = new IntValue(1);
    188       intCounter2.ValueParameter.ActualName = "Generations";
     185      intCounter.Increment = new IntValue(1);
     186      intCounter.ValueParameter.ActualName = "Generations";
    189187
    190188      comparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
     
    222220      subScopesRemover.Successor = null;
    223221      uniformSubScopesProcessor2.Operator = evaluator;
    224       uniformSubScopesProcessor2.Successor = intCounter1;
     222      uniformSubScopesProcessor2.Successor = subScopesCounter;
    225223      evaluator.Successor = null;
    226       intCounter1.Successor = null;
     224      subScopesCounter.Successor = null;
    227225      subScopesProcessor2.Operators.Add(bestSelector);
    228226      subScopesProcessor2.Operators.Add(new EmptyOperator());
     
    230228      bestSelector.Successor = rightReducer;
    231229      rightReducer.Successor = null;
    232       mergingReducer.Successor = intCounter2;
    233       intCounter2.Successor = comparator;
     230      mergingReducer.Successor = intCounter;
     231      intCounter.Successor = comparator;
    234232      comparator.Successor = resultsCollector2;
    235233      resultsCollector2.Successor = analyzer2;
  • trunk/sources/HeuristicLab.Operators/3.3/IntCounter.cs

    r5208 r5352  
    3333  [StorableClass]
    3434  public sealed class IntCounter : SingleSuccessorOperator {
    35     private object locker = new object();
    3635
    3736    public LookupParameter<IntValue> ValueParameter {
     
    6261
    6362    public override IOperation Apply() {
    64       lock (locker) {
    65         if (ValueParameter.ActualValue == null) ValueParameter.ActualValue = new IntValue();
    66         ValueParameter.ActualValue.Value += IncrementParameter.ActualValue.Value;
    67       }
     63      if (ValueParameter.ActualValue == null) ValueParameter.ActualValue = new IntValue();
     64      ValueParameter.ActualValue.Value += IncrementParameter.ActualValue.Value;
    6865      return base.Apply();
    6966    }
Note: See TracChangeset for help on using the changeset viewer.