Changeset 9154 for branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3
- Timestamp:
- 01/14/13 15:23:17 (12 years ago)
- Location:
- branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.