Changeset 9175
- Timestamp:
- 01/21/13 16:33:47 (12 years ago)
- Location:
- branches/LearningClassifierSystems
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystem.cs
r9154 r9175 112 112 get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; } 113 113 } 114 private ValueParameter<MultiAnalyzer> FinalAnalyzerParameter { 115 get { return (ValueParameter<MultiAnalyzer>)Parameters["FinalAnalyzer"]; } 116 } 114 117 private ValueParameter<IntValue> MaxIterationsParameter { 115 118 get { return (ValueParameter<IntValue>)Parameters["MaxIterations"]; } … … 197 200 get { return AnalyzerParameter.Value; } 198 201 set { AnalyzerParameter.Value = value; } 202 } 203 public MultiAnalyzer FinalAnalyzer { 204 get { return FinalAnalyzerParameter.Value; } 205 set { FinalAnalyzerParameter.Value = value; } 199 206 } 200 207 private RandomCreator RandomCreator { … … 228 235 Parameters.Add(new ValueParameter<BoolValue>("DoActionSetSubsumption", "Specifies if action set is tested for subsuming classifiers.", new BoolValue(true))); 229 236 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer())); 237 Parameters.Add(new ValueParameter<MultiAnalyzer>("FinalAnalyzer", "The operator used to analyze the last generation.", new MultiAnalyzer())); 230 238 Parameters.Add(new ValueParameter<IntValue>("MaxIterations", "The maximum number of iterations.", new IntValue(1000))); 231 239 #endregion … … 246 254 247 255 mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name; 256 mainLoop.FinalAnalyzerParameter.ActualName = FinalAnalyzerParameter.Name; 248 257 mainLoop.MaxIterationsParameter.ActualName = MaxIterationsParameter.Name; 249 258 #endregion … … 298 307 private void UpdateAnalyzers() { 299 308 Analyzer.Operators.Clear(); 309 FinalAnalyzer.Operators.Clear(); 300 310 if (Problem != null) { 301 311 foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>()) { 302 312 Analyzer.Operators.Add(analyzer, analyzer.EnabledByDefault); 313 FinalAnalyzer.Operators.Add(analyzer, analyzer.EnabledByDefault); 303 314 } 304 315 } -
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystemMainLoop.cs
r9167 r9175 64 64 get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; } 65 65 } 66 public ValueLookupParameter<IOperator> FinalAnalyzerParameter { 67 get { return (ValueLookupParameter<IOperator>)Parameters["FinalAnalyzer"]; } 68 } 66 69 #endregion 67 70 … … 110 113 Parameters.Add(new LookupParameter<IntValue>("MaxIterations", "The maximum number of iterations the algorithm will do.")); 111 114 Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation.")); 115 Parameters.Add(new ValueLookupParameter<IOperator>("FinalAnalyzer", "The operator used to analyze the last generation.")); 112 116 #endregion 113 117 … … 115 119 VariableCreator variableCreator = new VariableCreator(); 116 120 ResultsCollector resultsCollector = new ResultsCollector(); 121 Placeholder analyzer = new Placeholder(); 117 122 Placeholder finalAnalyzer = new Placeholder(); 118 123 ConditionalBranch initialPopulationConditionalBranch = new ConditionalBranch(); … … 179 184 resultsCollector.ResultsParameter.ActualName = "Results"; 180 185 181 finalAnalyzer.Name = "Analyzer"; 182 finalAnalyzer.OperatorParameter.ActualName = "Analyzer"; 186 analyzer.Name = "Analyzer"; 187 analyzer.OperatorParameter.ActualName = "Analyzer"; 188 189 finalAnalyzer.Name = "FinalAnalyzer"; 190 finalAnalyzer.OperatorParameter.ActualName = "FinalAnalyzer"; 183 191 184 192 initialPopulationConditionalBranch.ConditionParameter.ActualName = "CreateInitialPopulation"; … … 349 357 initialPopulationConditionalBranch.Successor = maxIterationsComparator; 350 358 maxIterationsComparator.Successor = terminationConditionalBranch1; 351 //terminationConditionalBranch1.TrueBranch = finalAnalyzer;359 terminationConditionalBranch1.TrueBranch = finalAnalyzer; 352 360 terminationConditionalBranch1.FalseBranch = classifierFetcher; 353 361 classifierFetcher.Successor = matchCondtionSubScopesProcessor; … … 406 414 deletionSelectorAfterGA.Successor = leftReducerAfterGA; 407 415 leftReducerAfterGA.Successor = iterationCounter; 408 //iterationCounter.Successor = maxIterationsComparator; 409 410 iterationCounter.Successor = finalAnalyzer; 411 finalAnalyzer.Successor = maxIterationsComparator; 416 iterationCounter.Successor = analyzer; 417 analyzer.Successor = maxIterationsComparator; 412 418 #endregion 413 419 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/CombinedIntegerVector.cs
r9167 r9175 142 142 IntMatrix actionBounds = new IntMatrix(actionPartLength, bounds.Columns); 143 143 int start = length - actionPartLength; 144 int rows = bounds.Rows; 144 145 for (int i = start; i < length; i++) { 145 int pos = i % bounds.Rows;146 int pos = i % rows; 146 147 for (int j = 0; j < bounds.Columns; j++) { 147 148 actionBounds[i - start, j] = bounds[pos, j]; … … 160 161 curbounds = i % bounds.Rows; 161 162 //if don't care symbol is matched, next indices can be checked 162 if (this[i] .Equals(bounds[curbounds, 1] - 1)) {163 if (this[i] == bounds[curbounds, 1] - 1) { 163 164 continue; 164 165 } 165 if ( !this[i].Equals(targetVector[i])) {166 if (this[i] != targetVector[i]) { 166 167 return false; 167 168 } … … 241 242 242 243 public bool Equals(IClassifier other) { 243 return this.MatchAction(other) && this.MatchCondition(other); 244 var cast = other as CombinedIntegerVector; 245 if (cast == null) { return false; } 246 for (int i = 0; i < array.Length; i++) { 247 if (!array[i].Equals(cast.array[i])) { 248 return false; 249 } 250 } 251 return true; 244 252 } 245 253 … … 251 259 return result.GetHashCode(); 252 260 } 253 254 public bool Identical(IClassifier classifier) {255 var cast = classifier as CombinedIntegerVector;256 if (cast != null) {257 for (int i = 0; i < array.Length; i++) {258 if (!array[i].Equals(cast.array[i])) {259 return false;260 }261 }262 }263 return true;264 }265 261 } 266 262 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Analyzer/XCSSolutionAnalyzer.cs
r9154 r9175 31 31 [Item("ConditionActionSolutionAnalyzer", "")] 32 32 [StorableClass] 33 public sealedclass XCSSolutionAnalyzer : SingleSuccessorOperator, IAnalyzer {33 public abstract class XCSSolutionAnalyzer : SingleSuccessorOperator, IAnalyzer { 34 34 public bool EnabledByDefault { 35 35 get { return true; } … … 67 67 } 68 68 69 public ResultCollection Results { get { return ResultsParameter.ActualValue; } } 70 69 71 [StorableConstructor] 70 private XCSSolutionAnalyzer(bool deserializing) : base(deserializing) { } 71 private XCSSolutionAnalyzer(XCSSolutionAnalyzer original, Cloner cloner) : base(original, cloner) { } 72 public override IDeepCloneable Clone(Cloner cloner) { 73 return new XCSSolutionAnalyzer(this, cloner); 74 } 72 protected XCSSolutionAnalyzer(bool deserializing) : base(deserializing) { } 73 protected XCSSolutionAnalyzer(XCSSolutionAnalyzer original, Cloner cloner) : base(original, cloner) { } 75 74 public XCSSolutionAnalyzer() 76 75 : base() { … … 96 95 ItemArray<DoubleValue> averageActionSetSizes = AverageActionSetSizeParameter.ActualValue; 97 96 ItemArray<IntValue> numerosities = NumerosityParameter.ActualValue; 98 ResultCollection results = ResultsParameter.ActualValue;99 97 IConditionActionProblemData problemData = ProblemDataParameter.ActualValue; 100 98 … … 108 106 XCSModel xcsModel = new XCSModel(xcsClassifiers); 109 107 110 if (results.ContainsKey("XCSSolution")) { 111 results.Remove("XCSSolution"); 112 } 113 results.Add(new Result("XCSSolution", xcsModel.CreateConditionActionSolution(problemData))); 114 108 UseCurrentXCSSolution(xcsModel.CreateConditionActionSolution(problemData)); 115 109 return base.Apply(); 116 110 } 111 112 protected abstract void UseCurrentXCSSolution(IXCSSolution xcsSolution); 117 113 } 118 114 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj
r9167 r9175 38 38 </PropertyGroup> 39 39 <ItemGroup> 40 <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 40 41 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 41 42 <Private>False</Private> … … 56 57 <Private>False</Private> 57 58 </Reference> 59 <Reference Include="HeuristicLab.Optimization.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 58 60 <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 59 61 <Private>False</Private> … … 86 88 <Compile Include="ActionSelection\MaxValueActionSelector.cs" /> 87 89 <Compile Include="ActionSelection\RandomActionSelector.cs" /> 90 <Compile Include="Analyzer\BestTrainingXCSSolutionAnalyzer.cs" /> 91 <Compile Include="Analyzer\CurrentXCSSolutionAnalyzer.cs" /> 88 92 <Compile Include="Analyzer\XCSSolutionAnalyzer.cs" /> 89 93 <Compile Include="Covering\CoveringOperator.cs" /> -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/IClassifier.cs
r9167 r9175 41 41 bool Equals(object obj); 42 42 int GetHashCode(); 43 44 //test45 bool Identical(IClassifier classifier);46 43 } 47 44 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Interfaces/IConditionActionSolution.cs
r9154 r9175 31 31 event EventHandler ModelChanged; 32 32 event EventHandler ProblemDataChanged; 33 34 double TrainingAccuracy { get; } 35 double TestAccuracy { get; } 33 36 } 34 37 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Reinforcement/ActionExecuter.cs
r9089 r9175 69 69 70 70 public override IOperation Apply() { 71 if (SelectedActionParameter.ActualValue. Action.Equals(CurrentClassifierToMatchParameter.ActualValue.Action)) {71 if (SelectedActionParameter.ActualValue.MatchAction(CurrentClassifierToMatchParameter.ActualValue)) { 72 72 CurrentPayoffParameter.ActualValue = PositiveRewardParameter.ActualValue; 73 73 } else { -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/XCSSolution.cs
r9161 r9175 86 86 description = original.Description; 87 87 } 88 public override IDeepCloneable Clone(Cloner cloner) { 89 return new XCSSolution(this, cloner); 90 } 88 91 public XCSSolution(IConditionActionModel model, IConditionActionProblemData problemData) 89 92 : base() { … … 118 121 119 122 while (originalEnumerator.MoveNext() && estimatedActionEnumerator.MoveNext()) { 120 if (originalEnumerator.Current. Action.Equals(estimatedActionEnumerator.Current)) {123 if (originalEnumerator.Current.MatchAction(estimatedActionEnumerator.Current)) { 121 124 correctClassified++; 122 125 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblem.cs
r9167 r9175 149 149 get { return CoveringSolutionCreatorParameter; } 150 150 } 151 private XCSSolutionAnalyzer XCSSolutionAnalyzer {152 get { return Operators.OfType<XCSSolutionAnalyzer>().FirstOrDefault(); }153 }154 151 #endregion 155 152 … … 226 223 227 224 private void InitializeOperators() { 228 Operators.Add(new XCSSolutionAnalyzer()); 225 Operators.Add(new BestTrainingXCSSolutionAnalyzer()); 226 Operators.Add(new CurrentXCSSolutionAnalyzer()); 229 227 230 228 ParameterizeAnalyzers(); … … 232 230 233 231 private void ParameterizeAnalyzers() { 234 if (XCSSolutionAnalyzer != null) {235 XCSSolutionAnalyzer.ClassifierParameter.ActualName = SolutionCreator.CombinedIntegerVectorParameter.ActualName;236 XCSSolutionAnalyzer.PredictionParameter.ActualName = Evaluator.PredictionParameter.ActualName;237 XCSSolutionAnalyzer.ErrorParameter.ActualName = Evaluator.ErrorParameter.ActualName;238 XCSSolutionAnalyzer.FitnessParameter.ActualName = Evaluator.FitnessParameter.ActualName;239 XCSSolutionAnalyzer.ExperienceParameter.ActualName = Evaluator.ExperienceParameter.ActualName;240 XCSSolutionAnalyzer.AverageActionSetSizeParameter.ActualName = Evaluator.AverageActionSetSizeParameter.ActualName;241 XCSSolutionAnalyzer.NumerosityParameter.ActualName = Evaluator.NumerosityParameter.ActualName;242 XCSSolutionAnalyzer.TimestampParameter.ActualName = Evaluator.TimestampParameter.ActualName;243 XCSSolutionAnalyzer.ProblemDataParameter.ActualName = ProblemDataParameter.Name;244 XCSSolutionAnalyzer.ResultsParameter.ActualName = "Results";232 foreach (XCSSolutionAnalyzer xcsAnalyzer in Operators.Where(x => x is XCSSolutionAnalyzer)) { 233 xcsAnalyzer.ClassifierParameter.ActualName = SolutionCreator.CombinedIntegerVectorParameter.ActualName; 234 xcsAnalyzer.PredictionParameter.ActualName = Evaluator.PredictionParameter.ActualName; 235 xcsAnalyzer.ErrorParameter.ActualName = Evaluator.ErrorParameter.ActualName; 236 xcsAnalyzer.FitnessParameter.ActualName = Evaluator.FitnessParameter.ActualName; 237 xcsAnalyzer.ExperienceParameter.ActualName = Evaluator.ExperienceParameter.ActualName; 238 xcsAnalyzer.AverageActionSetSizeParameter.ActualName = Evaluator.AverageActionSetSizeParameter.ActualName; 239 xcsAnalyzer.NumerosityParameter.ActualName = Evaluator.NumerosityParameter.ActualName; 240 xcsAnalyzer.TimestampParameter.ActualName = Evaluator.TimestampParameter.ActualName; 241 xcsAnalyzer.ProblemDataParameter.ActualName = ProblemDataParameter.Name; 242 xcsAnalyzer.ResultsParameter.ActualName = "Results"; 245 243 } 246 244 }
Note: See TracChangeset
for help on using the changeset viewer.