Changeset 9194 for branches/LearningClassifierSystems
- Timestamp:
- 01/28/13 17:54:46 (12 years ago)
- Location:
- branches/LearningClassifierSystems
- Files:
-
- 28 added
- 2 deleted
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/HeuristicLab.Algorithms.LearningClassifierSystems-3.3.csproj
r9160 r9194 50 50 <Reference Include="HeuristicLab.Common-3.3"> 51 51 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath> 52 <Private>False</Private>53 </Reference>54 <Reference Include="HeuristicLab.Core-3.3">55 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>56 52 <Private>False</Private> 57 53 </Reference> … … 116 112 </ItemGroup> 117 113 <ItemGroup> 114 <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj"> 115 <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project> 116 <Name>HeuristicLab.Core-3.3</Name> 117 </ProjectReference> 118 118 <ProjectReference Include="..\..\HeuristicLab.Encodings.CombinedIntegerVectorEncoding\3.3\HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3.csproj"> 119 119 <Project>{CE7163C5-BFFE-45F0-9BD0-E10EF24E8BD2}</Project> -
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystemMainLoop.cs
r9175 r9194 76 76 private DoDeletionBeforeCoveringOperator doDeletionBeforeCovering; 77 77 private CoveringOperator covering; 78 private CountNumberOfUniqueActions countNumberOfUniqueActions; 78 79 79 80 private UniformSomePositionManipulator test; … … 136 137 ConditionalSelector actionMatchSelector = new ConditionalSelector(); 137 138 SubScopesProcessor matchSetSubScopesProcessor = new SubScopesProcessor(); 138 CountNumberOfUniqueActionscountNumberOfUniqueActions = new CountNumberOfUniqueActions();139 countNumberOfUniqueActions = new CountNumberOfUniqueActions(); 139 140 doDeletionBeforeCovering = new DoDeletionBeforeCoveringOperator(); 140 141 ConditionalBranch doDeletionBeforeCoveringConditionalBranch = new ConditionalBranch(); … … 439 440 classifierFetcher.OperatorParameter.ActualName = problem.ClassifierFetcherParameter.Name; 440 441 441 test.FetchedC lassifierParameter.ActualName = problem.ClassifierFetcher.CurrentClassifierToMatchParameter.ActualName;442 test.FetchedConditionParameter.ActualName = problem.ClassifierFetcher.CurrentInputToMatchParameter.ActualName; 442 443 test.PossibleActionsParameter.ActualName = problem.PossibleActionsConcreteClassParameter.Name; 443 444 … … 454 455 actionSetSubsumption.OperatorParameter.ActualName = problem.ActionSetSubsumptionOperatorParameter.Name; 455 456 456 matchConditionOperator.TargetMatchParameter.ActualName = problem.ClassifierFetcher.Current ClassifierToMatchParameter.ActualName;457 matchConditionOperator.TargetMatchParameter.ActualName = problem.ClassifierFetcher.CurrentInputToMatchParameter.ActualName; 457 458 458 459 doDeletionBeforeCovering.MinimalNumberOfUniqueActionsParameter.ActualName = problem.ThetaMinimalNumberOfActionsParameter.Name; 460 doDeletionBeforeCovering.ClassifierComparerParameter.ActualName = problem.ClassifierComparerParameter.Name; 459 461 460 462 covering.SolutionCreatorParameter.ActualName = problem.CoveringSolutionCreatorParameter.Name; … … 465 467 predictionArrayCalculator.PredictionParameter.ActualName = problem.Evaluator.PredictionParameter.ActualName; 466 468 predictionArrayCalculator.FitnessParameter.ActualName = problem.Evaluator.FitnessParameter.ActualName; 469 predictionArrayCalculator.ClassifierComparerParameter.ActualName = problem.ClassifierComparerParameter.Name; 470 471 countNumberOfUniqueActions.ClassifierComparerParameter.ActualName = problem.ClassifierComparerParameter.Name; 467 472 } 468 473 //private void ParameterizeSelectors() { -
branches/LearningClassifierSystems/HeuristicLab.Core/3.3/Collections/ItemDictionary.cs
r7725 r9194 59 59 public ItemDictionary() : base() { } 60 60 public ItemDictionary(int capacity) : base(capacity) { } 61 public ItemDictionary(IEqualityComparer<TKey> comparer) : base(comparer) { } 61 62 public ItemDictionary(IDictionary<TKey, TValue> dictionary) : base(dictionary) { } 63 public ItemDictionary(IDictionary<TKey, TValue> dictionary, IEqualityComparer<TKey> comparer) : base(dictionary, comparer) { } 62 64 63 65 public object Clone() { -
branches/LearningClassifierSystems/HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj
r9178 r9194 41 41 <DebugType>full</DebugType> 42 42 <Optimize>false</Optimize> 43 <OutputPath> $(SolutionDir)\bin\</OutputPath>43 <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath> 44 44 <DefineConstants>DEBUG;TRACE</DefineConstants> 45 45 <ErrorReport>prompt</ErrorReport> … … 52 52 <DebugType>pdbonly</DebugType> 53 53 <Optimize>true</Optimize> 54 <OutputPath> $(SolutionDir)\bin\</OutputPath>54 <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath> 55 55 <DefineConstants>TRACE</DefineConstants> 56 56 <ErrorReport>prompt</ErrorReport> … … 63 63 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> 64 64 <DebugSymbols>true</DebugSymbols> 65 <OutputPath> $(SolutionDir)\bin\</OutputPath>65 <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath> 66 66 <DefineConstants>DEBUG;TRACE</DefineConstants> 67 67 <DebugType>full</DebugType> … … 71 71 </PropertyGroup> 72 72 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> 73 <OutputPath> $(SolutionDir)\bin\</OutputPath>73 <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath> 74 74 <DefineConstants>TRACE</DefineConstants> 75 75 <DocumentationFile> … … 83 83 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' "> 84 84 <DebugSymbols>true</DebugSymbols> 85 <OutputPath> $(SolutionDir)\bin\</OutputPath>85 <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath> 86 86 <DefineConstants>DEBUG;TRACE</DefineConstants> 87 87 <DebugType>full</DebugType> … … 91 91 </PropertyGroup> 92 92 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' "> 93 <OutputPath> $(SolutionDir)\bin\</OutputPath>93 <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath> 94 94 <DefineConstants>TRACE</DefineConstants> 95 95 <DocumentationFile> … … 102 102 </PropertyGroup> 103 103 <ItemGroup> 104 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 105 <Private>False</Private> 106 </Reference> 107 <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 108 <Private>False</Private> 109 </Reference> 110 <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 111 <Private>False</Private> 112 </Reference> 113 <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 114 <Private>False</Private> 115 </Reference> 116 <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 117 <Private>False</Private> 118 </Reference> 104 119 <Reference Include="System" /> 105 120 <Reference Include="System.Core"> … … 205 220 </ItemGroup> 206 221 <ItemGroup> 207 <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">208 <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>209 <Name>HeuristicLab.Collections-3.3</Name>210 <Private>False</Private>211 </ProjectReference>212 <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">213 <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>214 <Name>HeuristicLab.Common.Resources-3.3</Name>215 <Private>False</Private>216 </ProjectReference>217 <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">218 <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>219 <Name>HeuristicLab.Common-3.3</Name>220 <Private>False</Private>221 </ProjectReference>222 <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">223 <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>224 <Name>HeuristicLab.Persistence-3.3</Name>225 <Private>False</Private>226 </ProjectReference>227 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">228 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>229 <Name>HeuristicLab.PluginInfrastructure-3.3</Name>230 <Private>False</Private>231 </ProjectReference>232 </ItemGroup>233 <ItemGroup>234 222 <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> 235 223 <Visible>False</Visible> -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/CombinedIntegerVector.cs
r9175 r9194 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using System.Text; … … 33 34 [StorableClass] 34 35 [Item("CombinedIntegerVector", "Represents a combined vector of integer values.")] 35 public class CombinedIntegerVector : IntegerVector, IClassifier {36 public class CombinedIntegerVector : IntegerVector, IClassifier, ICondition, IAction, IInput { 36 37 37 38 [Storable] … … 121 122 } 122 123 123 public IC lassifierCondition {124 public ICondition Condition { 124 125 get { 125 126 int[] condition = new int[Length - actionLength]; … … 129 130 } 130 131 131 public I ClassifierAction {132 public IAction Action { 132 133 get { 133 134 int[] action = new int[actionLength]; … … 152 153 } 153 154 154 public bool Match Condition(IClassifiertarget) {155 public bool MatchInput(IInput target) { 155 156 var targetVector = target as CombinedIntegerVector; 156 157 if (targetVector == null) return false; 157 if (targetVector.Length != this.Length) return false;158 if (targetVector.Length - targetVector.actionLength != this.Length - this.actionLength) return false; 158 159 159 160 int curbounds; … … 171 172 } 172 173 174 public bool MatchAction(IClassifier target) { 175 return MatchAction(target.Action); 176 } 177 173 178 // no "don't care" symbols have to be considered 174 public bool MatchAction(I Classifiertarget) {179 public bool MatchAction(IAction target) { 175 180 var targetVector = target as CombinedIntegerVector; 176 181 if (targetVector == null) return false; … … 188 193 189 194 public bool IsMoreGeneral(IClassifier target) { 195 return IsMoreGeneral(target as ICondition); 196 } 197 198 public bool IsMoreGeneral(ICondition target) { 190 199 var targetVector = target as CombinedIntegerVector; 191 200 int curbounds; … … 201 210 return true; 202 211 } 212 213 #region ICondition Members 214 public bool Match(IInput target) { 215 return MatchInput(target); 216 } 217 #endregion 218 219 #region IAction Members 220 public bool Match(IAction target) { 221 return MatchAction(target); 222 } 223 #endregion 203 224 204 225 private int NumberOfGeneralSymbols() { … … 233 254 } 234 255 235 public override bool Equals(object obj) { 236 var cast = obj as CombinedIntegerVector; 237 if (cast != null) { 238 return this.Equals(cast); 239 } 240 return false; 241 } 242 243 public bool Equals(IClassifier other) { 244 var cast = other as CombinedIntegerVector; 256 public bool Identical(IClassifier target) { 257 var cast = target as CombinedIntegerVector; 245 258 if (cast == null) { return false; } 246 259 for (int i = 0; i < array.Length; i++) { … … 252 265 } 253 266 267 public override bool Equals(object obj) { 268 return base.Equals(obj); 269 } 270 254 271 public override int GetHashCode() { 255 int result = actionLength; 256 for (int i = 0; i < array.Length; i++) { 257 result ^= array[i]; 258 } 259 return result.GetHashCode(); 272 return base.GetHashCode(); 273 } 274 275 [StorableClass] 276 [Item("CombinedIntegerVectorComparer", "")] 277 public class CombinedIntegerVectorComparer : Item, IEqualityComparer<CombinedIntegerVector>, IClassifierComparer { 278 279 [StorableConstructor] 280 protected CombinedIntegerVectorComparer(bool deserializing) : base(deserializing) { } 281 protected CombinedIntegerVectorComparer(CombinedIntegerVectorComparer original, Cloner cloner) 282 : base(original, cloner) { 283 } 284 public override IDeepCloneable Clone(Cloner cloner) { 285 return new CombinedIntegerVectorComparer(this, cloner); 286 } 287 public CombinedIntegerVectorComparer() : base() { } 288 289 public bool Equals(CombinedIntegerVector x, CombinedIntegerVector y) { 290 for (int i = 0; i < x.array.Length; i++) { 291 if (!x.array[i].Equals(y.array[i])) { 292 return false; 293 } 294 } 295 return true; 296 } 297 298 public int GetHashCode(CombinedIntegerVector obj) { 299 int result = obj.actionLength; 300 for (int i = 0; i < obj.array.Length; i++) { 301 result ^= obj.array[i]; 302 } 303 return result.GetHashCode(); 304 } 305 306 public bool Equals(IAction x, IAction y) { 307 var xCast = x as CombinedIntegerVector; 308 var yCast = y as CombinedIntegerVector; 309 return x != null && y != null && Equals(xCast, yCast); 310 } 311 312 public int GetHashCode(IAction obj) { 313 var objCast = obj as CombinedIntegerVector; 314 return objCast != null ? GetHashCode(objCast) : obj.GetHashCode(); 315 } 260 316 } 261 317 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/CombinedIntegerVectorManipulator.cs
r9110 r9194 39 39 get { return (ILookupParameter<CombinedIntegerVector>)Parameters["Child"]; } 40 40 } 41 public ILookupParameter<CombinedIntegerVector> FetchedC lassifierParameter {41 public ILookupParameter<CombinedIntegerVector> FetchedConditionParameter { 42 42 get { return (ILookupParameter<CombinedIntegerVector>)Parameters["Parent"]; } 43 43 } … … 57 57 58 58 public sealed override IOperation Apply() { 59 ChildParameter.ActualValue = Manipulate(RandomParameter.ActualValue, FetchedC lassifierParameter.ActualValue, ChildParameter.ActualValue);59 ChildParameter.ActualValue = Manipulate(RandomParameter.ActualValue, FetchedConditionParameter.ActualValue, ChildParameter.ActualValue); 60 60 return base.Apply(); 61 61 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Covering/CombinedIntegerVectorCoveringCreator.cs
r9110 r9194 34 34 35 35 #region Parameter Properties 36 public ILookupParameter<I Classifier> CoverClassifierParameter {37 get { return (ILookupParameter<I Classifier>)Parameters["CoverClassifier"]; }36 public ILookupParameter<IInput> CoverInputParameter { 37 get { return (ILookupParameter<IInput>)Parameters["CoverInput"]; } 38 38 } 39 public ILookupParameter<I Classifier> ActionParameter {40 get { return (ILookupParameter<I Classifier>)Parameters["Action"]; }39 public ILookupParameter<IAction> ActionParameter { 40 get { return (ILookupParameter<IAction>)Parameters["Action"]; } 41 41 } 42 42 public IValueLookupParameter<IClassifier> CreatedClassifierParameter { … … 62 62 public CombinedIntegerVectorCoveringCreator() 63 63 : base() { 64 Parameters.Add(new LookupParameter<I Classifier>("CoverClassifier"));65 Parameters.Add(new LookupParameter<I Classifier>("Action"));64 Parameters.Add(new LookupParameter<IInput>("CoverInput")); 65 Parameters.Add(new LookupParameter<IAction>("Action")); 66 66 Parameters.Add(new ValueLookupParameter<IClassifier>("CreatedClassifier")); 67 67 Parameters.Add(new LookupParameter<PercentValue>("ChangeSymbolProbability")); … … 70 70 71 71 public override IOperation Apply() { 72 CombinedIntegerVector newCondition = (CombinedIntegerVector)Cover ClassifierParameter.ActualValue.Condition.Clone();72 CombinedIntegerVector newCondition = (CombinedIntegerVector)CoverInputParameter.ActualValue.Clone(); 73 73 74 CombinedIntegerVector condition = (CombinedIntegerVector)Cover ClassifierParameter.ActualValue.Condition;75 CombinedIntegerVector action = (CombinedIntegerVector)ActionParameter.ActualValue .Action;74 CombinedIntegerVector condition = (CombinedIntegerVector)CoverInputParameter.ActualValue; 75 CombinedIntegerVector action = (CombinedIntegerVector)ActionParameter.ActualValue; 76 76 77 77 newCondition = UniformSomePositionManipulator.ManipulateCondition(RandomParameter.ActualValue, condition, newCondition, ChangeSymbolProbabilityParameter.ActualValue.Value); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3.csproj
r9154 r9194 89 89 <Private>False</Private> 90 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 91 <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 95 92 <Private>False</Private> … … 149 146 </ItemGroup> 150 147 <ItemGroup> 148 <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj"> 149 <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project> 150 <Name>HeuristicLab.Core-3.3</Name> 151 </ProjectReference> 151 152 <ProjectReference Include="..\..\HeuristicLab.Encodings.ConditionActionEncoding\3.3\HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj"> 152 153 <Project>{422FB262-0845-4969-8D16-12F057AA90B1}</Project> -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Interfaces/ICombinedIntegerVectorManipulator.cs
r9110 r9194 29 29 public interface ICombinedIntegerVectorManipulator : IManipulator, ICombinedIntegerVectorOperator { 30 30 ILookupParameter<CombinedIntegerVector> ChildParameter { get; } 31 ILookupParameter<CombinedIntegerVector> FetchedC lassifierParameter { get; }31 ILookupParameter<CombinedIntegerVector> FetchedConditionParameter { get; } 32 32 } 33 33 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/ActionSelection/ActionSelector.cs
r9089 r9194 37 37 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } 38 38 } 39 public IValueLookupParameter<I Classifier> SelectedActionParameter {40 get { return (IValueLookupParameter<I Classifier>)Parameters["SelectedAction"]; }39 public IValueLookupParameter<IAction> SelectedActionParameter { 40 get { return (IValueLookupParameter<IAction>)Parameters["SelectedAction"]; } 41 41 } 42 public ILookupParameter<IItemDictionary<I Classifier, DoubleValue>> PredictionArrayParameter {43 get { return (ILookupParameter<IItemDictionary<I Classifier, DoubleValue>>)Parameters["PredictionArray"]; }42 public ILookupParameter<IItemDictionary<IAction, DoubleValue>> PredictionArrayParameter { 43 get { return (ILookupParameter<IItemDictionary<IAction, DoubleValue>>)Parameters["PredictionArray"]; } 44 44 } 45 45 public ILookupParameter<PercentValue> ExplorationProbabilityParameter { … … 55 55 : base() { 56 56 Parameters.Add(new LookupParameter<IRandom>("Random")); 57 Parameters.Add(new ValueLookupParameter<I Classifier>("SelectedAction", "Action, which has been selected."));58 Parameters.Add(new LookupParameter<IItemDictionary<I Classifier, DoubleValue>>("PredictionArray"));57 Parameters.Add(new ValueLookupParameter<IAction>("SelectedAction", "Action, which has been selected.")); 58 Parameters.Add(new LookupParameter<IItemDictionary<IAction, DoubleValue>>("PredictionArray")); 59 59 Parameters.Add(new LookupParameter<PercentValue>("ExplorationProbability")); 60 60 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/ActionSelection/MaxValueActionSelector.cs
r9089 r9194 36 36 get { return (ILookupParameter<ItemArray<DoubleValue>>)Parameters["ValueParameter"]; } 37 37 } 38 public ILookupParameter<IClassifierComparer> ClassifierComparerParameter { 39 get { return (ILookupParameter<IClassifierComparer>)Parameters["ClassifierComparer"]; } 40 } 38 41 39 42 [StorableConstructor] … … 43 46 : base() { 44 47 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("ValueParameter", "DoubleValue which will be summed up.")); 48 Parameters.Add(new LookupParameter<IClassifierComparer>("ClassifierComparer")); 45 49 } 46 50 public override IDeepCloneable Clone(Cloner cloner) { … … 48 52 } 49 53 50 protected override I ClassifierSelectAction(List<IScope> scopes) {51 Dictionary<I Classifier, double> actionSet = new Dictionary<IClassifier, double>();54 protected override IAction SelectAction(List<IScope> scopes) { 55 Dictionary<IAction, double> actionSet = new Dictionary<IAction, double>(ClassifierComparerParameter.ActualValue); 52 56 for (int i = 0; i < MatchParameter.ActualValue.Length; i++) { 53 57 var action = MatchParameter.ActualValue[i].Action; -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/ActionSelection/OldActionSelector.cs
r9089 r9194 38 38 get { return (ILookupParameter<ItemArray<IClassifier>>)Parameters["MatchParameter"]; } 39 39 } 40 public IValueLookupParameter<I Classifier> SelectedActionParameter {41 get { return (IValueLookupParameter<I Classifier>)Parameters["SelectedAction"]; }40 public IValueLookupParameter<IAction> SelectedActionParameter { 41 get { return (IValueLookupParameter<IAction>)Parameters["SelectedAction"]; } 42 42 } 43 43 … … 54 54 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope from which sub-scopes should be selected.")); 55 55 Parameters.Add(new ScopeTreeLookupParameter<IClassifier>("MatchParameter", "The matching encoding contained in each sub-scope which is used for selection.")); 56 Parameters.Add(new ValueLookupParameter<I Classifier>("SelectedAction", "Action, which has been selected."));56 Parameters.Add(new ValueLookupParameter<IAction>("SelectedAction", "Action, which has been selected.")); 57 57 } 58 58 … … 63 63 } 64 64 65 protected abstract I ClassifierSelectAction(List<IScope> scopes);65 protected abstract IAction SelectAction(List<IScope> scopes); 66 66 } 67 67 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/ActionSelection/RandomActionSelector.cs
r9089 r9194 45 45 } 46 46 47 protected override I ClassifierSelectAction(List<IScope> scopes) {47 protected override IAction SelectAction(List<IScope> scopes) { 48 48 IRandom random = RandomParameter.ActualValue; 49 49 int index = random.Next(MatchParameter.ActualValue.Length); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Analyzer/XCSSolutionAnalyzer.cs
r9175 r9194 66 66 get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; } 67 67 } 68 public ILookupParameter<IClassifierComparer> ClassifierComparerParameter { 69 get { return (ILookupParameter<IClassifierComparer>)Parameters["ClassifierComparer"]; } 70 } 68 71 69 72 public ResultCollection Results { get { return ResultsParameter.ActualValue; } } … … 84 87 Parameters.Add(new LookupParameter<IConditionActionProblemData>("ProblemData", "")); 85 88 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the solution should be stored.")); 89 Parameters.Add(new LookupParameter<IClassifierComparer>("ClassifierComparer")); 86 90 } 87 91 … … 105 109 106 110 XCSModel xcsModel = new XCSModel(xcsClassifiers); 107 111 xcsModel.ClassifierComparer = ClassifierComparerParameter.ActualValue; 108 112 UseCurrentXCSSolution(xcsModel.CreateConditionActionSolution(problemData)); 109 113 return base.Apply(); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Covering/CoveringOperator.cs
r9110 r9194 35 35 36 36 #region Parameter Properties 37 public ILookupParameter<IItemSet<I Classifier>> ActionsInMatchSetParameter {38 get { return (ILookupParameter<IItemSet<I Classifier>>)Parameters["ActionsInMatchSet"]; }37 public ILookupParameter<IItemSet<IAction>> ActionsInMatchSetParameter { 38 get { return (ILookupParameter<IItemSet<IAction>>)Parameters["ActionsInMatchSet"]; } 39 39 } 40 public ILookupParameter<IItemSet<I Classifier>> PossibleActionsParameter {41 get { return (ILookupParameter<IItemSet<I Classifier>>)Parameters["PossibleActions"]; }40 public ILookupParameter<IItemSet<IAction>> PossibleActionsParameter { 41 get { return (ILookupParameter<IItemSet<IAction>>)Parameters["PossibleActions"]; } 42 42 } 43 43 public ILookupParameter<IntValue> MinimalNumberOfUniqueActionsParameter { … … 77 77 public CoveringOperator() 78 78 : base() { 79 Parameters.Add(new LookupParameter<IClassifier>("CoverClassifier")); 80 Parameters.Add(new LookupParameter<IItemSet<IClassifier>>("ActionsInMatchSet")); 81 Parameters.Add(new LookupParameter<IItemSet<IClassifier>>("PossibleActions")); 79 Parameters.Add(new LookupParameter<IItemSet<IAction>>("ActionsInMatchSet")); 80 Parameters.Add(new LookupParameter<IItemSet<IAction>>("PossibleActions")); 82 81 Parameters.Add(new LookupParameter<IntValue>("MinimalNumberOfUniqueActions")); 83 82 Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator")); … … 95 94 bool parallel = ParallelParameter.ActualValue.Value; 96 95 97 IItemSet<I Classifier> clone = (IItemSet<IClassifier>)PossibleActionsParameter.ActualValue.Clone();96 IItemSet<IAction> clone = (IItemSet<IAction>)PossibleActionsParameter.ActualValue.Clone(); 98 97 clone.ExceptWith(ActionsInMatchSetParameter.ActualValue); 99 98 … … 116 115 VariableCreator variableCreator = new VariableCreator(); 117 116 int pos = RandomParameter.ActualValue.Next(clone.Count); 118 I Classifieraction = clone.ElementAt(pos);117 IAction action = clone.ElementAt(pos); 119 118 clone.Remove(action); 120 variableCreator.CollectedValues.Add(new ValueParameter<I Classifier>("Action", action));119 variableCreator.CollectedValues.Add(new ValueParameter<IAction>("Action", action)); 121 120 variableCreation.Add(ExecutionContext.CreateOperation(variableCreator, CurrentScope.SubScopes[current + i])); 122 121 creation.Add(ExecutionContext.CreateOperation(creator, CurrentScope.SubScopes[current + i])); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Covering/DoDeletionBeforeCovering.cs
r9110 r9194 55 55 get { return (IValueLookupParameter<IntValue>)Parameters["NumberToDelete"]; } 56 56 } 57 public ILookupParameter<IClassifierComparer> ClassifierComparerParameter { 58 get { return (ILookupParameter<IClassifierComparer>)Parameters["ClassifierComparer"]; } 59 } 57 60 #endregion 58 61 … … 71 74 Parameters.Add(new ValueLookupParameter<BoolValue>("DoDeletion")); 72 75 Parameters.Add(new ValueLookupParameter<IntValue>("NumberToDelete")); 76 Parameters.Add(new LookupParameter<IClassifierComparer>("ClassifierComparer")); 73 77 } 74 78 public override IDeepCloneable Clone(Cloner cloner) { … … 77 81 78 82 public override IOperation Apply() { 79 IItemSet<I Classifier> uniqueActions = new ItemSet<IClassifier>();83 IItemSet<IAction> uniqueActions = new ItemSet<IAction>(ClassifierComparerParameter.ActualValue); 80 84 var classifiers = ClassifiersParameter.ActualValue; 81 85 var matchcondition = MatchConditionParameter.ActualValue; -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Covering/ICovering.cs
r9105 r9194 26 26 namespace HeuristicLab.Encodings.ConditionActionEncoding { 27 27 public interface ICovering : IStochasticOperator { 28 ILookupParameter<IItemSet<I Classifier>> ActionsInMatchSetParameter { get; }29 ILookupParameter<IItemSet<I Classifier>> PossibleActionsParameter { get; }28 ILookupParameter<IItemSet<IAction>> ActionsInMatchSetParameter { get; } 29 ILookupParameter<IItemSet<IAction>> PossibleActionsParameter { get; } 30 30 31 31 ILookupParameter<IntValue> MinimalNumberOfUniqueActionsParameter { get; } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Covering/ICoveringSolutionCreator.cs
r9090 r9194 28 28 namespace HeuristicLab.Encodings.ConditionActionEncoding { 29 29 public interface ICoveringSolutionCreator : IOperator, IParameterizedNamedItem, INamedItem, IParameterizedItem, IItem, IContent, IDeepCloneable, ICloneable, IStochasticOperator { 30 ILookupParameter<I Classifier> CoverClassifierParameter { get; }31 ILookupParameter<I Classifier> ActionParameter { get; }30 ILookupParameter<IInput> CoverInputParameter { get; } 31 ILookupParameter<IAction> ActionParameter { get; } 32 32 33 33 IValueLookupParameter<IClassifier> CreatedClassifierParameter { get; } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/GA/InsertInPopulationOperator.cs
r9110 r9194 86 86 IClassifier cl = classifiers[indices]; 87 87 for (int i = 0; i < classifiers.Length; i++) { 88 if (!hasToBeDeleted[i].Value && !insertInPopulation[i].Value && cl. Equals(classifiers[i])) {88 if (!hasToBeDeleted[i].Value && !insertInPopulation[i].Value && cl.Identical(classifiers[i])) { 89 89 numerosities[i].Value += numerosities[indices].Value; 90 90 hasToBeDeleted[indices].Value = true; -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj
r9175 r9194 43 43 </Reference> 44 44 <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 45 <Private>False</Private>46 </Reference>47 <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">48 45 <Private>False</Private> 49 46 </Reference> … … 124 121 <Compile Include="Reinforcement\IActionExecuter.cs" /> 125 122 <Compile Include="Reinforcement\IClassifierFetcher.cs" /> 126 <Compile Include="Selectors\IMatchSelector.cs" />127 <Compile Include="Selectors\MatchSelector.cs" />128 123 <Compile Include="Selectors\PreservingRightReducer.cs" /> 129 124 <Compile Include="Subsumption\ActionSetSubsumptionOperator.cs" /> … … 140 135 <None Include="Plugin.cs.frame" /> 141 136 </ItemGroup> 142 <ItemGroup /> 137 <ItemGroup> 138 <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj"> 139 <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project> 140 <Name>HeuristicLab.Core-3.3</Name> 141 </ProjectReference> 142 </ItemGroup> 143 143 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 144 144 <PropertyGroup> -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/IClassifier.cs
r9175 r9194 20 20 #endregion 21 21 22 using System ;22 using System.Collections.Generic; 23 23 using HeuristicLab.Core; 24 24 25 25 namespace HeuristicLab.Encodings.ConditionActionEncoding { 26 /// <summary> 27 /// IMatching is used in dictinoaries, therefore the methods "Equals" and "GetHashCode" have to be overriden 28 /// IEquatable<IMatching> should be implemented as well. 29 /// 30 /// This also helps to implement macroclassifiers later on 31 /// </summary> 32 public interface IClassifier : IItem, IEquatable<IClassifier> { 33 IClassifier Condition { get; } 34 IClassifier Action { get; } 35 bool MatchCondition(IClassifier target); 36 bool MatchAction(IClassifier target); 26 public interface IClassifier : IItem { 27 ICondition Condition { get; } 28 IAction Action { get; } 29 30 bool MatchInput(IInput target); 31 bool MatchAction(IAction target); 37 32 bool IsMoreGeneral(IClassifier target); 33 bool IsMoreGeneral(ICondition target); 38 34 39 //to use IMatching as key in a dictionary, Equals and GetHashCode have to be override. 40 //Also IEquatable<Class> should be implemented. 41 bool Equals(object obj); 42 int GetHashCode(); 35 bool Identical(IClassifier target); 43 36 } 37 38 public interface ICondition : IItem { 39 bool Match(IInput target); 40 } 41 42 public interface IAction : IItem { 43 bool Match(IAction target); 44 } 45 46 public interface IInput : IItem { } 47 48 public interface IClassifierComparer : IEqualityComparer<IAction>, IItem { } 44 49 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Interfaces/IConditionActionModel.cs
r9161 r9194 28 28 29 29 int ClassifierCount { get; } 30 IEnumerable<I Classifier> GetAction(IEnumerable<IClassifier> classifiers);31 I Classifier GetAction(IClassifierclassifier);30 IEnumerable<IAction> GetAction(IEnumerable<IInput> classifiers); 31 IAction GetAction(IInput classifier); 32 32 } 33 33 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Interfaces/IConditionActionProblem.cs
r9110 r9194 37 37 //IItemSet<IClassifier> PossibleActions { get; } 38 38 39 IParameter ClassifierComparerParameter { get; } 40 39 41 ICoveringSolutionCreator CoveringSolutionCreator { get; } 40 42 IParameter CoveringSolutionCreatorParameter { get; } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Interfaces/IConditionActionProblemData.cs
r9161 r9194 43 43 bool IsTestSample(int index); 44 44 45 IEnumerable<IClassifier> FetchClassifier(IEnumerable<int> rows); 46 IClassifier FetchClassifier(int rowNumber); 45 IEnumerable<IInput> FetchInput(IEnumerable<int> rows); 46 IInput FetchInput(int rowNumber); 47 48 IEnumerable<IAction> FetchAction(IEnumerable<int> rows); 49 IAction FetchAction(int rowNumber); 47 50 48 51 event EventHandler Changed; -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Operator/CountNumberOfUniqueActions.cs
r9090 r9194 35 35 get { return (ILookupParameter<ItemArray<IClassifier>>)Parameters["Classifiers"]; } 36 36 } 37 public IValueLookupParameter<IItemSet<IClassifier>> UniqueActionsParameter { 38 get { return (IValueLookupParameter<IItemSet<IClassifier>>)Parameters["UniqueActions"]; } 37 public ILookupParameter<IClassifierComparer> ClassifierComparerParameter { 38 get { return (ILookupParameter<IClassifierComparer>)Parameters["ClassifierComparer"]; } 39 } 40 public IValueLookupParameter<IItemSet<IAction>> UniqueActionsParameter { 41 get { return (IValueLookupParameter<IItemSet<IAction>>)Parameters["UniqueActions"]; } 39 42 } 40 43 public IValueLookupParameter<IntValue> NumberOfUniqueActionsParameter { … … 53 56 : base() { 54 57 Parameters.Add(new ScopeTreeLookupParameter<IClassifier>("Classifiers")); 55 Parameters.Add(new ValueLookupParameter<IItemSet<IClassifier>>("UniqueActions")); 58 Parameters.Add(new LookupParameter<IClassifierComparer>("ClassifierComparer")); 59 Parameters.Add(new ValueLookupParameter<IItemSet<IAction>>("UniqueActions")); 56 60 Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfUniqueActions")); 57 61 } 58 62 59 63 public override IOperation Apply() { 60 ItemSet<I Classifier> actions = new ItemSet<IClassifier>();64 ItemSet<IAction> actions = new ItemSet<IAction>(ClassifierComparerParameter.ActualValue); 61 65 foreach (var classifier in ClassifiersParameter.ActualValue) { 62 66 actions.Add(classifier.Action); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Operator/MatchActionOperator.cs
r9089 r9194 34 34 get { return (ILookupParameter<BoolValue>)Parameters["MatchAction"]; } 35 35 } 36 public ILookupParameter<I Classifier> TargetMatchParameter {37 get { return (ILookupParameter<I Classifier>)Parameters["TargetMatchParameter"]; }36 public ILookupParameter<IAction> TargetMatchParameter { 37 get { return (ILookupParameter<IAction>)Parameters["TargetMatchParameter"]; } 38 38 } 39 39 public ILookupParameter<IClassifier> MatchParameter { … … 49 49 : base() { 50 50 Parameters.Add(new LookupParameter<BoolValue>("MatchAction", "True if the action matches.")); 51 Parameters.Add(new ValueLookupParameter<I Classifier>("TargetMatchParameter", "Target that has to be matched by the match parameter."));51 Parameters.Add(new ValueLookupParameter<IAction>("TargetMatchParameter", "Target that has to be matched by the match parameter.")); 52 52 Parameters.Add(new ValueLookupParameter<IClassifier>("MatchParameter", "The matching encoding contained in each sub-scope which is used for selection.")); 53 53 } … … 57 57 58 58 public override IOperation Apply() { 59 I Classifiertarget = TargetMatchParameter.ActualValue;59 IAction target = TargetMatchParameter.ActualValue; 60 60 IClassifier match = MatchParameter.ActualValue; 61 61 MatchActionParameter.ActualValue = new BoolValue(match.MatchAction(target)); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Operator/MatchConditionOperator.cs
r9110 r9194 34 34 get { return (ILookupParameter<BoolValue>)Parameters["MatchCondition"]; } 35 35 } 36 public ILookupParameter<I Classifier> TargetMatchParameter {37 get { return (ILookupParameter<I Classifier>)Parameters["TargetMatchParameter"]; }36 public ILookupParameter<IInput> TargetMatchParameter { 37 get { return (ILookupParameter<IInput>)Parameters["TargetMatchParameter"]; } 38 38 } 39 39 public ILookupParameter<IClassifier> MatchParameter { … … 49 49 : base() { 50 50 Parameters.Add(new LookupParameter<BoolValue>("MatchCondition", "True if the condition matches.")); 51 Parameters.Add(new ValueLookupParameter<I Classifier>("TargetMatchParameter", "Target that has to be matched by the match parameter."));51 Parameters.Add(new ValueLookupParameter<IInput>("TargetMatchParameter", "Target that has to be matched by the match parameter.")); 52 52 Parameters.Add(new ValueLookupParameter<IClassifier>("MatchParameter", "The matching encoding contained in each sub-scope which is used for selection.")); 53 53 } … … 57 57 58 58 public override IOperation Apply() { 59 I Classifiertarget = TargetMatchParameter.ActualValue;59 IInput target = TargetMatchParameter.ActualValue; 60 60 IClassifier match = MatchParameter.ActualValue; 61 MatchConditionParameter.ActualValue = new BoolValue(match.Match Condition(target));61 MatchConditionParameter.ActualValue = new BoolValue(match.MatchInput(target)); 62 62 return base.Apply(); 63 63 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Operator/PredictionArrayCalculator.cs
r9089 r9194 33 33 public class PredictionArrayCalculator : SingleSuccessorOperator { 34 34 35 public ILookupParameter<IClassifierComparer> ClassifierComparerParameter { 36 get { return (ILookupParameter<IClassifierComparer>)Parameters["ClassifierComparer"]; } 37 } 35 38 public ILookupParameter<ItemArray<DoubleValue>> FitnessParameter { 36 39 get { return (ILookupParameter<ItemArray<DoubleValue>>)Parameters["Fitness"]; } … … 39 42 get { return (ILookupParameter<ItemArray<DoubleValue>>)Parameters["Prediction"]; } 40 43 } 41 public IValueParameter<IItemDictionary<I Classifier, DoubleValue>> PredictionArrayParameter {42 get { return (IValueParameter<IItemDictionary<I Classifier, DoubleValue>>)Parameters["PredictionArray"]; }44 public IValueParameter<IItemDictionary<IAction, DoubleValue>> PredictionArrayParameter { 45 get { return (IValueParameter<IItemDictionary<IAction, DoubleValue>>)Parameters["PredictionArray"]; } 43 46 } 44 47 public ILookupParameter<ItemArray<IClassifier>> MatchParameter { … … 53 56 public PredictionArrayCalculator() 54 57 : base() { 58 Parameters.Add(new LookupParameter<IClassifierComparer>("ClassifierComparer")); 55 59 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Fitness")); 56 60 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Prediction")); 57 Parameters.Add(new ValueLookupParameter<IItemDictionary<I Classifier, DoubleValue>>("PredictionArray"));61 Parameters.Add(new ValueLookupParameter<IItemDictionary<IAction, DoubleValue>>("PredictionArray")); 58 62 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope from which sub-scopes should be selected.")); 59 63 Parameters.Add(new ScopeTreeLookupParameter<IClassifier>("MatchParameter", "The matching encoding contained in each sub-scope which is used for selection.")); … … 64 68 65 69 public sealed override IOperation Apply() { 66 IItemDictionary<I Classifier, DoubleValue> predictionArray = new ItemDictionary<IClassifier, DoubleValue>();67 IDictionary<I Classifier, double> fitnessSumPerAction = new Dictionary<IClassifier, double>();70 IItemDictionary<IAction, DoubleValue> predictionArray = new ItemDictionary<IAction, DoubleValue>(ClassifierComparerParameter.ActualValue); 71 IDictionary<IAction, double> fitnessSumPerAction = new Dictionary<IAction, double>(ClassifierComparerParameter.ActualValue); 68 72 ItemArray<DoubleValue> fitnesses = FitnessParameter.ActualValue; 69 73 ItemArray<DoubleValue> predictions = PredictionParameter.ActualValue; -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Reinforcement/ActionExecuter.cs
r9175 r9194 33 33 34 34 #region parameter 35 public IValueLookupParameter<I Classifier> SelectedActionParameter {36 get { return (IValueLookupParameter<I Classifier>)Parameters["SelectedAction"]; }35 public IValueLookupParameter<IAction> SelectedActionParameter { 36 get { return (IValueLookupParameter<IAction>)Parameters["SelectedAction"]; } 37 37 } 38 public IValueLookupParameter<I Classifier> CurrentClassifierToMatchParameter {39 get { return (IValueLookupParameter<I Classifier>)Parameters["CurrentClassifierToMatch"]; }38 public IValueLookupParameter<IAction> CurrentActionToMatchParameter { 39 get { return (IValueLookupParameter<IAction>)Parameters["CurrentActionToMatch"]; } 40 40 } 41 41 public IValueLookupParameter<DoubleValue> CurrentPayoffParameter { … … 61 61 public ActionExecuter() 62 62 : base() { 63 Parameters.Add(new ValueLookupParameter<I Classifier>("SelectedAction"));64 Parameters.Add(new ValueLookupParameter<I Classifier>("CurrentClassifierToMatch"));63 Parameters.Add(new ValueLookupParameter<IAction>("SelectedAction")); 64 Parameters.Add(new ValueLookupParameter<IAction>("CurrentActionToMatch")); 65 65 Parameters.Add(new ValueLookupParameter<DoubleValue>("CurrentPayoff")); 66 66 Parameters.Add(new ValueLookupParameter<DoubleValue>("NegativeReward")); … … 69 69 70 70 public override IOperation Apply() { 71 if (SelectedActionParameter.ActualValue.Match Action(CurrentClassifierToMatchParameter.ActualValue)) {71 if (SelectedActionParameter.ActualValue.Match(CurrentActionToMatchParameter.ActualValue)) { 72 72 CurrentPayoffParameter.ActualValue = PositiveRewardParameter.ActualValue; 73 73 } else { -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Reinforcement/ClassifierFetcher.cs
r9161 r9194 33 33 [StorableClass] 34 34 public class ClassifierFetcher : SingleSuccessorOperator, IClassifierFetcher { 35 35 36 #region parameters 36 public IValueLookupParameter<IClassifier> CurrentClassifierToMatchParameter { 37 get { return (IValueLookupParameter<IClassifier>)Parameters["CurrentClassifierToMatch"]; } 37 public IValueLookupParameter<IInput> CurrentInputToMatchParameter { 38 get { return (IValueLookupParameter<IInput>)Parameters["CurrentConditionToMatch"]; } 39 } 40 public IValueLookupParameter<IAction> CurrentActionToMatchParameter { 41 get { return (IValueLookupParameter<IAction>)Parameters["CurrentActionToMatch"]; } 38 42 } 39 43 public ILookupParameter<IConditionActionProblemData> ProblemDataParameter { … … 56 60 public ClassifierFetcher() 57 61 : base() { 58 Parameters.Add(new ValueLookupParameter<IClassifier>("CurrentClassifierToMatch")); 62 Parameters.Add(new ValueLookupParameter<IInput>("CurrentConditionToMatch")); 63 Parameters.Add(new ValueLookupParameter<IAction>("CurrentActionToMatch")); 59 64 Parameters.Add(new LookupParameter<IConditionActionProblemData>("ProblemData")); 60 65 Parameters.Add(new LookupParameter<IntValue>("Iteration")); … … 68 73 var trainingIndices = ProblemData.TrainingIndices.ToList(); 69 74 int index = IterationParameter.ActualValue.Value % trainingIndices.Count; 70 CurrentClassifierToMatchParameter.ActualValue = ProblemDataParameter.ActualValue.FetchClassifier(trainingIndices[index]); 75 CurrentInputToMatchParameter.ActualValue = ProblemDataParameter.ActualValue.FetchInput(trainingIndices[index]); 76 CurrentActionToMatchParameter.ActualValue = ProblemDataParameter.ActualValue.FetchAction(trainingIndices[index]); 71 77 return base.Apply(); 72 78 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Reinforcement/IActionExecuter.cs
r9089 r9194 27 27 namespace HeuristicLab.Encodings.ConditionActionEncoding { 28 28 public interface IActionExecuter : IOperator, IParameterizedNamedItem, INamedItem, IParameterizedItem, IItem, IContent, IDeepCloneable, ICloneable { 29 IValueLookupParameter<I Classifier> SelectedActionParameter { get; }30 IValueLookupParameter<I Classifier> CurrentClassifierToMatchParameter { get; }29 IValueLookupParameter<IAction> SelectedActionParameter { get; } 30 IValueLookupParameter<IAction> CurrentActionToMatchParameter { get; } 31 31 IValueLookupParameter<DoubleValue> CurrentPayoffParameter { get; } 32 32 ILookupParameter<DoubleValue> NegativeRewardParameter { get; } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Reinforcement/IClassifierFetcher.cs
r9089 r9194 27 27 namespace HeuristicLab.Encodings.ConditionActionEncoding { 28 28 public interface IClassifierFetcher : IOperator, IParameterizedNamedItem, INamedItem, IParameterizedItem, IItem, IContent, IDeepCloneable, ICloneable { 29 IValueLookupParameter<IClassifier> CurrentClassifierToMatchParameter { get; } 29 IValueLookupParameter<IInput> CurrentInputToMatchParameter { get; } 30 IValueLookupParameter<IAction> CurrentActionToMatchParameter { get; } 30 31 ILookupParameter<IConditionActionProblemData> ProblemDataParameter { get; } 31 32 ILookupParameter<IntValue> IterationParameter { get; } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Subsumption/CheckGASubsumptionOperator.cs
r9110 r9194 105 105 for (int i = 0; i < parents.Length; i++) { 106 106 IClassifier curParent = parents[i]; 107 if (curParent.MatchAction(child )) {107 if (curParent.MatchAction(child.Action)) { 108 108 if (CouldSubsume(experiences[i], errors[i])) { 109 109 if (curParent.IsMoreGeneral(child)) { -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/XCSModel.cs
r9161 r9194 34 34 public int ClassifierCount { get { return Count; } } 35 35 36 public IClassifierComparer ClassifierComparer { get; set; } 37 36 38 [StorableConstructor] 37 39 protected XCSModel(bool deserializing) : base(deserializing) { } … … 51 53 } 52 54 53 public IEnumerable<I Classifier> GetAction(IEnumerable<IClassifier> classifiers) {55 public IEnumerable<IAction> GetAction(IEnumerable<IInput> classifiers) { 54 56 foreach (var classifier in classifiers) { 55 57 yield return GetAction(classifier); … … 57 59 } 58 60 59 public I Classifier GetAction(IClassifierclassifier) {61 public IAction GetAction(IInput classifier) { 60 62 var matchedClassifiers = new ItemCollection<XCSClassifier>(); 61 63 foreach (var xcsClassifier in this) { 62 if (xcsClassifier.Classifier.Match Condition(classifier)) {64 if (xcsClassifier.Classifier.MatchInput(classifier)) { 63 65 matchedClassifiers.Add(xcsClassifier); 64 66 } … … 67 69 if (matchedClassifiers.Count == 0) { return null; } 68 70 69 IDictionary<I Classifier, double> predictionArray = CreatePredictionArray(matchedClassifiers);71 IDictionary<IAction, double> predictionArray = CreatePredictionArray(matchedClassifiers); 70 72 return predictionArray.OrderByDescending(x => x.Value).First().Key; 71 73 } 72 74 73 private IDictionary<I Classifier, double> CreatePredictionArray(ItemCollection<XCSClassifier> matchedClassifiers) {74 var predictionArray = new Dictionary<I Classifier, double>();75 var fitnessSumPerAction = new Dictionary<I Classifier, double>();75 private IDictionary<IAction, double> CreatePredictionArray(ItemCollection<XCSClassifier> matchedClassifiers) { 76 var predictionArray = new Dictionary<IAction, double>(ClassifierComparer); 77 var fitnessSumPerAction = new Dictionary<IAction, double>(ClassifierComparer); 76 78 77 79 foreach (var xcsClassifier in matchedClassifiers) { … … 86 88 } 87 89 88 var actions = new List<I Classifier>(predictionArray.Keys);90 var actions = new List<IAction>(predictionArray.Keys); 89 91 foreach (var action in actions) { 90 92 if (fitnessSumPerAction[action] != 0) { -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/XCSSolution.cs
r9175 r9194 104 104 105 105 private void RecalculateResults() { 106 var originalTrainingClassifer = ProblemData.FetchClassifier(ProblemData.TrainingIndices); 107 var originalTestClassifer = ProblemData.FetchClassifier(ProblemData.TestIndices); 108 var estimatedTrainingClassifier = Model.GetAction(originalTrainingClassifer); 109 var estimatedTestClassifier = Model.GetAction(originalTestClassifer); 110 111 TrainingAccuracy = CalculateAccuracy(originalTrainingClassifer, estimatedTrainingClassifier); 112 TestAccuracy = CalculateAccuracy(originalTestClassifer, estimatedTestClassifier); 113 } 114 115 private double CalculateAccuracy(IEnumerable<IClassifier> original, IEnumerable<IClassifier> estimated) { 106 var originalTrainingCondition = ProblemData.FetchInput(ProblemData.TrainingIndices); 107 var originalTestCondition = ProblemData.FetchInput(ProblemData.TestIndices); 108 var estimatedTrainingClassifier = Model.GetAction(originalTrainingCondition); 109 var estimatedTestClassifier = Model.GetAction(originalTestCondition); 110 111 var originalTrainingAction = ProblemData.FetchAction(ProblemData.TrainingIndices); 112 var originalTestAction = ProblemData.FetchAction(ProblemData.TestIndices); 113 114 TrainingAccuracy = CalculateAccuracy(originalTrainingAction, estimatedTrainingClassifier); 115 TestAccuracy = CalculateAccuracy(originalTestAction, estimatedTestClassifier); 116 } 117 118 private double CalculateAccuracy(IEnumerable<IAction> original, IEnumerable<IAction> estimated) { 116 119 double correctClassified = 0; 117 120 … … 121 124 122 125 while (originalEnumerator.MoveNext() && estimatedActionEnumerator.MoveNext()) { 123 if (originalEnumerator.Current.Match Action(estimatedActionEnumerator.Current)) {126 if (originalEnumerator.Current.Match(estimatedActionEnumerator.Current)) { 124 127 correctClassified++; 125 128 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/HeuristicLab.Problems.ConditionActionClassification-3.3.csproj
r9160 r9194 44 44 <Reference Include="HeuristicLab.Common-3.3"> 45 45 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath> 46 <Private>False</Private>47 </Reference>48 <Reference Include="HeuristicLab.Core-3.3">49 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>50 46 <Private>False</Private> 51 47 </Reference> … … 100 96 </ItemGroup> 101 97 <ItemGroup> 98 <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj"> 99 <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project> 100 <Name>HeuristicLab.Core-3.3</Name> 101 </ProjectReference> 102 102 <ProjectReference Include="..\..\HeuristicLab.Encodings.CombinedIntegerVectorEncoding\3.3\HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3.csproj"> 103 103 <Project>{CE7163C5-BFFE-45F0-9BD0-E10EF24E8BD2}</Project> -
branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblem.cs
r9175 r9194 69 69 get { return (IFixedValueParameter<DoubleValue>)Parameters["InitialFitness"]; } 70 70 } 71 public IFixedValueParameter<ItemSet<I Classifier>> PossibleActionsParameter {72 get { return (IFixedValueParameter<ItemSet<I Classifier>>)Parameters["PossibleActions"]; }71 public IFixedValueParameter<ItemSet<IAction>> PossibleActionsParameter { 72 get { return (IFixedValueParameter<ItemSet<IAction>>)Parameters["PossibleActions"]; } 73 73 } 74 74 public IFixedValueParameter<ItemSet<CombinedIntegerVector>> PossibleActionsConcreteClassParameter { … … 77 77 public IFixedValueParameter<IntValue> ThetaMinimalNumberOfActionsParameter { 78 78 get { return (IFixedValueParameter<IntValue>)Parameters["ThetaMinimalNumberOfActions"]; } 79 } 80 public IFixedValueParameter<HeuristicLab.Encodings.CombinedIntegerVectorEncoding.CombinedIntegerVector.CombinedIntegerVectorComparer> ClassifierComparerParameter { 81 get { return (IFixedValueParameter<HeuristicLab.Encodings.CombinedIntegerVectorEncoding.CombinedIntegerVector.CombinedIntegerVectorComparer>)Parameters["ClassifierComparer"]; } 79 82 } 80 83 #endregion … … 108 111 // get { return PossibleActions; } 109 112 //} 110 public ItemSet<I Classifier> PossibleActions {113 public ItemSet<IAction> PossibleActions { 111 114 get { return PossibleActionsParameter.Value; } 112 115 } … … 148 151 IParameter IConditionActionProblem.CoveringSolutionCreatorParameter { 149 152 get { return CoveringSolutionCreatorParameter; } 153 } 154 public IClassifierComparer ClassifierComparer { 155 get { return ClassifierComparerParameter.Value; } 156 } 157 IParameter IConditionActionProblem.ClassifierComparerParameter { 158 get { return ClassifierComparerParameter; } 150 159 } 151 160 #endregion … … 177 186 Parameters.Add(new ValueParameter<IActionExecuter>(ActionExecuterParameterName, "", new ActionExecuter())); 178 187 Parameters.Add(new ValueParameter<ClassifierFetcher>(ClassifierFetcherParameterName, "", new ClassifierFetcher())); 179 Parameters.Add(new FixedValueParameter<ItemSet<IClassifier>>("PossibleActions")); 180 Parameters.Add(new FixedValueParameter<ItemSet<CombinedIntegerVector>>("PossibleActionsConcreteClass")); 188 Parameters.Add(new FixedValueParameter<HeuristicLab.Encodings.CombinedIntegerVectorEncoding.CombinedIntegerVector.CombinedIntegerVectorComparer>("ClassifierComparer", new HeuristicLab.Encodings.CombinedIntegerVectorEncoding.CombinedIntegerVector.CombinedIntegerVectorComparer())); 189 Parameters.Add(new FixedValueParameter<ItemSet<IAction>>("PossibleActions", new ItemSet<IAction>(ClassifierComparer))); 190 Parameters.Add(new FixedValueParameter<ItemSet<CombinedIntegerVector>>("PossibleActionsConcreteClass", new ItemSet<CombinedIntegerVector>(ClassifierComparer))); 181 191 Parameters.Add(new FixedValueParameter<IntValue>("ThetaMinimalNumberOfActions", "Minimal number of actions, which have to be present in the match set, or else covering will occure.", new IntValue(1))); 182 192 … … 191 201 192 202 coveringSolutionCreator.ChangeSymbolProbabilityParameter.ActualName = ChangeSymbolProbabilityInCoveringParameter.Name; 193 coveringSolutionCreator.Cover ClassifierParameter.ActualName = ClassifierFetcher.CurrentClassifierToMatchParameter.ActualName;203 coveringSolutionCreator.CoverInputParameter.ActualName = ClassifierFetcher.CurrentInputToMatchParameter.ActualName; 194 204 coveringSolutionCreator.CreatedClassifierParameter.ActualName = "CombinedIntegerVector"; 195 205 196 206 ClassifierFetcher.ProblemDataParameter.ActualName = ProblemDataParameter.Name; 197 207 198 ActionExecuter.Current ClassifierToMatchParameter.ActualName = ClassifierFetcher.CurrentClassifierToMatchParameter.ActualName;208 ActionExecuter.CurrentActionToMatchParameter.ActualName = ClassifierFetcher.CurrentActionToMatchParameter.ActualName; 199 209 ActionExecuter.NegativeRewardParameter.ActualName = NegativeRewardParameter.Name; 200 210 ActionExecuter.PositiveRewardParameter.ActualName = PositiveRewardParameter.Name; … … 241 251 xcsAnalyzer.ProblemDataParameter.ActualName = ProblemDataParameter.Name; 242 252 xcsAnalyzer.ResultsParameter.ActualName = "Results"; 253 xcsAnalyzer.ClassifierComparerParameter.ActualName = ClassifierComparerParameter.Name; 243 254 } 244 255 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblemData.cs
r9167 r9194 119 119 #endregion 120 120 121 private IDictionary<int, IClassifier> fetchClassifiersCache = new Dictionary<int, IClassifier>();122 123 124 121 [StorableConstructor] 125 122 protected ConditionActionClassificationProblemData(bool deserializing) : base(deserializing) { } … … 201 198 } 202 199 203 public IEnumerable<I Classifier> FetchClassifier(IEnumerable<int> rows) {200 public IEnumerable<IInput> FetchInput(IEnumerable<int> rows) { 204 201 foreach (var row in rows) { 205 yield return FetchClassifier(row); 206 } 207 } 208 209 public IClassifier FetchClassifier(int rowNumber) { 202 yield return FetchInput(row); 203 } 204 } 205 public IInput FetchInput(int rowNumber) { 206 return FetchClassifier(rowNumber).Condition as IInput; 207 } 208 public IEnumerable<IAction> FetchAction(IEnumerable<int> rows) { 209 foreach (var row in rows) { 210 yield return FetchAction(row); 211 } 212 } 213 public IAction FetchAction(int rowNumber) { 214 return FetchClassifier(rowNumber).Action; 215 } 216 #region fetchHelper 217 private IDictionary<int, IClassifier> fetchClassifiersCache = new Dictionary<int, IClassifier>(); 218 219 private IClassifier FetchClassifier(int rowNumber) { 210 220 if (!fetchClassifiersCache.ContainsKey(rowNumber)) { 211 221 int[] elements = new int[Length.Value]; … … 231 241 return fetchClassifiersCache[rowNumber]; 232 242 } 243 #endregion 233 244 } 234 245 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.Instances.ConditionActionClassification/3.3/HeuristicLab.Problems.Instances.ConditionActionClassification.csproj
r9160 r9194 39 39 <ItemGroup> 40 40 <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 41 <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />42 41 <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 43 42 <Reference Include="HeuristicLab.PluginInfrastructure-3.3"> … … 67 66 </ItemGroup> 68 67 <ItemGroup> 68 <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj"> 69 <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project> 70 <Name>HeuristicLab.Core-3.3</Name> 71 </ProjectReference> 69 72 <ProjectReference Include="..\..\HeuristicLab.Encodings.ConditionActionEncoding\3.3\HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj"> 70 73 <Project>{422FB262-0845-4969-8D16-12F057AA90B1}</Project> -
branches/LearningClassifierSystems/HeuristicLab.Problems.XCS.Views/3.3/HeuristicLab.Problems.XCS.Views-3.3.csproj
r9154 r9194 41 41 <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 42 42 <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 43 <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />44 43 <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 45 44 <Reference Include="HeuristicLab.MainForm-3.3"> … … 78 77 </ItemGroup> 79 78 <ItemGroup> 79 <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj"> 80 <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project> 81 <Name>HeuristicLab.Core-3.3</Name> 82 </ProjectReference> 80 83 <ProjectReference Include="..\..\HeuristicLab.Encodings.ConditionActionEncoding\3.3\HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj"> 81 84 <Project>{422FB262-0845-4969-8D16-12F057AA90B1}</Project> -
branches/LearningClassifierSystems/LearningClassifierSystem.sln
r9160 r9194 19 19 EndProject 20 20 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.Instances.ConditionActionClassification", "HeuristicLab.Problems.Instances.ConditionActionClassification\3.3\HeuristicLab.Problems.Instances.ConditionActionClassification.csproj", "{1CC7585E-DD22-41FA-869B-93DE41EA8936}" 21 EndProject 22 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Core-3.3", "HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj", "{C36BD924-A541-4A00-AFA8-41701378DDC5}" 23 EndProject 24 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Encodings.VariableVector-3.3", "HeuristicLab.Encodings.VariableVector\3.3\HeuristicLab.Encodings.VariableVector-3.3.csproj", "{7C116F48-7218-4105-BD6E-EE868E2D4823}" 21 25 EndProject 22 26 Global … … 82 86 {1CC7585E-DD22-41FA-869B-93DE41EA8936}.Release|x64.ActiveCfg = Release|Any CPU 83 87 {1CC7585E-DD22-41FA-869B-93DE41EA8936}.Release|x86.ActiveCfg = Release|Any CPU 88 {C36BD924-A541-4A00-AFA8-41701378DDC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 89 {C36BD924-A541-4A00-AFA8-41701378DDC5}.Debug|Any CPU.Build.0 = Debug|Any CPU 90 {C36BD924-A541-4A00-AFA8-41701378DDC5}.Debug|x64.ActiveCfg = Debug|x64 91 {C36BD924-A541-4A00-AFA8-41701378DDC5}.Debug|x64.Build.0 = Debug|x64 92 {C36BD924-A541-4A00-AFA8-41701378DDC5}.Debug|x86.ActiveCfg = Debug|x86 93 {C36BD924-A541-4A00-AFA8-41701378DDC5}.Debug|x86.Build.0 = Debug|x86 94 {C36BD924-A541-4A00-AFA8-41701378DDC5}.Release|Any CPU.ActiveCfg = Release|Any CPU 95 {C36BD924-A541-4A00-AFA8-41701378DDC5}.Release|Any CPU.Build.0 = Release|Any CPU 96 {C36BD924-A541-4A00-AFA8-41701378DDC5}.Release|x64.ActiveCfg = Release|x64 97 {C36BD924-A541-4A00-AFA8-41701378DDC5}.Release|x64.Build.0 = Release|x64 98 {C36BD924-A541-4A00-AFA8-41701378DDC5}.Release|x86.ActiveCfg = Release|x86 99 {C36BD924-A541-4A00-AFA8-41701378DDC5}.Release|x86.Build.0 = Release|x86 100 {7C116F48-7218-4105-BD6E-EE868E2D4823}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 101 {7C116F48-7218-4105-BD6E-EE868E2D4823}.Debug|Any CPU.Build.0 = Debug|Any CPU 102 {7C116F48-7218-4105-BD6E-EE868E2D4823}.Debug|x64.ActiveCfg = Debug|Any CPU 103 {7C116F48-7218-4105-BD6E-EE868E2D4823}.Debug|x86.ActiveCfg = Debug|Any CPU 104 {7C116F48-7218-4105-BD6E-EE868E2D4823}.Release|Any CPU.ActiveCfg = Release|Any CPU 105 {7C116F48-7218-4105-BD6E-EE868E2D4823}.Release|Any CPU.Build.0 = Release|Any CPU 106 {7C116F48-7218-4105-BD6E-EE868E2D4823}.Release|x64.ActiveCfg = Release|Any CPU 107 {7C116F48-7218-4105-BD6E-EE868E2D4823}.Release|x86.ActiveCfg = Release|Any CPU 84 108 EndGlobalSection 85 109 GlobalSection(SolutionProperties) = preSolution
Note: See TracChangeset
for help on using the changeset viewer.