Changeset 9154 for branches/LearningClassifierSystems
- Timestamp:
- 01/14/13 15:23:17 (12 years ago)
- Location:
- branches/LearningClassifierSystems
- Files:
-
- 19 added
- 1 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/HeuristicLab.Algorithms.LearningClassifierSystems-3.3.csproj
r9089 r9154 41 41 <Private>False</Private> 42 42 </Reference> 43 <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 44 <Private>False</Private> 45 </Reference> 43 46 <Reference Include="HeuristicLab.Collections-3.3"> 44 47 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath> … … 57 60 <Private>False</Private> 58 61 </Reference> 59 <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 62 <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 63 <Private>False</Private> 64 </Reference> 60 65 <Reference Include="HeuristicLab.Operators-3.3"> 61 66 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath> … … 86 91 <Private>False</Private> 87 92 </Reference> 88 <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 93 <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 94 <Private>False</Private> 95 </Reference> 89 96 <Reference Include="System" /> 90 97 <Reference Include="System.Core" /> … … 111 118 <Project>{CE7163C5-BFFE-45F0-9BD0-E10EF24E8BD2}</Project> 112 119 <Name>HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3</Name> 120 <Private>False</Private> 113 121 </ProjectReference> 114 122 <ProjectReference Include="..\..\HeuristicLab.Encodings.ConditionActionEncoding\3.3\HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj"> 115 123 <Project>{422FB262-0845-4969-8D16-12F057AA90B1}</Project> 116 124 <Name>HeuristicLab.Encodings.ConditionActionEncoding-3.3</Name> 125 <Private>False</Private> 117 126 </ProjectReference> 118 127 <ProjectReference Include="..\..\HeuristicLab.Problems.ConditionActionClassification\3.3\HeuristicLab.Problems.ConditionActionClassification-3.3.csproj"> 119 128 <Project>{EA51D441-F6A3-41E1-9993-A2488E93C222}</Project> 120 129 <Name>HeuristicLab.Problems.ConditionActionClassification-3.3</Name> 130 <Private>False</Private> 121 131 </ProjectReference> 122 132 </ItemGroup> -
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LCSAdaptedGeneticAlgorithm.cs
r9110 r9154 72 72 get { return (ValueLookupParameter<VariableCollection>)Parameters["Results"]; } 73 73 } 74 public ValueLookupParameter<IOperator> AnalyzerParameter {75 get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }76 }77 74 public ValueLookupParameter<IntValue> EvaluatedSolutionsParameter { 78 75 get { return (ValueLookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; } … … 118 115 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.")); 119 116 Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored.")); 120 Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation."));121 117 Parameters.Add(new ValueLookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated.")); 122 118 Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population.")); … … 128 124 VariableCreator variableCreator = new VariableCreator(); 129 125 ResultsCollector resultsCollector1 = new ResultsCollector(); 130 Placeholder analyzer1 = new Placeholder();131 126 Placeholder selector = new Placeholder(); 132 127 SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor(); … … 141 136 IntCounter intCounter = new IntCounter(); 142 137 Comparator comparator = new Comparator(); 143 Placeholder analyzer2 = new Placeholder();144 138 ConditionalBranch conditionalBranch = new ConditionalBranch(); 145 139 … … 157 151 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class GeneticAlgorithm expects this to be called Generations 158 152 159 resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));153 //resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Iterations")); 160 154 resultsCollector1.ResultsParameter.ActualName = "Results"; 161 162 analyzer1.Name = "Analyzer";163 analyzer1.OperatorParameter.ActualName = "Analyzer";164 155 165 156 tempIdAssigner.LeftSideParameter.ActualName = TEMPID; … … 220 211 comparator.RightSideParameter.ActualName = "MaximumGenerations"; 221 212 222 analyzer2.Name = "Analyzer";223 analyzer2.OperatorParameter.ActualName = "Analyzer";224 225 213 conditionalBranch.ConditionParameter.ActualName = "Terminate"; 226 214 #endregion … … 229 217 OperatorGraph.InitialOperator = variableCreator; 230 218 variableCreator.Successor = resultsCollector1; 231 resultsCollector1.Successor = analyzer1; 232 analyzer1.Successor = tempIdAssigner; 219 resultsCollector1.Successor = tempIdAssigner; 233 220 tempIdAssigner.Successor = setSubsumptionFalseSubScopesProcessor; 234 221 setSubsumptionFalseSubScopesProcessor.Operator = setSubsumpByAssigner; … … 259 246 doGASubsumptionBranch2.Successor = intCounter; 260 247 intCounter.Successor = comparator; 261 comparator.Successor = analyzer2; 262 analyzer2.Successor = conditionalBranch; 248 comparator.Successor = conditionalBranch; 263 249 conditionalBranch.FalseBranch = selector; 264 250 conditionalBranch.TrueBranch = null; -
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystem.cs
r9089 r9154 21 21 22 22 using System; 23 using System.Linq; 24 using HeuristicLab.Analysis; 23 25 using HeuristicLab.Common; 24 26 using HeuristicLab.Core; 25 27 using HeuristicLab.Data; 26 28 using HeuristicLab.Encodings.ConditionActionEncoding; 29 using HeuristicLab.Operators; 27 30 using HeuristicLab.Optimization; 31 using HeuristicLab.Optimization.Operators; 28 32 using HeuristicLab.Parameters; 29 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 105 109 get { return (ValueParameter<BoolValue>)Parameters["DoActionSetSubsumption"]; } 106 110 } 111 private ValueParameter<MultiAnalyzer> AnalyzerParameter { 112 get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; } 113 } 114 private ValueParameter<IntValue> MaxIterationsParameter { 115 get { return (ValueParameter<IntValue>)Parameters["MaxIterations"]; } 116 } 107 117 #endregion 108 118 … … 180 190 set { DoActionSetSubsumptionParameter.Value = value; } 181 191 } 192 public IntValue MaxIterations { 193 get { return MaxIterationsParameter.Value; } 194 set { MaxIterationsParameter.Value = value; } 195 } 196 public MultiAnalyzer Analyzer { 197 get { return AnalyzerParameter.Value; } 198 set { AnalyzerParameter.Value = value; } 199 } 182 200 private RandomCreator RandomCreator { 183 201 get { return (RandomCreator)OperatorGraph.InitialOperator; } 184 202 } 185 203 public LearningClassifierSystemMainLoop MainLoop { 186 get { return (LearningClassifierSystemMainLoop)RandomCreator.Successor; }204 get { return FindMainLoop(RandomCreator.Successor); } 187 205 } 188 206 #endregion … … 209 227 Parameters.Add(new ValueParameter<BoolValue>("DoGASubsumption", "Specifies if offsprings are tested for possible logical subsumption by parents.", new BoolValue(true))); 210 228 Parameters.Add(new ValueParameter<BoolValue>("DoActionSetSubsumption", "Specifies if action set is tested for subsuming classifiers.", new BoolValue(true))); 229 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer())); 230 Parameters.Add(new ValueParameter<IntValue>("MaxIterations", "The maximum number of iterations.", new IntValue(1000))); 211 231 #endregion 212 232 … … 214 234 RandomCreator randomCreator = new RandomCreator(); 215 235 216 //ResultsCollector resultsCollector = new ResultsCollector();236 ResultsCollector resultsCollector = new ResultsCollector(); 217 237 LearningClassifierSystemMainLoop mainLoop = new LearningClassifierSystemMainLoop(); 218 238 … … 222 242 randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name; 223 243 randomCreator.SetSeedRandomlyParameter.Value = null; 244 245 resultsCollector.ResultsParameter.ActualName = "Results"; 246 247 mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name; 248 mainLoop.MaxIterationsParameter.ActualName = MaxIterationsParameter.Name; 224 249 #endregion 225 250 226 251 #region Create operator graph 227 252 OperatorGraph.InitialOperator = randomCreator; 228 randomCreator.Successor = mainLoop; 253 randomCreator.Successor = resultsCollector; 254 resultsCollector.Successor = mainLoop; 229 255 #endregion 256 257 UpdateAnalyzers(); 230 258 } 231 259 private LearningClassifierSystem(LearningClassifierSystem original, Cloner cloner) … … 242 270 ParameterizeEvaluator(Problem.Evaluator); 243 271 MainLoop.SetCurrentProblem(Problem); 272 UpdateAnalyzers(); 244 273 } 245 274 base.OnProblemChanged(); … … 253 282 MainLoop.SetCurrentProblem(Problem); 254 283 base.Problem_SolutionCreatorChanged(sender, e); 284 } 285 protected override void Problem_OperatorsChanged(object sender, EventArgs e) { 286 UpdateAnalyzers(); 287 base.Problem_OperatorsChanged(sender, e); 255 288 } 256 289 … … 262 295 evaluator.ErrorZeroParameter.ActualName = ErrorZeroParameter.Name; 263 296 } 297 298 private void UpdateAnalyzers() { 299 Analyzer.Operators.Clear(); 300 if (Problem != null) { 301 foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>()) { 302 Analyzer.Operators.Add(analyzer, analyzer.EnabledByDefault); 303 } 304 } 305 } 306 307 private LearningClassifierSystemMainLoop FindMainLoop(IOperator start) { 308 IOperator mainLoop = start; 309 while (mainLoop != null && !(mainLoop is LearningClassifierSystemMainLoop)) 310 mainLoop = ((SingleSuccessorOperator)mainLoop).Successor; 311 if (mainLoop == null) return null; 312 else return (LearningClassifierSystemMainLoop)mainLoop; 313 } 264 314 } 265 315 } -
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystemMainLoop.cs
r9110 r9154 55 55 get { return (IConstrainedValueParameter<IOperator>)Parameters["AfterCrossover"]; } 56 56 } 57 public LookupParameter<IntValue> MaxIterationsParameter { 58 get { return (LookupParameter<IntValue>)Parameters["MaxIterations"]; } 59 } 60 public ValueLookupParameter<IOperator> AnalyzerParameter { 61 get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; } 62 } 57 63 #endregion 58 64 … … 97 103 XCSAfterCrossoverOperator afterCrossover = new XCSAfterCrossoverOperator(); 98 104 Parameters.Add(new ConstrainedValueParameter<IOperator>("AfterCrossover", "The operator used to select solutions for reproduction.", new ItemSet<IOperator>() { new XCSAfterCrossoverOperator() }, afterCrossover)); 105 Parameters.Add(new LookupParameter<IntValue>("MaxIterations", "The maximum number of iterations the algorithm will do.")); 106 Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation.")); 99 107 #endregion 108 109 110 //test 111 DataReducer testReducer = new DataReducer(); 112 testReducer.TargetParameter.ActualName = "TestCurrentPopulation"; 113 testReducer.ParameterToReduce.ActualName = "Numerosity"; 114 testReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum); 115 testReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign); 100 116 101 117 #region Create operators 102 118 VariableCreator variableCreator = new VariableCreator(); 119 ResultsCollector resultsCollector = new ResultsCollector(); 120 Placeholder finalAnalyzer = new Placeholder(); 103 121 ConditionalBranch initialPopulationConditionalBranch = new ConditionalBranch(); 104 122 initialSolutionsCreator = new SolutionsCreator(); 105 123 Assigner initialPopulationSizeAssigner = new Assigner(); 124 Comparator maxIterationsComparator = new Comparator(); 125 ConditionalBranch terminationConditionalBranch1 = new ConditionalBranch(); 106 126 IntCounter iterationCounter = new IntCounter(); 107 127 UniformSubScopesProcessor matchCondtionSubScopesProcessor = new UniformSubScopesProcessor(); … … 159 179 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("CurrentPopulationSize", new IntValue(0))); 160 180 181 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Iteration")); 182 resultsCollector.ResultsParameter.ActualName = "Results"; 183 184 finalAnalyzer.Name = "Analyzer"; 185 finalAnalyzer.OperatorParameter.ActualName = "Analyzer"; 186 161 187 initialPopulationConditionalBranch.ConditionParameter.ActualName = "CreateInitialPopulation"; 162 188 … … 165 191 initialPopulationSizeAssigner.LeftSideParameter.ActualName = "CurrentPopulationSize"; 166 192 initialPopulationSizeAssigner.RightSideParameter.ActualName = "N"; 193 194 maxIterationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual); 195 maxIterationsComparator.LeftSideParameter.ActualName = "Iteration"; 196 maxIterationsComparator.RightSideParameter.ActualName = MaxIterationsParameter.ActualName; 197 maxIterationsComparator.ResultParameter.ActualName = "TerminateMaxIterations"; 198 199 terminationConditionalBranch1.ConditionParameter.ActualName = "TerminateMaxIterations"; 167 200 168 201 iterationCounter.ValueParameter.ActualName = "Iteration"; … … 311 344 OperatorGraph.InitialOperator = variableCreator; 312 345 313 variableCreator.Successor = initialPopulationConditionalBranch; 346 variableCreator.Successor = resultsCollector; 347 resultsCollector.Successor = initialPopulationConditionalBranch; 314 348 initialPopulationConditionalBranch.TrueBranch = initialSolutionsCreator; 315 349 initialSolutionsCreator.Successor = initialPopulationSizeAssigner; 316 350 initialPopulationConditionalBranch.FalseBranch = new EmptyOperator(); 317 initialPopulationConditionalBranch.Successor = classifierFetcher; 351 initialPopulationConditionalBranch.Successor = maxIterationsComparator; 352 maxIterationsComparator.Successor = terminationConditionalBranch1; 353 terminationConditionalBranch1.TrueBranch = finalAnalyzer; 354 terminationConditionalBranch1.FalseBranch = classifierFetcher; 318 355 classifierFetcher.Successor = matchCondtionSubScopesProcessor; 319 356 matchCondtionSubScopesProcessor.Operator = matchConditionOperator; … … 371 408 deletionSelectorAfterGA.Successor = leftReducerAfterGA; 372 409 leftReducerAfterGA.Successor = iterationCounter; 373 iterationCounter.Successor = classifierFetcher; 410 //iterationCounter.Successor = maxIterationsComparator; 411 412 iterationCounter.Successor = testReducer; 413 testReducer.Successor = maxIterationsComparator; 374 414 #endregion 375 415 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3.csproj
r9110 r9154 83 83 </PropertyGroup> 84 84 <ItemGroup> 85 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 86 <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 87 <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 88 <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 89 <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 90 <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 91 <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 92 <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 93 <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 94 <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 85 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 86 <Private>False</Private> 87 </Reference> 88 <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 89 <Private>False</Private> 90 </Reference> 91 <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 92 <Private>False</Private> 93 </Reference> 94 <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 95 <Private>False</Private> 96 </Reference> 97 <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 98 <Private>False</Private> 99 </Reference> 100 <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 101 <Private>False</Private> 102 </Reference> 103 <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 104 <Private>False</Private> 105 </Reference> 106 <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 107 <Private>False</Private> 108 </Reference> 109 <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 110 <Private>False</Private> 111 </Reference> 112 <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 113 <Private>False</Private> 114 </Reference> 95 115 <Reference Include="System" /> 96 116 <Reference Include="System.Core" /> … … 132 152 <Project>{422FB262-0845-4969-8D16-12F057AA90B1}</Project> 133 153 <Name>HeuristicLab.Encodings.ConditionActionEncoding-3.3</Name> 154 <Private>False</Private> 134 155 </ProjectReference> 135 156 </ItemGroup> -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Manipulator/UniformSomePositionManipulator.cs
r9110 r9154 46 46 public UniformSomePositionManipulator() 47 47 : base() { 48 Parameters.Add(new ValueLookupParameter<PercentValue>("Probability", "The probability for each dimension to be manipulated." , new PercentValue(0.5)));48 Parameters.Add(new ValueLookupParameter<PercentValue>("Probability", "The probability for each dimension to be manipulated.")); 49 49 Parameters.Add(new LookupParameter<IItemSet<CombinedIntegerVector>>("PossibleActions")); 50 50 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Deletion/XCSDeletionOperator.cs
r9110 r9154 112 112 double averageFitnessInPopulation = fitnessSum / numerositySum; 113 113 for (int cl = 0; cl < fitnesses.Length; cl++) { 114 if (numerosities[cl].Value > 0 ) {114 if (numerosities[cl].Value > 0 && !hasToBeDeleted[cl].Value) { 115 115 voteSum += DeletionVote(averageFitnessInPopulation, averageActionSetSizes[cl].Value, numerosities[cl].Value, fitnesses[cl].Value, experiences[cl].Value); 116 116 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj
r9110 r9154 65 65 <Private>False</Private> 66 66 </Reference> 67 <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 67 <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 68 <Private>False</Private> 69 </Reference> 68 70 <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 69 71 <Private>False</Private> … … 83 85 <Compile Include="ActionSelection\MaxValueActionSelector.cs" /> 84 86 <Compile Include="ActionSelection\RandomActionSelector.cs" /> 87 <Compile Include="Analyzer\XCSSolutionAnalyzer.cs" /> 85 88 <Compile Include="Covering\CoveringOperator.cs" /> 86 89 <Compile Include="Covering\DoDeletionBeforeCovering.cs" /> … … 95 98 <Compile Include="GA\XCSAfterCrossoverOperator.cs" /> 96 99 <Compile Include="IClassifier.cs" /> 100 <Compile Include="Interfaces\IConditionActionModel.cs" /> 97 101 <Compile Include="Interfaces\IConditionActionProblem.cs" /> 98 102 <Compile Include="Interfaces\IConditionActionProblemData.cs" /> 103 <Compile Include="Interfaces\IConditionActionSolution.cs" /> 104 <Compile Include="Interfaces\IXCSModel.cs" /> 105 <Compile Include="Interfaces\IXCSSolution.cs" /> 99 106 <Compile Include="Operator\CalculateAccuracy.cs" /> 100 107 <Compile Include="GA\XCSCheckIfGAShouldBeApplied.cs" /> … … 108 115 <Compile Include="Plugin.cs" /> 109 116 <Compile Include="Reinforcement\ActionExecuter.cs" /> 117 <Compile Include="Reinforcement\ClassifierFetcher.cs" /> 110 118 <Compile Include="Reinforcement\IActionExecuter.cs" /> 111 119 <Compile Include="Reinforcement\IClassifierFetcher.cs" /> … … 116 124 <Compile Include="Subsumption\ExecuteGASubsumptionOperator.cs" /> 117 125 <Compile Include="Subsumption\IActionSetSubsumption.cs" /> 126 <Compile Include="XCSClassifier.cs" /> 127 <Compile Include="XCSModel.cs" /> 128 <Compile Include="XCSSolution.cs" /> 118 129 <None Include="Properties\AssemblyInfo.cs.frame" /> 119 130 </ItemGroup> -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Interfaces/IConditionActionProblemData.cs
r9089 r9154 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using HeuristicLab.Core; … … 32 33 IEnumerable<string> AllowedConditionVariables { get; } 33 34 IEnumerable<string> AllowedActionVariables { get; } 35 36 IntValue Length { get; } 37 IntValue ActionLength { get; } 38 IntMatrix Bounds { get; } 39 40 IClassifier FetchClassifier(int rowNumber); 41 42 event EventHandler Changed; 34 43 } 35 44 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/HeuristicLab.Problems.ConditionActionClassification-3.3.csproj
r9105 r9154 40 40 <Reference Include="HeuristicLab.Collections-3.3"> 41 41 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath> 42 <Private>False</Private> 42 43 </Reference> 43 44 <Reference Include="HeuristicLab.Common-3.3"> 44 45 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath> 46 <Private>False</Private> 45 47 </Reference> 46 48 <Reference Include="HeuristicLab.Core-3.3"> 47 49 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath> 50 <Private>False</Private> 48 51 </Reference> 49 52 <Reference Include="HeuristicLab.Data-3.3"> 50 53 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath> 54 <Private>False</Private> 51 55 </Reference> 52 <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 53 <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 54 <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 56 <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 57 <Private>False</Private> 58 </Reference> 59 <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 60 <Private>False</Private> 61 </Reference> 62 <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 63 <Private>False</Private> 64 </Reference> 55 65 <Reference Include="HeuristicLab.Parameters-3.3"> 56 66 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath> 67 <Private>False</Private> 57 68 </Reference> 58 69 <Reference Include="HeuristicLab.Persistence-3.3"> 59 70 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath> 71 <Private>False</Private> 60 72 </Reference> 61 73 <Reference Include="HeuristicLab.PluginInfrastructure-3.3"> 62 74 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath> 75 <Private>False</Private> 63 76 </Reference> 64 <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 77 <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 78 <Private>False</Private> 79 </Reference> 65 80 <Reference Include="System" /> 66 81 <Reference Include="System.Core" /> … … 76 91 <Compile Include="Implementation\ConditionActionClassificationProblemData.cs" /> 77 92 <Compile Include="Plugin.cs" /> 78 <Compile Include="Reinforcement\CombinedIntegerVectorClassifierFetcher.cs" />79 93 <None Include="HeuristicLab.snk" /> 80 94 <None Include="Properties\AssemblyInfo.cs.frame" /> … … 88 102 <Project>{CE7163C5-BFFE-45F0-9BD0-E10EF24E8BD2}</Project> 89 103 <Name>HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3</Name> 104 <Private>False</Private> 90 105 </ProjectReference> 91 106 <ProjectReference Include="..\..\HeuristicLab.Encodings.ConditionActionEncoding\3.3\HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj"> 92 107 <Project>{422FB262-0845-4969-8D16-12F057AA90B1}</Project> 93 108 <Name>HeuristicLab.Encodings.ConditionActionEncoding-3.3</Name> 109 <Private>False</Private> 94 110 </ProjectReference> 95 111 </ItemGroup> -
branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblem.cs
r9110 r9154 76 76 get { return (IFixedValueParameter<IntValue>)Parameters["ThetaMinimalNumberOfActions"]; } 77 77 } 78 //for test purposes79 public IFixedValueParameter<IntValue> LengthParameter {80 get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; }81 }82 public IFixedValueParameter<IntValue> ActionPartLengthParameter {83 get { return (IFixedValueParameter<IntValue>)Parameters["ActionPartLength"]; }84 }85 public IFixedValueParameter<IntMatrix> BoundsParameter {86 get { return (IFixedValueParameter<IntMatrix>)Parameters["Bounds"]; }87 }88 78 #endregion 89 79 … … 120 110 } 121 111 IParameter IConditionActionProblem.ActionExecuterParameter { get { return ActionExecuterParameter; } } 122 public C ombinedIntegerVectorClassifierFetcher ClassifierFetcher {112 public ClassifierFetcher ClassifierFetcher { 123 113 get { return ClassifierFetcherParameter.Value; } 124 114 } 125 public ValueParameter<C ombinedIntegerVectorClassifierFetcher> ClassifierFetcherParameter {126 get { return (ValueParameter<C ombinedIntegerVectorClassifierFetcher>)Parameters[ClassifierFetcherParameterName]; }115 public ValueParameter<ClassifierFetcher> ClassifierFetcherParameter { 116 get { return (ValueParameter<ClassifierFetcher>)Parameters[ClassifierFetcherParameterName]; } 127 117 } 128 118 IClassifierFetcher IConditionActionProblem.ClassifierFetcher { get { return ClassifierFetcher; } } … … 150 140 IParameter IConditionActionProblem.CoveringSolutionCreatorParameter { 151 141 get { return CoveringSolutionCreatorParameter; } 142 } 143 private XCSSolutionAnalyzer XCSSolutionAnalyzer { 144 get { return Operators.OfType<XCSSolutionAnalyzer>().FirstOrDefault(); } 152 145 } 153 146 #endregion … … 170 163 public ConditionActionClassificationProblem(ConditionActionClassificationProblemData problemData, XCSEvaluator evaluator, UniformRandomCombinedIntegerVectorCreator solutionCreator, ICoveringSolutionCreator coveringSolutionCreator) 171 164 : base(evaluator, solutionCreator) { 172 Parameters.Add(new FixedValueParameter<IntValue>("Length", "The operator to create a solution.", new IntValue(7)));173 Parameters.Add(new FixedValueParameter<IntValue>("ActionPartLength", "The operator to create a solution.", new IntValue(1)));174 int[,] elements = new int[,] { { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 2 } };175 Parameters.Add(new FixedValueParameter<IntMatrix>("Bounds", "The operator to create a solution.", new IntMatrix(elements)));176 165 Parameters.Add(new ValueParameter<ConditionActionClassificationProblemData>("ProblemData", "", problemData)); 177 166 Parameters.Add(new FixedValueParameter<DoubleValue>("PositiveReward", "", new DoubleValue(1000))); … … 182 171 183 172 Parameters.Add(new ValueParameter<IActionExecuter>(ActionExecuterParameterName, "", new ActionExecuter())); 184 Parameters.Add(new ValueParameter<C ombinedIntegerVectorClassifierFetcher>(ClassifierFetcherParameterName, "", new CombinedIntegerVectorClassifierFetcher()));173 Parameters.Add(new ValueParameter<ClassifierFetcher>(ClassifierFetcherParameterName, "", new ClassifierFetcher())); 185 174 Parameters.Add(new FixedValueParameter<ItemSet<IClassifier>>("PossibleActions")); 186 175 Parameters.Add(new FixedValueParameter<ItemSet<CombinedIntegerVector>>("PossibleActionsConcreteClass")); … … 196 185 Evaluator.InitialPredictionParameter.ActualName = "InitialPrediction"; 197 186 198 SolutionCreator.ActionPartLengthParameter.ActualName = ActionPartLengthParameter.Name;199 SolutionCreator.LengthParameter.ActualName = LengthParameter.Name;200 SolutionCreator.BoundsParameter.ActualName = BoundsParameter.Name;187 SolutionCreator.ActionPartLengthParameter.ActualName = ProblemData.ActionLengthParameter.Name; 188 SolutionCreator.LengthParameter.ActualName = ProblemData.LengthParameter.Name; 189 SolutionCreator.BoundsParameter.ActualName = ProblemData.BoundsParameter.Name; 201 190 202 191 coveringSolutionCreator.ChangeSymbolProbabilityParameter.ActualName = ChangeSymbolProbabilityInCoveringParameter.Name; … … 204 193 coveringSolutionCreator.CreatedClassifierParameter.ActualName = "CombinedIntegerVector"; 205 194 206 ClassifierFetcher.ActionPartLengthParameter.ActualName = ActionPartLengthParameter.Name;207 ClassifierFetcher.BoundsParameter.ActualName = BoundsParameter.Name;208 195 ClassifierFetcher.ProblemDataParameter.ActualName = ProblemDataParameter.Name; 209 196 … … 217 204 ThetaMinimalNumberOfActions.Value = PossibleActions.Count; 218 205 219 BoundsParameter.ValueChanged += new System.EventHandler(BoundsParameter_ValueChanged); 220 LengthParameter.ValueChanged += new System.EventHandler(LengthParameter_ValueChanged); 221 ActionPartLengthParameter.ValueChanged += new System.EventHandler(ActionPartLengthParameter_ValueChanged); 222 } 223 224 #region event handler 225 private void ActionPartLengthParameter_ValueChanged(object sender, System.EventArgs e) { 206 InitializeOperators(); 207 208 problemData.Changed += new System.EventHandler(problemData_Changed); 209 } 210 211 private void problemData_Changed(object sender, System.EventArgs e) { 226 212 SetPossibleActions(); 227 213 } 228 private void LengthParameter_ValueChanged(object sender, System.EventArgs e) { 229 SetPossibleActions(); 230 } 231 private void BoundsParameter_ValueChanged(object sender, System.EventArgs e) { 232 SetPossibleActions(); 233 } 234 #endregion 214 215 private void InitializeOperators() { 216 Operators.Add(new XCSSolutionAnalyzer()); 217 218 ParameterizeAnalyzers(); 219 } 220 221 private void ParameterizeAnalyzers() { 222 if (XCSSolutionAnalyzer != null) { 223 XCSSolutionAnalyzer.ClassifierParameter.ActualName = SolutionCreator.CombinedIntegerVectorParameter.ActualName; 224 XCSSolutionAnalyzer.PredictionParameter.ActualName = Evaluator.PredictionParameter.ActualName; 225 XCSSolutionAnalyzer.ErrorParameter.ActualName = Evaluator.ErrorParameter.ActualName; 226 XCSSolutionAnalyzer.FitnessParameter.ActualName = Evaluator.FitnessParameter.ActualName; 227 XCSSolutionAnalyzer.ExperienceParameter.ActualName = Evaluator.ExperienceParameter.ActualName; 228 XCSSolutionAnalyzer.AverageActionSetSizeParameter.ActualName = Evaluator.AverageActionSetSizeParameter.ActualName; 229 XCSSolutionAnalyzer.NumerosityParameter.ActualName = Evaluator.NumerosityParameter.ActualName; 230 XCSSolutionAnalyzer.TimestampParameter.ActualName = Evaluator.TimestampParameter.ActualName; 231 XCSSolutionAnalyzer.ProblemDataParameter.ActualName = ProblemDataParameter.Name; 232 XCSSolutionAnalyzer.ResultsParameter.ActualName = "Results"; 233 } 234 } 235 235 236 236 private void SetPossibleActions() { 237 237 //get bounds of action 238 IntMatrix actionBounds = GetElementsOfBoundsForAction( BoundsParameter.Value, LengthParameter.Value.Value, ActionPartLengthParameter.Value.Value);239 int actionLength = ActionPartLengthParameter.Value.Value;240 int start = LengthParameter.Value.Value - actionLength;238 IntMatrix actionBounds = GetElementsOfBoundsForAction(ProblemData.Bounds, ProblemData.Length.Value, ProblemData.ActionLength.Value); 239 int actionLength = ProblemData.ActionLength.Value; 240 int start = ProblemData.Length.Value - actionLength; 241 241 int[] elements = new int[actionLength]; 242 242 int[] curPos = new int[actionLength]; -
branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblemData.cs
r9089 r9154 26 26 using HeuristicLab.Core; 27 27 using HeuristicLab.Data; 28 using HeuristicLab.Encodings.CombinedIntegerVectorEncoding; 28 29 using HeuristicLab.Encodings.ConditionActionEncoding; 29 30 using HeuristicLab.Parameters; … … 54 55 get { return (IFixedValueParameter<ReadOnlyCheckedItemList<StringValue>>)Parameters["ActionVariables"]; } 55 56 } 57 public IFixedValueParameter<IntValue> LengthParameter { 58 get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; } 59 } 60 public IFixedValueParameter<IntValue> ActionLengthParameter { 61 get { return (IFixedValueParameter<IntValue>)Parameters["ActionLength"]; } 62 } 63 public IFixedValueParameter<IntMatrix> BoundsParameter { 64 get { return (IFixedValueParameter<IntMatrix>)Parameters["Bounds"]; } 65 } 56 66 #endregion 57 67 … … 74 84 get { return ActionVariables.CheckedItems.Select(x => x.Value.Value); } 75 85 } 86 87 private IDictionary<int, IClassifier> fetchClassifiersCache = new Dictionary<int, IClassifier>(); 76 88 77 89 … … 105 117 Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>("ActionVariables", "", actionVariables.AsReadOnly())); 106 118 Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>("ConditionVariables", "", conditionVariables.AsReadOnly())); 119 Parameters.Add(new FixedValueParameter<IntValue>("Length", "", new IntValue(7))); 120 Parameters.Add(new FixedValueParameter<IntValue>("ActionLength", "", new IntValue(1))); 121 int[,] elements = new int[,] { { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 2 } }; 122 Parameters.Add(new FixedValueParameter<IntMatrix>("Bounds", "", new IntMatrix(elements))); 107 123 108 124 ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false; 109 125 } 126 127 public event EventHandler Changed; 128 protected virtual void OnChanged() { 129 var listeners = Changed; 130 if (listeners != null) listeners(this, EventArgs.Empty); 131 } 132 133 public IntValue Length { 134 get { return LengthParameter.Value; } 135 } 136 137 public IntValue ActionLength { 138 get { return ActionLengthParameter.Value; } 139 } 140 141 public IntMatrix Bounds { 142 get { return BoundsParameter.Value; } 143 } 144 145 public IClassifier FetchClassifier(int rowNumber) { 146 if (!fetchClassifiersCache.ContainsKey(rowNumber)) { 147 int[] elements = new int[Length.Value]; 148 var variableNamesList = Dataset.VariableNames.ToList(); 149 int elementIndex = 0; 150 for (int i = 0; i < variableNamesList.Count; i++) { 151 if (AllowedConditionVariables.Contains(variableNamesList[i])) { 152 elements[elementIndex] = int.Parse(Dataset.GetValue(rowNumber, i)); 153 elementIndex++; 154 } 155 } 156 for (int i = 0; i < variableNamesList.Count; i++) { 157 if (AllowedActionVariables.Contains(variableNamesList[i])) { 158 elements[elementIndex] = int.Parse(Dataset.GetValue(rowNumber, i)); 159 elementIndex++; 160 } 161 } 162 if (elementIndex != Length.Value) { 163 throw new ArgumentException("Length of classifier is not equal to the number of allowed condition + action variables."); 164 } 165 fetchClassifiersCache.Add(rowNumber, new CombinedIntegerVector(elements, ActionLengthParameter.Value.Value, BoundsParameter.Value)); 166 } 167 return fetchClassifiersCache[rowNumber]; 168 } 110 169 } 111 170 } -
branches/LearningClassifierSystems/LearningClassifierSystem.sln
r9089 r9154 15 15 EndProject 16 16 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.ConditionActionClassification-3.3", "HeuristicLab.Problems.ConditionActionClassification\3.3\HeuristicLab.Problems.ConditionActionClassification-3.3.csproj", "{EA51D441-F6A3-41E1-9993-A2488E93C222}" 17 EndProject 18 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.XCS.Views-3.3", "HeuristicLab.Problems.XCS.Views\3.3\HeuristicLab.Problems.XCS.Views-3.3.csproj", "{8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}" 17 19 EndProject 18 20 Global … … 62 64 {EA51D441-F6A3-41E1-9993-A2488E93C222}.Release|x64.ActiveCfg = Release|Any CPU 63 65 {EA51D441-F6A3-41E1-9993-A2488E93C222}.Release|x86.ActiveCfg = Release|Any CPU 66 {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 67 {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Debug|Any CPU.Build.0 = Debug|Any CPU 68 {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Debug|x64.ActiveCfg = Debug|Any CPU 69 {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Debug|x86.ActiveCfg = Debug|Any CPU 70 {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Release|Any CPU.ActiveCfg = Release|Any CPU 71 {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Release|Any CPU.Build.0 = Release|Any CPU 72 {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Release|x64.ActiveCfg = Release|Any CPU 73 {8FFB8E0F-BC17-4D72-AF0F-E67A22F8EDE5}.Release|x86.ActiveCfg = Release|Any CPU 64 74 EndGlobalSection 65 75 GlobalSection(SolutionProperties) = preSolution
Note: See TracChangeset
for help on using the changeset viewer.