Changeset 9242
- Timestamp:
- 02/25/13 12:37:18 (12 years ago)
- Location:
- branches/LearningClassifierSystems
- Files:
-
- 5 added
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystem.cs
r9204 r9242 123 123 public IConstrainedValueParameter<IManipulator> MutatorParameter { 124 124 get { return (IConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; } 125 } 126 public ValueParameter<IntValue> AnalyzeInIterationParameter { 127 get { return (ValueParameter<IntValue>)Parameters["AnalyzeInIteration"]; } 125 128 } 126 129 #endregion … … 253 256 Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.")); 254 257 Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 258 Parameters.Add(new ValueParameter<IntValue>("AnalyzeInIteration", "", new IntValue(50))); 255 259 #endregion 256 260 … … 275 279 mainLoop.MutatorParameter.ActualName = MutatorParameter.Name; 276 280 mainLoop.CrossoverProbabilityParameter.ActualName = CrossoverProbabilityParameter.Name; 281 mainLoop.AnalyzeInIterationParameter.ActualName = AnalyzeInIterationParameter.Name; 277 282 #endregion 278 283 -
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystemMainLoop.cs
r9226 r9242 69 69 get { return (ValueLookupParameter<IOperator>)Parameters["FinalAnalyzer"]; } 70 70 } 71 public ValueLookupParameter<IntValue> AnalyzeInIterationParameter { 72 get { return (ValueLookupParameter<IntValue>)Parameters["AnalyzeInIteration"]; } 73 } 71 74 #endregion 72 75 … … 114 117 Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation.")); 115 118 Parameters.Add(new ValueLookupParameter<IOperator>("FinalAnalyzer", "The operator used to analyze the last generation.")); 119 Parameters.Add(new ValueLookupParameter<IntValue>("AnalyzeInIteration", "")); 116 120 #endregion 117 121 … … 119 123 VariableCreator variableCreator = new VariableCreator(); 120 124 ResultsCollector resultsCollector = new ResultsCollector(); 125 ModuloOperator moduloOperator = new ModuloOperator(); 126 Comparator analyzerComparator = new Comparator(); 127 ConditionalBranch analyzerConditionalBranch = new ConditionalBranch(); 121 128 Placeholder analyzer = new Placeholder(); 122 129 Placeholder finalAnalyzer = new Placeholder(); … … 183 190 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Iteration")); 184 191 resultsCollector.ResultsParameter.ActualName = "Results"; 192 193 moduloOperator.LeftSideParameter.ActualName = "Iteration"; 194 moduloOperator.RightSideParameter.ActualName = AnalyzeInIterationParameter.ActualName; 195 moduloOperator.ResultParameter.ActualName = "ModuloResult"; 196 197 analyzerComparator.LeftSideParameter.ActualName = "ModuloResult"; 198 analyzerComparator.RightSideParameter.Value = new IntValue(0); 199 analyzerComparator.ResultParameter.ActualName = "DoAnalyzing"; 200 201 analyzerConditionalBranch.ConditionParameter.ActualName = "DoAnalyzing"; 185 202 186 203 analyzer.Name = "Analyzer"; … … 403 420 deletionSelectorAfterGA.Successor = leftReducerAfterGA; 404 421 leftReducerAfterGA.Successor = iterationCounter; 405 iterationCounter.Successor = analyzer; 406 analyzer.Successor = maxIterationsComparator; 422 iterationCounter.Successor = moduloOperator; 423 moduloOperator.Successor = analyzerComparator; 424 analyzerComparator.Successor = analyzerConditionalBranch; 425 analyzerConditionalBranch.Successor = maxIterationsComparator; 426 analyzerConditionalBranch.TrueBranch = analyzer; 407 427 #endregion 408 428 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/CombinedIntegerVectorCreator.cs
r9089 r9242 41 41 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 42 42 } 43 public IValueLookupParameter<I ntValue> LengthParameter {44 get { return (IValueLookupParameter<I ntValue>)Parameters["Length"]; }43 public IValueLookupParameter<ICombinedIntegerVectorClassificationProblemData> ProblemDataParameter { 44 get { return (IValueLookupParameter<ICombinedIntegerVectorClassificationProblemData>)Parameters["ProblemData"]; } 45 45 } 46 public I ValueLookupParameter<IntMatrix> BoundsParameter {47 get { return (I ValueLookupParameter<IntMatrix>)Parameters["Bounds"]; }46 public ILookupParameter<CombinedIntegerVector> CombinedIntegerVectorParameter { 47 get { return (ILookupParameter<CombinedIntegerVector>)Parameters["CombinedIntegerVector"]; } 48 48 } 49 49 50 public IValueLookupParameter<IntValue> ActionPartLengthParameter { 51 get { return (IValueLookupParameter<IntValue>)Parameters["ActionPartLength"]; } 52 } 53 54 public ILookupParameter<CombinedIntegerVector> CombinedIntegerVectorParameter { 55 get { return (ILookupParameter<CombinedIntegerVector>)Parameters["CombinedIntegerVector"]; } 50 protected ICombinedIntegerVectorClassificationProblemData ProblemData { 51 get { return ProblemDataParameter.ActualValue; } 56 52 } 57 53 … … 62 58 : base() { 63 59 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 64 Parameters.Add(new ValueLookupParameter<IntValue>("Length", "The length of the vector.")); 65 Parameters.Add(new ValueLookupParameter<IntMatrix>("Bounds", "The bounds matrix can contain one row for each dimension with three columns specifying minimum (inclusive), maximum (exclusive), and step size. If less rows are given the matrix is cycled.")); 60 Parameters.Add(new ValueLookupParameter<ICombinedIntegerVectorClassificationProblemData>("ProblemData", "")); 66 61 Parameters.Add(new LookupParameter<CombinedIntegerVector>("CombinedIntegerVector", "The vector which should be manipulated.")); 67 Parameters.Add(new ValueLookupParameter<IntValue>("ActionPartLength", "The length of the vector."));68 62 } 69 63 70 64 public sealed override IOperation Apply() { 71 CombinedIntegerVectorParameter.ActualValue = Create(RandomParameter.ActualValue, LengthParameter.ActualValue, BoundsParameter.ActualValue, ActionPartLengthParameter.ActualValue);65 CombinedIntegerVectorParameter.ActualValue = Create(RandomParameter.ActualValue, ProblemData.LengthParameter.Value, ProblemData.BoundsParameter.Value, ProblemData.ActionLengthParameter.Value); 72 66 return base.Apply(); 73 67 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Covering/CombinedIntegerVectorCoveringCreator.cs
r9204 r9242 43 43 44 44 protected override IClassifier CreateCoveredClassifier(IInput input, IAction action, IRandom random, double changeSymbolProbability) { 45 CombinedIntegerVector newCondition = (CombinedIntegerVector) input.Clone();45 CombinedIntegerVector newCondition = (CombinedIntegerVector)((CombinedIntegerVector)input.Clone()).Condition; 46 46 47 47 CombinedIntegerVector condition = (CombinedIntegerVector)input; -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3.csproj
r9228 r9242 128 128 <Compile Include="Creators\UniformRandomCombinedIntegerVectorCreator.cs" /> 129 129 <Compile Include="Crossovers\SinglePointCrossover.cs" /> 130 <Compile Include="Interfaces\ICombinedIntegerVectorClassificationProblem.cs" /> 131 <Compile Include="Interfaces\ICombinedIntegerVectorClassificationProblemData.cs" /> 130 132 <Compile Include="Interfaces\ICombinedIntegerVectorManipulator.cs" /> 131 133 <Compile Include="Interfaces\ICombinedIntegerVectorCrossover.cs" /> 132 <Compile Include="Interfaces\IBoundedCombinedIntegerVectorOperator.cs" />133 134 <Compile Include="Interfaces\ICombinedIntegerVectorCreator.cs" /> 134 135 <Compile Include="Interfaces\ICombinedIntegerVectorOperator.cs" /> -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Interfaces/ICombinedIntegerVectorCreator.cs
r9089 r9242 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Data;26 25 using HeuristicLab.Optimization; 27 26 28 27 namespace HeuristicLab.Encodings.CombinedIntegerVectorEncoding { 29 public interface ICombinedIntegerVectorCreator : ISolutionCreator, IBoundedCombinedIntegerVectorOperator, ICombinedIntegerVectorOperator, IOperator, IParameterizedNamedItem, INamedItem, IParameterizedItem, IItem, IContent, IDeepCloneable, ICloneable { 30 IValueLookupParameter<IntValue> LengthParameter { get; } 31 IValueLookupParameter<IntValue> ActionPartLengthParameter { get; } 28 public interface ICombinedIntegerVectorCreator : ISolutionCreator, ICombinedIntegerVectorOperator, IOperator, IParameterizedNamedItem, INamedItem, IParameterizedItem, IItem, IContent, IDeepCloneable, ICloneable { 29 IValueLookupParameter<ICombinedIntegerVectorClassificationProblemData> ProblemDataParameter { get; } 32 30 ILookupParameter<CombinedIntegerVector> CombinedIntegerVectorParameter { get; } 33 31 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj
r9228 r9242 118 118 <Compile Include="GA\XCSCheckIfGAShouldBeApplied.cs" /> 119 119 <Compile Include="Operator\CountNumberOfUniqueActions.cs" /> 120 <Compile Include="Operator\ModuloOperator.cs" /> 120 121 <Compile Include="Operator\PredictionArrayCalculator.cs" /> 121 122 <Compile Include="Operator\MatchActionOperator.cs" /> -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3
- Property svn:ignore
-
old new 1 1 obj 2 Plugin.cs
-
- Property svn:ignore
-
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Covering/VariableVectorCoveringCreator.cs
r9226 r9242 34 34 public class VariableVectorCoveringCreator : CoveringSolutionCreator, IVariableVectorCoveringCreator { 35 35 36 public IValueLookupParameter<VariableVector> SampleVariableVectorParameter { 37 get { return (IValueLookupParameter<VariableVector>)Parameters["SampleVariableVector"]; } 36 public IValueLookupParameter<IVariableVectorClassificationProblemData> ProblemDataParameter { 37 get { return (IValueLookupParameter<IVariableVectorClassificationProblemData>)Parameters["ProblemData"]; } 38 } 39 40 private IVariableVectorClassificationProblemData ProblemData { 41 get { return ProblemDataParameter.ActualValue; } 38 42 } 39 43 … … 45 49 public VariableVectorCoveringCreator() 46 50 : base() { 47 Parameters.Add(new ValueLookupParameter< VariableVector>("SampleVariableVector"));51 Parameters.Add(new ValueLookupParameter<IVariableVectorClassificationProblemData>("ProblemData")); 48 52 } 49 53 public override IDeepCloneable Clone(Cloner cloner) { … … 55 59 var actionCast = action as VariableVectorAction; 56 60 57 VariableVectorCondition sampleVariableVectorCondition = SampleVariableVectorParameter.ActualValue.Condition;61 VariableVectorCondition sampleVariableVectorCondition = ProblemData.SampleVariableVectorParameter.Value.Condition; 58 62 IEnumerable<IVariable> newCondition = CoverInput(inputCast, sampleVariableVectorCondition, random, changeSymbolProbability); 59 63 60 return new VariableVector(newCondition, actionCast.Va lues);64 return new VariableVector(newCondition, actionCast.VariableDictionary.Values); 61 65 } 62 66 63 67 private IEnumerable<IVariable> CoverInput(VariableVectorInput input, VariableVectorCondition sample, IRandom random, double changeSymbolProbability) { 64 varconditionVariables = new List<IVariable>();65 if (!sample. Keys.All(x => input.ContainsKey(x))) {68 List<IVariable> conditionVariables = new List<IVariable>(); 69 if (!sample.VariableDictionary.Keys.All(x => input.InputDictionary.ContainsKey(x))) { 66 70 throw new ArgumentException("Input does not contain all variable names from sample"); 67 71 } 68 foreach (var keyValuePair in sample ) {72 foreach (var keyValuePair in sample.VariableDictionary) { 69 73 IVariable variable = keyValuePair.Value.GetEmptyCopy(); 70 variable.Cover(random, input [keyValuePair.Key], changeSymbolProbability);74 variable.Cover(random, input.InputDictionary[keyValuePair.Key], changeSymbolProbability); 71 75 conditionVariables.Add(variable); 72 76 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Crossover/SinglePointCrossover.cs
r9226 r9242 54 54 55 55 if (parent1.Count != parent2.Count && parent1.VirtualLength != parent2.VirtualLength 56 && parent1Condition. Count != parent2Condition.Count && parent1Condition.VirtualLength != parent2Condition.VirtualLength57 && parent1Action. Count != parent2Action.Count && parent1Action.VirtualLength != parent2Action.VirtualLength)56 && parent1Condition.VariableDictionary.Count != parent2Condition.VariableDictionary.Count && parent1Condition.VirtualLength != parent2Condition.VirtualLength 57 && parent1Action.VariableDictionary.Count != parent2Action.VariableDictionary.Count && parent1Action.VirtualLength != parent2Action.VirtualLength) 58 58 throw new ArgumentException("SinglePointCrossover: The parents are of different length."); 59 59 60 60 int conditionLength = parent1Condition.VirtualLength; 61 61 int breakPoint = random.Next(1, conditionLength); 62 IList<IVariable> newCondition = new List<IVariable>(parent1Condition. Count);62 IList<IVariable> newCondition = new List<IVariable>(parent1Condition.VariableDictionary.Count); 63 63 64 64 var keyEnumerator = parent1Condition.Order.GetEnumerator(); 65 65 66 66 int index = 0; 67 IVariable curVariable ;67 IVariable curVariable = null; 68 68 while (index < breakPoint) { 69 keyEnumerator.MoveNext();70 curVariable = parent1Condition [keyEnumerator.Current];71 if ( curVariable.VirtualLength == 1 || index + curVariable.VirtualLength - 1 <breakPoint) {69 if (!keyEnumerator.MoveNext()) { throw new IndexOutOfRangeException("Enumerator has no next element!"); } 70 curVariable = parent1Condition.VariableDictionary[keyEnumerator.Current]; 71 if (index + curVariable.VirtualLength <= breakPoint) { 72 72 newCondition.Add(curVariable.GetSetCopy()); 73 index += curVariable.VirtualLength;74 73 } 74 index += curVariable.VirtualLength; 75 75 } 76 76 77 77 // breakpoint is in between a variable 78 78 if (index != breakPoint) { 79 newCondition.Add(parent1Condition [keyEnumerator.Current].CrossParentsAtPosition(parent2Condition[keyEnumerator.Current], breakPoint - index - 1));79 newCondition.Add(parent1Condition.VariableDictionary[keyEnumerator.Current].CrossParentsAtPosition(parent2Condition.VariableDictionary[keyEnumerator.Current], breakPoint - (index - curVariable.VirtualLength))); 80 80 } 81 81 82 82 while (index < conditionLength) { 83 83 keyEnumerator.MoveNext(); 84 curVariable = parent2Condition [keyEnumerator.Current];84 curVariable = parent2Condition.VariableDictionary[keyEnumerator.Current]; 85 85 newCondition.Add(curVariable.GetSetCopy()); 86 86 index += curVariable.VirtualLength; 87 87 } 88 88 89 var action = random.Next(2) == 1 ? parent1Action.Va lues.Select(x => x.GetSetCopy()) : parent2Action.Values.Select(x => x.GetSetCopy());89 var action = random.Next(2) == 1 ? parent1Action.VariableDictionary.Values.Select(x => x.GetSetCopy()) : parent2Action.VariableDictionary.Values.Select(x => x.GetSetCopy()); 90 90 91 91 return new VariableVector(newCondition, action); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/HeuristicLab.Encodings.VariableVector-3.3.csproj
r9228 r9242 85 85 <Compile Include="Covering\VariableVectorCoveringCreator.cs" /> 86 86 <Compile Include="Crossover\SinglePointCrossover.cs" /> 87 <Compile Include="Interfaces\IVariableVectorClassificationProblem.cs" /> 88 <Compile Include="Interfaces\IVariableVectorClassificationProblemData.cs" /> 87 89 <Compile Include="Interfaces\IVariableVectorCoveringCreator.cs" /> 88 90 <Compile Include="Interfaces\IVariableVectorCrossover.cs" /> -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Interfaces/IVariableVectorCoveringCreator.cs
r9204 r9242 25 25 namespace HeuristicLab.Encodings.VariableVector { 26 26 public interface IVariableVectorCoveringCreator : ICoveringSolutionCreator, IVariableVectorOperator { 27 IValueLookupParameter< VariableVector> SampleVariableVectorParameter { get; }27 IValueLookupParameter<IVariableVectorClassificationProblemData> ProblemDataParameter { get; } 28 28 } 29 29 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Interfaces/IVariableVectorCreator.cs
r9194 r9242 21 21 22 22 using HeuristicLab.Core; 23 using HeuristicLab.Data;24 23 using HeuristicLab.Optimization; 25 24 26 25 namespace HeuristicLab.Encodings.VariableVector { 27 26 public interface IVariableVectorCreator : ISolutionCreator, IVariableVectorOperator { 28 IValueLookupParameter<PercentValue> SpreadPercentageParameter { get; } 29 IValueLookupParameter<VariableVector> SampleVariableVectorParameter { get; } 27 IValueLookupParameter<IVariableVectorClassificationProblemData> ProblemDataParameter { get; } 30 28 ILookupParameter<VariableVector> VariableVectorParameter { get; } 31 32 29 } 33 30 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Manipulator/UniformActionManipulator.cs
r9204 r9242 60 60 int actionIndex = random.Next(otherActions.Count()); 61 61 VariableVectorAction newAction = otherActions.ElementAt(actionIndex); 62 return new VariableVector(child.Condition.Va lues.Select(x => x.GetSetCopy()), newAction.Values.Select(x => x.GetSetCopy()));62 return new VariableVector(child.Condition.VariableDictionary.Values.Select(x => x.GetSetCopy()), newAction.VariableDictionary.Values.Select(x => x.GetSetCopy())); 63 63 } 64 64 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Manipulator/UniformOnePositionInConditionManipulator.cs
r9226 r9242 57 57 int count = 0; 58 58 keyEnumerator.MoveNext(); 59 while (count < condition.VirtualLength && count < index && count + condition [keyEnumerator.Current].VirtualLength <= index) {60 count += condition [keyEnumerator.Current].VirtualLength;59 while (count < condition.VirtualLength && count < index && count + condition.VariableDictionary[keyEnumerator.Current].VirtualLength <= index) { 60 count += condition.VariableDictionary[keyEnumerator.Current].VirtualLength; 61 61 keyEnumerator.MoveNext(); 62 62 } 63 condition [keyEnumerator.Current].Manipulate(random, input[keyEnumerator.Current], index - count);63 condition.VariableDictionary[keyEnumerator.Current].Manipulate(random, input.InputDictionary[keyEnumerator.Current], index - count); 64 64 return child; 65 65 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Properties
-
Property
svn:ignore
set to
AssemblyInfo.cs
-
Property
svn:ignore
set to
-
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/DoubleVariable.cs
r9226 r9242 66 66 min = original.min; 67 67 max = original.max; 68 currentSpread = original.currentSpread; 69 currentCenter = original.currentCenter; 68 70 } 69 71 public DoubleVariable() : base() { } … … 89 91 90 92 public override string ToString() { 91 return (currentCenter - current Center) + " - " + (currentCenter + currentSpread);93 return (currentCenter - currentSpread) + " - " + (currentCenter + currentSpread); 92 94 } 93 95 … … 97 99 98 100 public override bool Match(double target) { 99 return currentCenter - currentSpread < target && target <currentCenter + currentSpread;101 return currentCenter - currentSpread <= target && target <= currentCenter + currentSpread; 100 102 } 101 103 … … 128 130 var targetCast = target as DoubleVariable; 129 131 if (targetCast == null) { return false; } 130 if (variableName != targetCast.variableName || currentCenter != targetCast.currentCenter131 || currentSpread != targetCast.currentSpread || max != targetCast.max132 || min != targetCast.min) { return false; }132 if (variableName != targetCast.variableName || currentCenter.IsAlmost(targetCast.currentCenter) 133 || currentSpread.IsAlmost(targetCast.currentSpread) || max.IsAlmost(targetCast.max) 134 || min.IsAlmost(targetCast.min)) { return false; } 133 135 134 136 return true; … … 149 151 } 150 152 151 public new DoubleVariable CrossParentsAtPosition(IVariable parent2, int pos) {152 varparent2Cast = parent2 as DoubleVariable;153 public override IVariable CrossParentsAtPosition(IVariable parent2, int pos) { 154 DoubleVariable parent2Cast = parent2 as DoubleVariable; 153 155 if (parent2Cast == null) { throw new ArgumentException("Argument is not of the correct type."); } 154 156 if (pos > 1 || pos < 0) { throw new ArgumentOutOfRangeException(); } 155 157 DoubleVariable crossed = (DoubleVariable)this.GetSetCopy(); 156 if (pos == 0) {158 if (pos == 1) { 157 159 crossed.CurrentSpread = parent2Cast.CurrentSpread; 158 160 } … … 180 182 181 183 public override void Cover(IRandom random, string stringValue, double changeSymbolProbability) { 182 Cover (random, stringValue, 50);184 CoverWithSpreadPercentage(random, stringValue, changeSymbolProbability); 183 185 } 184 186 … … 186 188 currentCenter = double.Parse(stringValue); 187 189 double delta = max - min; 188 currentSpread = random.NextDouble() * (delta * (spreadPercentage / 100));190 currentSpread = random.NextDouble() * (delta * spreadPercentage); 189 191 } 190 192 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/IVariable.cs
r9226 r9242 30 30 31 31 IVariable GetEmptyCopy(); 32 //GetSetCopy is used instead of Clone, so that data doesn't have to be duplicated 32 33 IVariable GetSetCopy(); 33 34 -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/IntVariable.cs
r9226 r9242 149 149 } 150 150 151 public new IntVariable CrossParentsAtPosition(IVariable parent2, int pos) {151 public override IVariable CrossParentsAtPosition(IVariable parent2, int pos) { 152 152 var parent2Cast = parent2 as IntVariable; 153 153 if (parent2Cast == null) { throw new ArgumentException("Argument is not of the correct type."); } 154 154 if (pos != 0) { throw new ArgumentOutOfRangeException(); } 155 return (IntVariable) this.GetSetCopy();155 return (IntVariable)parent2.GetSetCopy(); 156 156 } 157 157 -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/StringVariable.cs
r9226 r9242 198 198 } 199 199 200 public new StringVariable CrossParentsAtPosition(IVariable parent2, int pos) {200 public override IVariable CrossParentsAtPosition(IVariable parent2, int pos) { 201 201 var parent2Cast = parent2 as StringVariable; 202 202 if (parent2Cast == null) { throw new ArgumentException("Argument is not of the correct type."); } 203 203 if (pos != 0) { throw new ArgumentOutOfRangeException(); } 204 return (StringVariable) this.GetSetCopy();204 return (StringVariable)parent2.GetSetCopy(); 205 205 } 206 206 -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/Variable.cs
r9226 r9242 68 68 public abstract bool IsGreaterThanOrEquallyGeneral(IVariable target); 69 69 70 public virtual IVariable CrossParentsAtPosition(IVariable parent2, int pos) { throw new NotSupportedException("This method is not supported."); }70 public abstract IVariable CrossParentsAtPosition(IVariable parent2, int pos); 71 71 72 72 public abstract void Manipulate(IRandom random, string stringValue, int pos); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/VariableVector.cs
r9226 r9242 43 43 44 44 public int Count { 45 get { return condition. Count + action.Count; }45 get { return condition.VariableDictionary.Count + action.VariableDictionary.Count; } 46 46 } 47 47 48 48 public int VirtualLength { 49 get { return condition.Va lues.Sum(x => x.VirtualLength) + action.Values.Sum(x => x.VirtualLength); }49 get { return condition.VariableDictionary.Values.Sum(x => x.VirtualLength) + action.VariableDictionary.Values.Sum(x => x.VirtualLength); } 50 50 } 51 51 … … 73 73 74 74 public VariableVector GetEmptyCopy() { 75 return new VariableVector(Condition.Va lues.Select(x => x.GetEmptyCopy()), Action.Values.Select(x => x.GetEmptyCopy()));75 return new VariableVector(Condition.VariableDictionary.Values.Select(x => x.GetEmptyCopy()), Action.VariableDictionary.Values.Select(x => x.GetEmptyCopy())); 76 76 } 77 77 … … 112 112 113 113 public bool IsMoreGeneral(ICondition target) { 114 var targetCast = target as VariableVector ;114 var targetCast = target as VariableVectorCondition; 115 115 if (targetCast == null) { return false; } 116 if (Condition. Keys.Except(targetCast.Condition.Keys).Count() != 0117 || targetCast. Condition.Keys.Except(Condition.Keys).Count() != 0) { return false; }116 if (Condition.VariableDictionary.Keys.Except(targetCast.VariableDictionary.Keys).Count() != 0 117 || targetCast.VariableDictionary.Keys.Except(Condition.VariableDictionary.Keys).Count() != 0) { return false; } 118 118 119 double thisGenerality = Condition.Va lues.Sum(x => x.GetGenerality());120 double targetGenerality = Condition.Values.Sum(x => x.GetGenerality());119 double thisGenerality = Condition.VariableDictionary.Values.Sum(x => x.GetGenerality()); 120 double targetGenerality = targetCast.VariableDictionary.Values.Sum(x => x.GetGenerality()); 121 121 if (thisGenerality <= targetGenerality) { return false; } 122 122 123 foreach (var variables in targetCast. Condition) {124 if (!Condition [variables.Key].IsGreaterThanOrEquallyGeneral(variables.Value)) {123 foreach (var variables in targetCast.VariableDictionary) { 124 if (!Condition.VariableDictionary[variables.Key].IsGreaterThanOrEquallyGeneral(variables.Value)) { 125 125 return false; 126 126 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/VariableVectorAction.cs
r9226 r9242 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 using System.Drawing;25 23 using System.Linq; 26 24 using System.Text; … … 33 31 [StorableClass] 34 32 [Item("VariableVectorAction", "")] 35 public class VariableVectorAction : Dictionary<string, IActionVariable>, IAction {33 public class VariableVectorAction : Item, IAction { 36 34 37 public IOrderedEnumerable<string> Order { get { return this.Keys.OrderBy(x => x); } } 35 [Storable] 36 private Dictionary<string, IActionVariable> variableDictionary; 37 public Dictionary<string, IActionVariable> VariableDictionary { 38 get { return variableDictionary; } 39 protected set { variableDictionary = value; } 40 } 38 41 39 public int VirtualLength { get { return this.Values.Sum(x => x.VirtualLength); } } 42 public IOrderedEnumerable<string> Order { get { return VariableDictionary.Keys.OrderBy(x => x); } } 43 44 public int VirtualLength { get { return VariableDictionary.Values.Sum(x => x.VirtualLength); } } 40 45 41 46 [StorableConstructor] 42 47 protected VariableVectorAction(bool deserializing) { } 43 48 protected VariableVectorAction(VariableVectorAction original, Cloner cloner) { 44 foreach (var item in original) { 45 Add((string)item.Key.Clone(), (IActionVariable)item.Value.Clone()); 49 VariableDictionary = new Dictionary<string, IActionVariable>(original.VariableDictionary.Count); 50 foreach (var item in original.VariableDictionary) { 51 VariableDictionary.Add(item.Key, cloner.Clone(item.Value)); 46 52 } 47 53 } 48 public VariableVectorAction() : base() { } 49 public VariableVectorAction(int capacity) : base(capacity) { } 50 public VariableVectorAction(IDictionary<string, IActionVariable> dictionary) : base(dictionary) { } 51 52 //protected override void OnItemsAdded(IEnumerable<KeyValuePair<string, IActionVariable>> items) { 53 // foreach (var item in items) { 54 // if (!(item.Value is StringVariable || item.Value is IntVariable)) { 55 // throw new ArgumentException("Value has to be of type 'StringVariable' or 'IntVariable'"); 56 // } 57 // } 58 //} 54 public VariableVectorAction() 55 : base() { 56 VariableDictionary = new Dictionary<string, IActionVariable>(); 57 } 58 public VariableVectorAction(int capacity) 59 : base() { 60 VariableDictionary = new Dictionary<string, IActionVariable>(capacity); 61 } 62 public VariableVectorAction(IDictionary<string, IActionVariable> dictionary) 63 : base() { 64 VariableDictionary = new Dictionary<string, IActionVariable>(dictionary); 65 } 66 public override IDeepCloneable Clone(Cloner cloner) { 67 return new VariableVectorAction(this, cloner); 68 } 59 69 60 70 public VariableVectorAction GetEmptyCopy() { 61 VariableVectorAction emptyCopy = new VariableVectorAction(this.Count); 62 foreach (var keyValuePair in this) { 63 emptyCopy.Add(keyValuePair.Key, keyValuePair.Value.GetEmptyCopy()); 64 } 71 VariableVectorAction emptyCopy = new VariableVectorAction(VariableDictionary.Count); 72 emptyCopy.Add(VariableDictionary.Values.Select(x => x.GetEmptyCopy())); 65 73 return emptyCopy; 66 74 } 67 75 68 76 public VariableVectorAction GetSetCopy() { 69 VariableVectorAction setCopy = new VariableVectorAction(this.Count); 70 foreach (var keyValuePair in this) { 71 setCopy.Add(keyValuePair.Key, keyValuePair.Value.GetSetCopy()); 72 } 77 VariableVectorAction setCopy = new VariableVectorAction(VariableDictionary.Count); 78 setCopy.Add(VariableDictionary.Values.Select(x => x.GetSetCopy())); 73 79 return setCopy; 74 80 } … … 78 84 if (targetCast == null) { return false; } 79 85 if (!this.Order.SequenceEqual(targetCast.Order)) { return false; } 80 foreach (var keyValuePair in targetCast ) {81 if (! this[keyValuePair.Key].MatchVariable(keyValuePair.Value)) {86 foreach (var keyValuePair in targetCast.VariableDictionary) { 87 if (!VariableDictionary[keyValuePair.Key].MatchVariable(keyValuePair.Value)) { 82 88 return false; 83 89 } … … 88 94 public void Add(IEnumerable<IActionVariable> action) { 89 95 foreach (var variable in action) { 90 this.Add(variable.VariableName, variable);96 VariableDictionary.Add(variable.VariableName, variable); 91 97 } 92 98 } … … 95 101 StringBuilder sb = new StringBuilder(); 96 102 bool first = true; 97 foreach (var variable in this.Values) {103 foreach (var variable in VariableDictionary.Values) { 98 104 if (first) { 99 105 first = false; … … 107 113 108 114 public void Randomize(IRandom random) { 109 foreach (var variable in this.Values) {115 foreach (var variable in VariableDictionary.Values) { 110 116 variable.Randomize(random); 111 117 } … … 113 119 114 120 public bool Identical(VariableVectorAction target) { 115 if ( this.Order.SequenceEqual(target.Order)) { return false; }116 foreach (var keyValuePair in target ) {117 if (! this[keyValuePair.Key].Identical(keyValuePair.Value)) {121 if (!this.Order.SequenceEqual(target.Order)) { return false; } 122 foreach (var keyValuePair in target.VariableDictionary) { 123 if (!VariableDictionary[keyValuePair.Key].Identical(keyValuePair.Value)) { 118 124 return false; 119 125 } … … 121 127 return true; 122 128 } 123 124 public virtual string ItemName {125 get { return ItemAttribute.GetName(this.GetType()); }126 }127 public virtual string ItemDescription {128 get { return ItemAttribute.GetDescription(this.GetType()); }129 }130 public Version ItemVersion {131 get { return ItemAttribute.GetVersion(this.GetType()); }132 }133 public static Image StaticItemImage {134 get { return HeuristicLab.Common.Resources.VSImageLibrary.Class; }135 }136 public virtual Image ItemImage {137 get { return ItemAttribute.GetImage(this.GetType()); }138 }139 140 public virtual IDeepCloneable Clone(Cloner cloner) {141 return new VariableVectorAction(this, cloner);142 }143 144 public object Clone() {145 return Clone(new Cloner());146 }147 148 public event EventHandler ItemImageChanged;149 protected virtual void OnItemImageChanged() {150 EventHandler handler = ItemImageChanged;151 if (handler != null) handler(this, EventArgs.Empty);152 }153 public event EventHandler ToStringChanged;154 protected virtual void OnToStringChanged() {155 EventHandler handler = ToStringChanged;156 if (handler != null) handler(this, EventArgs.Empty);157 }158 129 } 159 130 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/VariableVectorActionComparer.cs
r9226 r9242 44 44 public bool Equals(VariableVectorAction x, VariableVectorAction y) { 45 45 if (!x.Order.SequenceEqual(y.Order)) return false; 46 foreach (var key in x. Keys) {47 if (!x [key].Identical(y[key])) {46 foreach (var key in x.VariableDictionary.Keys) { 47 if (!x.VariableDictionary[key].Identical(y.VariableDictionary[key])) { 48 48 return false; 49 49 } … … 54 54 public int GetHashCode(VariableVectorAction obj) { 55 55 int result = 1; 56 foreach (var key in obj. Keys) {56 foreach (var key in obj.VariableDictionary.Keys) { 57 57 result = 37 * result + key.GetHashCode(); 58 58 } 59 59 60 foreach (var val in obj.Va lues) {60 foreach (var val in obj.VariableDictionary.Values) { 61 61 result = 37 * result + val.GetHashCode(); 62 62 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/VariableVectorCondition.cs
r9226 r9242 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 using System.Drawing;25 23 using System.Linq; 26 24 using System.Text; … … 33 31 [StorableClass] 34 32 [Item("VariableVectorCondition", "")] 35 public class VariableVectorCondition : Dictionary<string, IVariable>, ICondition {33 public class VariableVectorCondition : Item, ICondition { 36 34 37 public IOrderedEnumerable<string> Order { get { return this.Keys.OrderBy(x => x); } } 35 [Storable] 36 private Dictionary<string, IVariable> variableDictionary; 37 public Dictionary<string, IVariable> VariableDictionary { 38 get { return variableDictionary; } 39 protected set { variableDictionary = value; } 40 } 38 41 39 public int VirtualLength { get { return this.Values.Sum(x => x.VirtualLength); } } 42 public IOrderedEnumerable<string> Order { get { return VariableDictionary.Keys.OrderBy(x => x); } } 43 44 public int VirtualLength { get { return VariableDictionary.Values.Sum(x => x.VirtualLength); } } 40 45 41 46 [StorableConstructor] 42 47 protected VariableVectorCondition(bool deserializing) { } 43 48 protected VariableVectorCondition(VariableVectorCondition original, Cloner cloner) { 44 foreach (var item in original) { 45 Add((string)item.Key.Clone(), (IVariable)item.Value.Clone()); 49 VariableDictionary = new Dictionary<string, IVariable>(original.VariableDictionary.Count); 50 foreach (var item in original.VariableDictionary) { 51 VariableDictionary.Add(item.Key, cloner.Clone(item.Value)); 46 52 } 47 53 } 48 public VariableVectorCondition() : base() { } 49 public VariableVectorCondition(int capacity) : base(capacity) { } 50 public VariableVectorCondition(IDictionary<string, IVariable> dictionary) : base(dictionary) { } 54 public VariableVectorCondition() 55 : base() { 56 VariableDictionary = new Dictionary<string, IVariable>(); 57 } 58 public VariableVectorCondition(int capacity) 59 : base() { 60 VariableDictionary = new Dictionary<string, IVariable>(capacity); 61 } 62 public VariableVectorCondition(IDictionary<string, IVariable> dictionary) 63 : base() { 64 VariableDictionary = new Dictionary<string, IVariable>(dictionary); 65 } 66 public override IDeepCloneable Clone(Cloner cloner) { 67 return new VariableVectorCondition(this, cloner); 68 } 51 69 52 70 public bool Match(IInput target) { 53 71 var targetCast = target as VariableVectorInput; 54 72 if (targetCast == null) { return false; } 55 if (!this.Keys.All(x => targetCast.Keys.Contains(x))) { return false; } 56 foreach (var key in this.Keys) { 57 if (!this[key].MatchInput(targetCast[key])) { 73 foreach (var key in VariableDictionary.Keys) { 74 if (!targetCast.InputDictionary.ContainsKey(key) || !VariableDictionary[key].MatchInput(targetCast.InputDictionary[key])) { 58 75 return false; 59 76 } … … 64 81 public void Add(IEnumerable<IVariable> condition) { 65 82 foreach (var variable in condition) { 66 this.Add(variable.VariableName, variable);83 VariableDictionary.Add(variable.VariableName, variable); 67 84 } 68 85 } … … 71 88 StringBuilder sb = new StringBuilder(); 72 89 bool first = true; 73 foreach (var variable in this.Values) {90 foreach (var variable in VariableDictionary.Values) { 74 91 if (first) { 75 92 first = false; … … 83 100 84 101 public void Randomize(IRandom random, double spreadPercentage) { 85 foreach (var variable in this.Values) {102 foreach (var variable in VariableDictionary.Values) { 86 103 if (variable is DoubleVariable) { 87 104 ((DoubleVariable)variable).Randomize(random, spreadPercentage); … … 94 111 public bool Identical(VariableVectorCondition target) { 95 112 if (!this.Order.SequenceEqual(target.Order)) { return false; } 96 foreach (var keyValuePair in target ) {97 if (! this[keyValuePair.Key].Identical(keyValuePair.Value)) {113 foreach (var keyValuePair in target.VariableDictionary) { 114 if (!VariableDictionary[keyValuePair.Key].Identical(keyValuePair.Value)) { 98 115 return false; 99 116 } … … 101 118 return true; 102 119 } 103 104 public virtual string ItemName {105 get { return ItemAttribute.GetName(this.GetType()); }106 }107 public virtual string ItemDescription {108 get { return ItemAttribute.GetDescription(this.GetType()); }109 }110 public Version ItemVersion {111 get { return ItemAttribute.GetVersion(this.GetType()); }112 }113 public static Image StaticItemImage {114 get { return HeuristicLab.Common.Resources.VSImageLibrary.Class; }115 }116 public virtual Image ItemImage {117 get { return ItemAttribute.GetImage(this.GetType()); }118 }119 120 public virtual IDeepCloneable Clone(Cloner cloner) {121 return new VariableVectorCondition(this, cloner);122 }123 124 public object Clone() {125 return Clone(new Cloner());126 }127 128 public event EventHandler ItemImageChanged;129 protected virtual void OnItemImageChanged() {130 EventHandler handler = ItemImageChanged;131 if (handler != null) handler(this, EventArgs.Empty);132 }133 public event EventHandler ToStringChanged;134 protected virtual void OnToStringChanged() {135 EventHandler handler = ToStringChanged;136 if (handler != null) handler(this, EventArgs.Empty);137 }138 120 } 139 121 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/VariableVectorCreator.cs
r9194 r9242 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data;25 24 using HeuristicLab.Operators; 26 25 using HeuristicLab.Optimization; … … 34 33 35 34 #region Parameter Properties 36 public IValueLookupParameter<PercentValue> SpreadPercentageParameter { 37 get { return (IValueLookupParameter<PercentValue>)Parameters["SpreadPercentage"]; } 38 } 39 public IValueLookupParameter<VariableVector> SampleVariableVectorParameter { 40 get { return (IValueLookupParameter<VariableVector>)Parameters["SampleVariableVector"]; } 35 public IValueLookupParameter<IVariableVectorClassificationProblemData> ProblemDataParameter { 36 get { return (IValueLookupParameter<IVariableVectorClassificationProblemData>)Parameters["ProblemData"]; } 41 37 } 42 38 public ILookupParameter<VariableVector> VariableVectorParameter { … … 48 44 #endregion 49 45 46 protected IVariableVectorClassificationProblemData ProblemData { 47 get { return ProblemDataParameter.ActualValue; } 48 } 49 50 50 [StorableConstructor] 51 51 protected VariableVectorCreator(bool deserializing) : base(deserializing) { } … … 55 55 public VariableVectorCreator() 56 56 : base() { 57 Parameters.Add(new ValueLookupParameter<PercentValue>("SpreadPercentage", "")); 58 Parameters.Add(new ValueLookupParameter<VariableVector>("SampleVariableVector", "")); 57 Parameters.Add(new ValueLookupParameter<IVariableVectorClassificationProblemData>("ProblemData", "")); 59 58 Parameters.Add(new LookupParameter<VariableVector>("VariableVector", "")); 60 59 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); … … 62 61 63 62 public override IOperation Apply() { 64 VariableVectorParameter.ActualValue = Create(RandomParameter.ActualValue, SampleVariableVectorParameter.ActualValue, SpreadPercentageParameter.ActualValue.Value);63 VariableVectorParameter.ActualValue = Create(RandomParameter.ActualValue, ProblemData.SampleVariableVectorParameter.Value, ProblemData.SpreadPercentageParameter.Value.Value); 65 64 return base.Apply(); 66 65 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/VariableVectorInput.cs
r9226 r9242 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing;25 24 using System.Linq; 26 25 using System.Text; … … 33 32 [StorableClass] 34 33 [Item("VariableVectorInput", "")] 35 public class VariableVectorInput : Dictionary<string, string>, IInput {34 public class VariableVectorInput : Item, IInput { 36 35 37 public IOrderedEnumerable<string> Order { get { return this.Keys.OrderBy(x => x); } } 36 [Storable] 37 private Dictionary<string, string> inputDictionary; 38 public Dictionary<string, string> InputDictionary { 39 get { return inputDictionary; } 40 protected set { 41 inputDictionary = value; 42 } 43 } 44 45 public IOrderedEnumerable<string> Order { get { return InputDictionary.Keys.OrderBy(x => x); } } 38 46 39 47 [StorableConstructor] 40 48 protected VariableVectorInput(bool deserializing) { } 41 49 protected VariableVectorInput(VariableVectorInput original, Cloner cloner) { 42 foreach (var item in original) { 43 Add((string)item.Key.Clone(), (string)item.Value.Clone()); 50 InputDictionary = new Dictionary<string, string>(original.InputDictionary.Count); 51 foreach (var item in original.InputDictionary) { 52 InputDictionary.Add(item.Key, item.Value); 44 53 } 45 54 } 46 public VariableVectorInput() : base() { } 47 public VariableVectorInput(int capacity) : base(capacity) { } 48 public VariableVectorInput(IDictionary<string, string> dictionary) : base(dictionary) { } 55 public VariableVectorInput() 56 : base() { 57 InputDictionary = new Dictionary<string, string>(); 58 } 59 public VariableVectorInput(int capacity) 60 : base() { 61 InputDictionary = new Dictionary<string, string>(capacity); 62 } 63 public VariableVectorInput(IDictionary<string, string> dictionary) 64 : base() { 65 InputDictionary = new Dictionary<string, string>(dictionary); 66 } 67 public override IDeepCloneable Clone(Cloner cloner) { 68 return new VariableVectorInput(this, cloner); 69 } 49 70 50 71 public override string ToString() { 51 72 StringBuilder sb = new StringBuilder(); 52 73 bool first = true; 53 foreach (var item in this) {74 foreach (var item in InputDictionary) { 54 75 if (first) { 55 76 first = false; … … 61 82 return sb.ToString(); 62 83 } 63 64 public virtual string ItemName {65 get { return ItemAttribute.GetName(this.GetType()); }66 }67 public virtual string ItemDescription {68 get { return ItemAttribute.GetDescription(this.GetType()); }69 }70 public Version ItemVersion {71 get { return ItemAttribute.GetVersion(this.GetType()); }72 }73 public static Image StaticItemImage {74 get { return HeuristicLab.Common.Resources.VSImageLibrary.Class; }75 }76 public virtual Image ItemImage {77 get { return ItemAttribute.GetImage(this.GetType()); }78 }79 80 public virtual IDeepCloneable Clone(Cloner cloner) {81 return new VariableVectorInput(this, cloner);82 }83 84 public object Clone() {85 return Clone(new Cloner());86 }87 88 public event EventHandler ItemImageChanged;89 protected virtual void OnItemImageChanged() {90 EventHandler handler = ItemImageChanged;91 if (handler != null) handler(this, EventArgs.Empty);92 }93 public event EventHandler ToStringChanged;94 protected virtual void OnToStringChanged() {95 EventHandler handler = ToStringChanged;96 if (handler != null) handler(this, EventArgs.Empty);97 }98 84 } 99 85 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.CombinedIntegerVectorClassification/3.3/CombinedIntegerVectorClassificationProblem.cs
r9226 r9242 37 37 public class CombinedIntegerVectorClassificationProblem : ConditionActionClassificationProblem<UniformRandomCombinedIntegerVectorCreator, 38 38 CombinedIntegerVectorComparer, 39 CombinedIntegerVectorClassificationProblemData> {39 CombinedIntegerVectorClassificationProblemData>, ICombinedIntegerVectorClassificationProblem { 40 40 public override string ChildName { 41 41 get { return "CombinedIntegerVector"; } … … 57 57 ProblemDataParameter.Value = value; 58 58 if (value != null) { 59 SetProblemDataS pecificParameters();59 SetProblemDataSettings(); 60 60 } 61 61 } … … 91 91 Parameters.Add(new FixedValueParameter<ItemSet<CombinedIntegerVector>>("PossibleActionsConcreteClass", new ItemSet<CombinedIntegerVector>(ClassifierComparer))); 92 92 93 SetProblemDataS pecificParameters();93 SetProblemDataSettings(); 94 94 95 95 InitializeOperators(); 96 97 problemData.Changed += new System.EventHandler(problemData_Changed);98 96 } 99 97 100 private void problemData_Changed(object sender, System.EventArgs e) { 101 SetProblemDataSpecificParameters(); 102 } 103 104 private void SetProblemDataSpecificParameters() { 105 SolutionCreator.ActionPartLengthParameter.Value = ProblemData.ActionLengthParameter.Value; 106 SolutionCreator.LengthParameter.Value = ProblemData.LengthParameter.Value; 107 SolutionCreator.BoundsParameter.Value = ProblemData.BoundsParameter.Value; 98 protected override void SetProblemDataSettings() { 99 SolutionCreator.ProblemDataParameter.ActualName = ProblemDataParameter.Name; 108 100 109 101 SetPossibleActions(); -
branches/LearningClassifierSystems/HeuristicLab.Problems.CombinedIntegerVectorClassification/3.3/CombinedIntegerVectorClassificationProblemData.cs
r9226 r9242 36 36 [StorableClass] 37 37 [Item("CombinedIntegerVectorClassificationProblemData", "A problem data for LCS.")] 38 public class CombinedIntegerVectorClassificationProblemData : ConditionActionClassificationProblemData {38 public class CombinedIntegerVectorClassificationProblemData : ConditionActionClassificationProblemData, ICombinedIntegerVectorClassificationProblemData { 39 39 40 40 #region parameter properites -
branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/ConditionActionClassificationProblem.cs
r9226 r9242 20 20 #endregion 21 21 22 using System; 22 23 using System.Linq; 23 24 using HeuristicLab.Common; … … 184 185 InitializeOperators(); 185 186 186 problemData.Changed += new System.EventHandler(problemData_Changed); 187 } 188 189 private void problemData_Changed(object sender, System.EventArgs e) { 190 SetPossibleActions(); 191 } 187 //test event handlers after deserialization 188 RegisterEventHandlers(); 189 } 190 191 private void RegisterEventHandlers() { 192 ProblemDataParameter.ValueChanged += new EventHandler(ProblemDataParameter_ValueChanged); 193 if (ProblemDataParameter.Value != null) ProblemDataParameter.Value.Changed += new EventHandler(ProblemData_Changed); 194 } 195 196 private void ProblemDataParameter_ValueChanged(object sender, EventArgs e) { 197 ProblemDataParameter.Value.Changed += new EventHandler(ProblemData_Changed); 198 SetProblemDataSettings(); 199 OnReset(); 200 } 201 202 private void ProblemData_Changed(object sender, EventArgs e) { 203 SetProblemDataSettings(); 204 } 205 206 protected abstract void SetProblemDataSettings(); 192 207 193 208 private void InitializeOperators() { -
branches/LearningClassifierSystems/HeuristicLab.Problems.Instances.ConditionActionClassification/3.3/HeuristicLab.Problems.Instances.ConditionActionClassification-3.3.csproj
r9228 r9242 79 79 <Private>False</Private> 80 80 </ProjectReference> 81 <ProjectReference Include="..\..\HeuristicLab.Encodings.CombinedIntegerVectorEncoding\3.3\HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3.csproj"> 82 <Project>{CE7163C5-BFFE-45F0-9BD0-E10EF24E8BD2}</Project> 83 <Name>HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3</Name> 84 </ProjectReference> 81 85 <ProjectReference Include="..\..\HeuristicLab.Encodings.ConditionActionEncoding\3.3\HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj"> 82 86 <Project>{422FB262-0845-4969-8D16-12F057AA90B1}</Project> 83 87 <Name>HeuristicLab.Encodings.ConditionActionEncoding-3.3</Name> 84 88 <Private>False</Private> 89 </ProjectReference> 90 <ProjectReference Include="..\..\HeuristicLab.Encodings.VariableVector\3.3\HeuristicLab.Encodings.VariableVector-3.3.csproj"> 91 <Project>{7C116F48-7218-4105-BD6E-EE868E2D4823}</Project> 92 <Name>HeuristicLab.Encodings.VariableVector-3.3</Name> 85 93 </ProjectReference> 86 94 <ProjectReference Include="..\..\HeuristicLab.Problems.CombinedIntegerVectorClassification\3.3\HeuristicLab.Problems.CombinedIntegerVectorClassification-3.3.csproj"> -
branches/LearningClassifierSystems/HeuristicLab.Problems.Instances.ConditionActionClassification/3.3/VariableVectorCVSInstanceProvider.cs
r9228 r9242 22 22 using System.Collections.Generic; 23 23 using System.Linq; 24 using HeuristicLab.Problems.CombinedIntegerVectorClassification;25 24 using HeuristicLab.Problems.DataAnalysis; 26 25 using HeuristicLab.Problems.Instances.DataAnalysis; 26 using HeuristicLab.Problems.VariableVectorClassification; 27 27 28 28 namespace HeuristicLab.Problems.Instances.ConditionActionClassification { -
branches/LearningClassifierSystems/HeuristicLab.Problems.VariableVectorClassification/3.3/VariableVectorClassificationProblem.cs
r9228 r9242 33 33 using HeuristicLab.Problems.DataAnalysis; 34 34 35 namespace HeuristicLab.Problems. CombinedIntegerVectorClassification {35 namespace HeuristicLab.Problems.VariableVectorClassification { 36 36 [StorableClass] 37 37 public class VariableVectorClassificationProblem : ConditionActionClassificationProblem<UniformRandomVariableVectorCreator, 38 38 VariableVectorActionComparer, 39 VariableVectorClassificationProblemData> {39 VariableVectorClassificationProblemData>, IVariableVectorClassificationProblem { 40 40 public override string ChildName { 41 41 get { return "VariableVector"; } … … 49 49 get { return (IFixedValueParameter<VariableVectorActionComparer>)Parameters["ClassifierComparer"]; } 50 50 } 51 public IVariableVectorCoveringCreator VariableVectorCoveringCreator { 52 get { return (IVariableVectorCoveringCreator)CoveringSolutionCreator; } 53 } 51 54 #endregion 52 55 … … 57 60 ProblemDataParameter.Value = value; 58 61 if (value != null) { 59 SetProblemDataS pecificParameters();62 SetProblemDataSettings(); 60 63 } 61 64 } … … 91 94 Parameters.Add(new FixedValueParameter<ItemSet<VariableVectorAction>>("PossibleActionsConcreteClass", new ItemSet<VariableVectorAction>(ClassifierComparer))); 92 95 93 coveringSolutionCreator.SampleVariableVectorParameter.ActualName = problemData.SampleVariableVectorParameter.Name;96 SolutionCreator.VariableVectorParameter.ActualName = ChildName; 94 97 95 SetProblemDataS pecificParameters();98 SetProblemDataSettings(); 96 99 97 100 InitializeOperators(); 98 99 problemData.Changed += new System.EventHandler(problemData_Changed);100 101 } 101 102 102 private void problemData_Changed(object sender, System.EventArgs e) { 103 SetProblemDataSpecificParameters(); 104 } 103 protected override void SetProblemDataSettings() { 104 SolutionCreator.ProblemDataParameter.ActualName = ProblemDataParameter.Name; 105 105 106 private void SetProblemDataSpecificParameters() { 107 SolutionCreator.SampleVariableVectorParameter.Value = ProblemData.SampleVariableVectorParameter.Value; 108 SolutionCreator.VariableVectorParameter.ActualName = ChildName; 109 SolutionCreator.SpreadPercentageParameter.Value = ProblemData.SpreadPercentageParameter.Value; 106 VariableVectorCoveringCreator.ProblemDataParameter.ActualName = ProblemDataParameter.Name; 110 107 111 108 SetPossibleActions(); … … 130 127 var sampleAction = ProblemData.SampleVariableVector.Action; 131 128 var actionKeys = sampleAction.Order; 132 var actionsEnumeratorList = sampleAction. ToDictionary(x => x.Key, y => y.Value.GetAllPossibleActions().ToList());129 var actionsEnumeratorList = sampleAction.VariableDictionary.ToDictionary(x => x.Key, y => y.Value.GetAllPossibleActions().ToList()); 133 130 int[] curPos = new int[actionsEnumeratorList.Count]; 134 131 //initialize curPos … … 145 142 cur = 0; 146 143 foreach (var key in actionKeys) { 147 curAction [key].SetTo(actionsEnumeratorList[key][curPos[cur]]);144 curAction.VariableDictionary[key].SetTo(actionsEnumeratorList[key][curPos[cur]]); 148 145 cur++; 149 146 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.VariableVectorClassification/3.3/VariableVectorClassificationProblemData.cs
r9228 r9242 33 33 using HeuristicLab.Problems.DataAnalysis; 34 34 35 namespace HeuristicLab.Problems. CombinedIntegerVectorClassification {35 namespace HeuristicLab.Problems.VariableVectorClassification { 36 36 [StorableClass] 37 37 [Item("CombinedIntegerVectorClassificationProblemData", "A problem data for LCS.")] 38 public class VariableVectorClassificationProblemData : ConditionActionClassificationProblemData {38 public class VariableVectorClassificationProblemData : ConditionActionClassificationProblemData, IVariableVectorClassificationProblemData { 39 39 40 40 #region parameter properites … … 90 90 var doubleValues = (variableValues as List<double>).Distinct(); 91 91 if (doubleValues.All(x => x % 1 == 0)) { 92 variable = new IntVariable(variableName, doubleValues.Select(x => Convert.ToInt32(x))); 92 // ToList call is necessary, because otherwise it wouldn't be possible to serialize it 93 variable = new IntVariable(variableName, doubleValues.Select(x => Convert.ToInt32(x)).ToList()); 93 94 } else { 94 95 variable = new DoubleVariable(variableName, doubleValues); … … 105 106 if (!fetchInputCache.ContainsKey(rowNumber)) { 106 107 VariableVectorInput input = new VariableVectorInput(); 107 IEnumerable<string> variableNames = SampleVariableVector.Condition. Keys.Union(SampleVariableVector.Action.Keys);108 IEnumerable<string> variableNames = SampleVariableVector.Condition.VariableDictionary.Keys.Union(SampleVariableVector.Action.VariableDictionary.Keys); 108 109 foreach (var variableName in variableNames) { 109 input. Add(variableName, Dataset.GetValue(rowNumber, variableName));110 input.InputDictionary.Add(variableName, Dataset.GetValue(rowNumber, variableName)); 110 111 } 111 112 fetchInputCache.Add(rowNumber, input); … … 118 119 if (!fetchActionCache.ContainsKey(rowNumber)) { 119 120 var action = SampleVariableVector.Action.GetEmptyCopy(); 120 foreach (var variableName in action. Keys) {121 action [variableName].SetTo(Dataset.GetValue(rowNumber, variableName));121 foreach (var variableName in action.VariableDictionary.Keys) { 122 action.VariableDictionary[variableName].SetTo(Dataset.GetValue(rowNumber, variableName)); 122 123 } 123 124 fetchActionCache.Add(rowNumber, action);
Note: See TracChangeset
for help on using the changeset viewer.