Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3490 for trunk/sources


Ignore:
Timestamp:
04/22/10 17:22:35 (15 years ago)
Author:
abeham
Message:

updated SASEGASA #839
added final maximum selection pressure for the last village

Location:
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3
Files:
2 edited

Legend:

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

    r3479 r3490  
    103103      get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
    104104    }
     105    private ValueLookupParameter<DoubleValue> FinalMaximumSelectionPressureParameter {
     106      get { return (ValueLookupParameter<DoubleValue>)Parameters["FinalMaximumSelectionPressure"]; }
     107    }
    105108    private ValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
    106109      get { return (ValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
     
    153156      set { ParallelParameter.Value = value; }
    154157    }
    155     private DoubleValue SuccessRatio {
     158    public DoubleValue SuccessRatio {
    156159      get { return SuccessRatioParameter.Value; }
    157160      set { SuccessRatioParameter.Value = value; }
    158161    }
    159     private DoubleValue ComparisonFactorLowerBound {
     162    public DoubleValue ComparisonFactorLowerBound {
    160163      get { return ComparisonFactorLowerBoundParameter.Value; }
    161164      set { ComparisonFactorLowerBoundParameter.Value = value; }
    162165    }
    163     private DoubleValue ComparisonFactorUpperBound {
     166    public DoubleValue ComparisonFactorUpperBound {
    164167      get { return ComparisonFactorUpperBoundParameter.Value; }
    165168      set { ComparisonFactorUpperBoundParameter.Value = value; }
    166169    }
    167     private IDiscreteDoubleValueModifier ComparisonFactorModifier {
     170    public IDiscreteDoubleValueModifier ComparisonFactorModifier {
    168171      get { return ComparisonFactorModifierParameter.Value; }
    169172      set { ComparisonFactorModifierParameter.Value = value; }
    170173    }
    171     private DoubleValue MaximumSelectionPressure {
     174    public DoubleValue MaximumSelectionPressure {
    172175      get { return MaximumSelectionPressureParameter.Value; }
    173176      set { MaximumSelectionPressureParameter.Value = value; }
    174177    }
    175     private BoolValue OffspringSelectionBeforeMutation {
     178    public DoubleValue FinalMaximumSelectionPressure {
     179      get { return FinalMaximumSelectionPressureParameter.Value; }
     180      set { FinalMaximumSelectionPressureParameter.Value = value; }
     181    }
     182    public BoolValue OffspringSelectionBeforeMutation {
    176183      get { return OffspringSelectionBeforeMutationParameter.Value; }
    177184      set { OffspringSelectionBeforeMutationParameter.Value = value; }
     
    216223      Parameters.Add(new OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>("ComparisonFactorModifier", "The operator used to modify the comparison factor.", new ItemSet<IDiscreteDoubleValueModifier>(new IDiscreteDoubleValueModifier[] { new LinearDiscreteDoubleValueModifier() }), new LinearDiscreteDoubleValueModifier()));
    217224      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.", new DoubleValue(100)));
     225      Parameters.Add(new ValueLookupParameter<DoubleValue>("FinalMaximumSelectionPressure", "The maximum selection pressure used when there is only one village left.", new DoubleValue(100)));
    218226      Parameters.Add(new ValueLookupParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation.", new BoolValue(false)));
    219227
     
    257265      mainLoop.ComparisonFactorUpperBoundParameter.ActualName = ComparisonFactorUpperBoundParameter.Name;
    258266      mainLoop.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
     267      mainLoop.FinalMaximumSelectionPressureParameter.ActualName = FinalMaximumSelectionPressureParameter.Name;
    259268      mainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name;
    260269      mainLoop.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
  • trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SASEGASAMainLoop.cs

    r3489 r3490  
    102102    public ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
    103103      get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
     104    }
     105    public ValueLookupParameter<DoubleValue> FinalMaximumSelectionPressureParameter {
     106      get { return (ValueLookupParameter<DoubleValue>)Parameters["FinalMaximumSelectionPressure"]; }
    104107    }
    105108    public ValueLookupParameter<IntValue> MaximumGenerationsParameter {
     
    136139      Parameters.Add(new ValueLookupParameter<IOperator>("ComparisonFactorModifier", "The operator used to modify the comparison factor."));
    137140      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm."));
     141      Parameters.Add(new ValueLookupParameter<DoubleValue>("FinalMaximumSelectionPressure", "The maximum selection pressure used when there is only one village left."));
    138142      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum genreation that terminates the algorithm."));
    139143      Parameters.Add(new ValueLookupParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation."));
     
    142146      #region Create operators
    143147      VariableCreator variableCreator = new VariableCreator();
     148      Assigner maxSelPressAssigner = new Assigner();
    144149      Assigner villageCountAssigner = new Assigner();
    145150      Assigner comparisonFactorInitializer = new Assigner();
     
    171176      IntCounter villageMaximumGenerationsCounter = new IntCounter();
    172177      DataTableValuesCollector selPressValuesCollector2 = new DataTableValuesCollector();
    173       Comparator villageCountComparator = new Comparator();
    174       ConditionalBranch villageTerminationCondition0 = new ConditionalBranch();
     178      Comparator villageCountComparator1 = new Comparator();
     179      ConditionalBranch villageTerminationCondition1 = new ConditionalBranch();
    175180      SASEGASAReunificator reunificator = new SASEGASAReunificator();
    176181      IntCounter reunificationCounter = new IntCounter();
    177182      Placeholder comparisonFactorModifier = new Placeholder();
     183      Comparator villageCountComparator2 = new Comparator();
     184      ConditionalBranch villageTerminationCondition2 = new ConditionalBranch();
     185      Assigner finalMaxSelPressAssigner = new Assigner();
    178186      Comparator maximumGenerationsComparator = new Comparator();
    179187      BestQualityMemorizer bestQualityMemorizer3 = new BestQualityMemorizer();
     
    181189      DataTableValuesCollector dataTableValuesCollector2 = new DataTableValuesCollector();
    182190      QualityDifferenceCalculator qualityDifferenceCalculator2 = new QualityDifferenceCalculator();
    183       ConditionalBranch villagesTerminationCondition = new ConditionalBranch();
     191      ConditionalBranch villagesTerminationCondition3 = new ConditionalBranch();
    184192      ConditionalBranch maximumGenerationsTerminationCondition = new ConditionalBranch();
    185193
     
    189197      villageCountAssigner.LeftSideParameter.ActualName = "VillageCount";
    190198      villageCountAssigner.RightSideParameter.ActualName = NumberOfVillagesParameter.Name;
     199
     200      maxSelPressAssigner.LeftSideParameter.ActualName = "CurrentMaximumSelectionPressure";
     201      maxSelPressAssigner.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name;
    191202
    192203      comparisonFactorInitializer.LeftSideParameter.ActualName = "ComparisonFactor";
     
    269280      mainLoop.ComparisonFactorModifierParameter.Value = new EmptyOperator(); // comparison factor is modified here
    270281      mainLoop.ComparisonFactorUpperBoundParameter.ActualName = ComparisonFactorUpperBoundParameter.Name;
    271       mainLoop.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
     282      mainLoop.MaximumSelectionPressureParameter.ActualName = "CurrentMaximumSelectionPressure";
    272283      mainLoop.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
    273284
     
    306317
    307318      // if there's just one island left and we're getting to this point SASEGASA terminates
    308       villageCountComparator.Name = "VillageCount <= 1 ?";
    309       villageCountComparator.LeftSideParameter.ActualName = "VillageCount";
    310       villageCountComparator.RightSideParameter.Value = new IntValue(1);
    311       villageCountComparator.Comparison.Value = ComparisonType.LessOrEqual;
    312       villageCountComparator.ResultParameter.ActualName = "TerminateVillages";
    313 
    314       villageTerminationCondition0.Name = "Skip reunification?";
    315       villageTerminationCondition0.ConditionParameter.ActualName = "TerminateVillages";
     319      villageCountComparator1.Name = "VillageCount <= 1 ?";
     320      villageCountComparator1.LeftSideParameter.ActualName = "VillageCount";
     321      villageCountComparator1.RightSideParameter.Value = new IntValue(1);
     322      villageCountComparator1.Comparison.Value = ComparisonType.LessOrEqual;
     323      villageCountComparator1.ResultParameter.ActualName = "TerminateVillages";
     324
     325      villageTerminationCondition1.Name = "Skip reunification?";
     326      villageTerminationCondition1.ConditionParameter.ActualName = "TerminateVillages";
    316327
    317328      reunificator.VillageCountParameter.ActualName = "VillageCount";
     
    321332
    322333      comparisonFactorModifier.OperatorParameter.ActualName = ComparisonFactorModifierParameter.Name;
     334
     335      villageCountComparator2.Name = "VillageCount == 1 ?";
     336      villageCountComparator2.LeftSideParameter.ActualName = "VillageCount";
     337      villageCountComparator2.RightSideParameter.Value = new IntValue(1);
     338      villageCountComparator2.Comparison.Value = ComparisonType.Equal;
     339      villageCountComparator2.ResultParameter.ActualName = "ChangeMaxSelPress";
     340
     341      villageTerminationCondition2.Name = "Change max selection pressure?";
     342      villageTerminationCondition2.ConditionParameter.ActualName = "ChangeMaxSelPress";
     343
     344      finalMaxSelPressAssigner.LeftSideParameter.ActualName = "CurrentMaximumSelectionPressure";
     345      finalMaxSelPressAssigner.RightSideParameter.ActualName = FinalMaximumSelectionPressureParameter.Name;
    323346
    324347      // if SASEGASAGenerations is reaching MaximumGenerations we're also terminating
     
    350373      qualityDifferenceCalculator2.SecondQualityParameter.ActualName = "BestQuality";
    351374
    352       villagesTerminationCondition.ConditionParameter.ActualName = "TerminateVillages";
     375      villagesTerminationCondition3.ConditionParameter.ActualName = "TerminateVillages";
    353376      villageMaximumGenerationsConditionalBranch1.ConditionParameter.ActualName = "TerminateMaximumGenerations";
    354377      #endregion
     
    357380      OperatorGraph.InitialOperator = variableCreator;
    358381      variableCreator.Successor = villageCountAssigner;
    359       villageCountAssigner.Successor = comparisonFactorInitializer;
     382      villageCountAssigner.Successor = maxSelPressAssigner;
     383      maxSelPressAssigner.Successor = comparisonFactorInitializer;
    360384      comparisonFactorInitializer.Successor = ussp0;
    361385      ussp0.Operator = islandVariableCreator;
     
    389413      villageMaximumGenerationsToGenerationsAssigner.Successor = villageMaximumGenerationsCounter;
    390414      villageMaximumGenerationsCounter.Successor = null;
    391       selPressValuesCollector2.Successor = villageCountComparator;
    392       villageCountComparator.Successor = villageTerminationCondition0;
    393       villageTerminationCondition0.TrueBranch = null;
    394       villageTerminationCondition0.FalseBranch = reunificator;
    395       villageTerminationCondition0.Successor = maximumGenerationsComparator;
     415      selPressValuesCollector2.Successor = villageCountComparator1;
     416      villageCountComparator1.Successor = villageTerminationCondition1;
     417      villageTerminationCondition1.TrueBranch = null;
     418      villageTerminationCondition1.FalseBranch = reunificator;
     419      villageTerminationCondition1.Successor = maximumGenerationsComparator;
    396420      reunificator.Successor = reunificationCounter;
    397421      reunificationCounter.Successor = comparisonFactorModifier;
    398       comparisonFactorModifier.Successor = null;
     422      comparisonFactorModifier.Successor = villageCountComparator2;
     423      villageCountComparator2.Successor = villageTerminationCondition2;
     424      villageTerminationCondition2.TrueBranch = finalMaxSelPressAssigner;
     425      villageTerminationCondition2.FalseBranch = null;
     426      villageTerminationCondition2.Successor = null;
     427      finalMaxSelPressAssigner.Successor = null;
    399428      maximumGenerationsComparator.Successor = bestQualityMemorizer3;
    400429      bestQualityMemorizer3.Successor = bestAverageWorstQualityCalculator3;
    401430      bestAverageWorstQualityCalculator3.Successor = dataTableValuesCollector2;
    402431      dataTableValuesCollector2.Successor = qualityDifferenceCalculator2;
    403       qualityDifferenceCalculator2.Successor = villagesTerminationCondition;
    404       villagesTerminationCondition.FalseBranch = maximumGenerationsTerminationCondition;
    405       villagesTerminationCondition.TrueBranch = null;
    406       villagesTerminationCondition.Successor = null;
     432      qualityDifferenceCalculator2.Successor = villagesTerminationCondition3;
     433      villagesTerminationCondition3.FalseBranch = maximumGenerationsTerminationCondition;
     434      villagesTerminationCondition3.TrueBranch = null;
     435      villagesTerminationCondition3.Successor = null;
    407436      maximumGenerationsTerminationCondition.FalseBranch = fixedReunificationStepConditionInitializer;
    408437      maximumGenerationsTerminationCondition.TrueBranch = null;
Note: See TracChangeset for help on using the changeset viewer.