Changeset 9110 for branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LCSAdaptedGeneticAlgorithm.cs
- Timestamp:
- 01/04/13 20:46:18 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LCSAdaptedGeneticAlgorithm.cs
r9105 r9110 24 24 using HeuristicLab.Core; 25 25 using HeuristicLab.Data; 26 using HeuristicLab.Encodings.ConditionActionEncoding; 26 27 using HeuristicLab.Operators; 27 28 using HeuristicLab.Optimization.Operators; … … 36 37 [StorableClass] 37 38 public sealed class LCSAdaptedGeneticAlgorithm : AlgorithmOperator { 39 private const string TEMPID = "TempID"; 40 private const string SUBSUMEDBY = "SubsumedBy"; 41 private const string SUBSUMED = "Subsumed"; 42 38 43 #region Parameter properties 39 44 public ValueLookupParameter<IRandom> RandomParameter { … … 75 80 public ValueLookupParameter<IntValue> PopulationSizeParameter { 76 81 get { return (ValueLookupParameter<IntValue>)Parameters["PopulationSize"]; } 82 } 83 public ValueLookupParameter<BoolValue> DoGASubsumptionParameter { 84 get { return (ValueLookupParameter<BoolValue>)Parameters["DoGASubsumption"]; } 77 85 } 78 86 private ScopeParameter CurrentScopeParameter { … … 113 121 Parameters.Add(new ValueLookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated.")); 114 122 Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population.")); 123 Parameters.Add(new ValueLookupParameter<BoolValue>("DoGASubsumption", "Sets if GA subsumption is executed.")); 115 124 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the genetic algorithm should be applied.")); 116 125 #endregion … … 126 135 Placeholder crossover = new Placeholder(); 127 136 Placeholder afterCrossover = new Placeholder(); 128 StochasticBranch stochasticBranch = new StochasticBranch();129 137 Placeholder mutator = new Placeholder(); 130 138 SubScopesRemover subScopesRemover = new SubScopesRemover(); … … 136 144 ConditionalBranch conditionalBranch = new ConditionalBranch(); 137 145 146 TempSubScopeIDAssigner tempIdAssigner = new TempSubScopeIDAssigner(); 147 ConditionalBranch doGASubsumptionBranch1 = new ConditionalBranch(); 148 UniformSubScopesProcessor setSubsumptionFalseSubScopesProcessor = new UniformSubScopesProcessor(); 149 Assigner setSubsumpByAssigner = new Assigner(); 150 Assigner setSubsumptionFalseAssigner = new Assigner(); 151 CheckGASubsumptionOperator checkGASubsumptionOperator = new CheckGASubsumptionOperator(); 152 ConditionalBranch doGASubsumptionBranch2 = new ConditionalBranch(); 153 ExecuteGASubsumptionOperator executeGAsubsumptionOperator = new ExecuteGASubsumptionOperator(); 154 ConditionalSelector subsumptionSelector = new ConditionalSelector(); 155 LeftReducer subsumptionLeftReducer = new LeftReducer(); 156 138 157 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class GeneticAlgorithm expects this to be called Generations 139 158 … … 144 163 analyzer1.OperatorParameter.ActualName = "Analyzer"; 145 164 165 tempIdAssigner.LeftSideParameter.ActualName = TEMPID; 166 167 setSubsumpByAssigner.LeftSideParameter.ActualName = SUBSUMEDBY; 168 setSubsumpByAssigner.RightSideParameter.Value = new IntValue(-1); 169 170 setSubsumptionFalseAssigner.LeftSideParameter.ActualName = SUBSUMED; 171 setSubsumptionFalseAssigner.RightSideParameter.Value = new BoolValue(false); 172 146 173 selector.Name = "Selector"; 147 174 selector.OperatorParameter.ActualName = "Selector"; … … 155 182 afterCrossover.OperatorParameter.ActualName = "AfterCrossover"; 156 183 157 stochasticBranch.ProbabilityParameter.ActualName = "MutationProbability";158 stochasticBranch.RandomParameter.ActualName = "Random";159 160 184 mutator.Name = "Mutator"; 161 185 mutator.OperatorParameter.ActualName = "Mutator"; 162 186 187 doGASubsumptionBranch1.ConditionParameter.ActualName = DoGASubsumptionParameter.ActualName; 188 189 checkGASubsumptionOperator.ChildClassifiersParameter.ActualName = "CombinedIntegerVector"; 190 checkGASubsumptionOperator.ParentsClassifiersParameter.ActualName = "CombinedIntegerVector"; 191 checkGASubsumptionOperator.NumerositiesParameter.ActualName = "Numerosity"; 192 checkGASubsumptionOperator.ExperiencesParameter.ActualName = "Experience"; 193 checkGASubsumptionOperator.ErrorsParameter.ActualName = "Error"; 194 checkGASubsumptionOperator.TempIDParameter.ActualName = TEMPID; 195 checkGASubsumptionOperator.ErrorZeroParameter.ActualName = "ErrorZero"; 196 checkGASubsumptionOperator.ThetaSubsumptionParameter.ActualName = "ThetaSubsumption"; 197 checkGASubsumptionOperator.SubsumedByParameter.ActualName = SUBSUMEDBY; 198 checkGASubsumptionOperator.SubsumedParameter.ActualName = SUBSUMED; 199 163 200 subScopesRemover.RemoveAllSubScopes = true; 201 202 doGASubsumptionBranch2.ConditionParameter.ActualName = DoGASubsumptionParameter.ActualName; 203 204 executeGAsubsumptionOperator.NumerositiesParameter.ActualName = "Numerosity"; 205 executeGAsubsumptionOperator.TempIDParameter.ActualName = TEMPID; 206 executeGAsubsumptionOperator.SubsumedByParameter.ActualName = SUBSUMEDBY; 207 208 subsumptionSelector.ConditionParameter.ActualName = SUBSUMED; 209 subsumptionSelector.CopySelected = new BoolValue(false); 164 210 165 211 subScopesCounter.Name = "Increment EvaluatedSolutions"; … … 184 230 variableCreator.Successor = resultsCollector1; 185 231 resultsCollector1.Successor = analyzer1; 186 analyzer1.Successor = selector; 232 analyzer1.Successor = tempIdAssigner; 233 tempIdAssigner.Successor = setSubsumptionFalseSubScopesProcessor; 234 setSubsumptionFalseSubScopesProcessor.Operator = setSubsumpByAssigner; 235 setSubsumpByAssigner.Successor = setSubsumptionFalseAssigner; 236 setSubsumptionFalseAssigner.Successor = null; 237 setSubsumptionFalseSubScopesProcessor.Successor = selector; 187 238 selector.Successor = subScopesProcessor1; 188 239 subScopesProcessor1.Operators.Add(new EmptyOperator()); … … 193 244 uniformSubScopesProcessor1.Successor = subScopesCounter; 194 245 crossover.Successor = afterCrossover; 195 afterCrossover.Successor = stochasticBranch;196 stochasticBranch.FirstBranch = mutator;197 stochasticBranch.SecondBranch = null;198 stochasticBranch.Successor = subScopesRemover;199 mutator.Successor = null;246 afterCrossover.Successor = mutator; 247 mutator.Successor = doGASubsumptionBranch1; 248 doGASubsumptionBranch1.TrueBranch = checkGASubsumptionOperator; 249 doGASubsumptionBranch1.FalseBranch = new EmptyOperator(); 250 doGASubsumptionBranch1.Successor = subScopesRemover; 200 251 subScopesRemover.Successor = null; 201 252 subScopesCounter.Successor = null; 202 mergingReducer.Successor = intCounter; 253 mergingReducer.Successor = doGASubsumptionBranch2; 254 doGASubsumptionBranch2.TrueBranch = executeGAsubsumptionOperator; 255 doGASubsumptionBranch2.FalseBranch = new EmptyOperator(); 256 executeGAsubsumptionOperator.Successor = subsumptionSelector; 257 subsumptionSelector.Successor = subsumptionLeftReducer; 258 subsumptionLeftReducer.Successor = null; 259 doGASubsumptionBranch2.Successor = intCounter; 203 260 intCounter.Successor = comparator; 204 261 comparator.Successor = analyzer2;
Note: See TracChangeset
for help on using the changeset viewer.