Changeset 5712
- Timestamp:
- 03/16/11 14:47:32 (14 years ago)
- Location:
- branches/DataAnalysis Refactoring
- Files:
-
- 4 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
r5695 r5712 51 51 [Storable(Name = "AllowedChildSymbols")] 52 52 private IEnumerable<KeyValuePair<ISymbol, IEnumerable<ISymbol>>> StorableAllowedChildSymbols { 53 get { return allowedChildSymbols.Select(x => new KeyValuePair<ISymbol, IEnumerable<ISymbol>>(GetSymbol(x.Key), x.Value.Select(y => GetSymbol(y)) )).ToArray();; }53 get { return allowedChildSymbols.Select(x => new KeyValuePair<ISymbol, IEnumerable<ISymbol>>(GetSymbol(x.Key), x.Value.Select(y => GetSymbol(y)).ToArray())).ToArray(); } 54 54 set { allowedChildSymbols = value.ToDictionary(x => x.Key.Name, x => x.Value.Select(y => y.Name).ToList()); } 55 55 } … … 57 57 [Storable(Name = "AllowedChildSymbolsPerIndex")] 58 58 private IEnumerable<KeyValuePair<Tuple<ISymbol, int>, IEnumerable<ISymbol>>> StorableAllowedChildSymbolsPerIndex { 59 get { return allowedChildSymbolsPerIndex.Select(x => new KeyValuePair<Tuple<ISymbol, int>, IEnumerable<ISymbol>>(Tuple.Create (GetSymbol(x.Key.Item1), x.Key.Item2), x.Value.Select(y => GetSymbol(y)))).ToArray(); }59 get { return allowedChildSymbolsPerIndex.Select(x => new KeyValuePair<Tuple<ISymbol, int>, IEnumerable<ISymbol>>(Tuple.Create<ISymbol, int>(GetSymbol(x.Key.Item1), x.Key.Item2), x.Value.Select(y => GetSymbol(y)).ToArray())).ToArray(); } 60 60 set { allowedChildSymbolsPerIndex = value.ToDictionary(x => Tuple.Create(x.Key.Item1.Name, x.Key.Item2), x => x.Value.Select(y => y.Name).ToList()); } 61 61 } -
branches/DataAnalysis Refactoring/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/TupleSerializer.cs
r5698 r5712 63 63 public IEnumerable<Tag> CreateMetaInfo(object obj) { 64 64 Type t = obj.GetType(); 65 for (int i = 1; i <=t.GetGenericArguments().Length; i++) {65 for (int i = 1; i <= t.GetGenericArguments().Length; i++) { 66 66 string name = string.Format("Item{0}", i); 67 67 yield return new Tag(name, t.GetProperty(name).GetValue(obj, null)); … … 79 79 static TupleSerializer() { 80 80 foreach (MethodInfo mi in typeof(Tuple).GetMethods(public_static).Where(mi => mi.Name == "Create")) { 81 CreateMethods[mi.GetGenericArguments().Length -1] = mi;81 CreateMethods[mi.GetGenericArguments().Length - 1] = mi; 82 82 } 83 83 } … … 85 85 public object CreateInstance(Type type, IEnumerable<Tag> metaInfo) { 86 86 var values = metaInfo.Select(t => t.Value).ToArray(); 87 MethodInfo createMethod = CreateMethods[values.Length-1].MakeGenericMethod(values.Select(v => v.GetType()).ToArray()); 87 88 MethodInfo createMethod = CreateMethods[values.Length - 1].MakeGenericMethod(type.GetGenericArguments()); 88 89 return createMethod.Invoke(null, values.ToArray()); 89 90 } -
branches/DataAnalysis Refactoring/HeuristicLab.Persistence/3.3/HeuristicLab.Persistence-3.3.csproj
r5290 r5712 142 142 <Compile Include="Default\CompositeSerializers\CompactNumberArray2StringSerializer.cs" /> 143 143 <Compile Include="Default\CompositeSerializers\ConcreteDictionarySerializer.cs" /> 144 <Compile Include="Default\CompositeSerializers\TupleSerializer.cs" /> 144 145 <Compile Include="Default\CompositeSerializers\HashSetSerializer.cs" /> 145 146 <Compile Include="Default\CompositeSerializers\DictionarySerializer.cs" /> -
branches/DataAnalysis Refactoring/HeuristicLab.Persistence/3.3/Tests/UseCases.cs
r5445 r5712 1243 1243 } 1244 1244 1245 [TestMethod] 1246 public void TupleTest() { 1247 var t1 = Tuple.Create(1); 1248 var t2 = Tuple.Create('1', "2"); 1249 var t3 = Tuple.Create(3.0, 3f, 5); 1250 var t4 = Tuple.Create(Tuple.Create(1, 2, 3), Tuple.Create(4, 5, 6), Tuple.Create(8, 9, 10)); 1251 var tuple = Tuple.Create(t1, t2, t3, t4); 1252 XmlGenerator.Serialize(tuple, tempFile); 1253 var newTuple = XmlParser.Deserialize<Tuple<Tuple<int>, Tuple<char, string>, Tuple<double, float, int>, Tuple<Tuple<int, int, int>, Tuple<int, int, int>, Tuple<int, int, int>>>>(tempFile); 1254 Assert.AreEqual(tuple, newTuple); 1255 } 1256 1245 1257 1246 1258 -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/ArtificialAntProblem.cs
r5686 r5712 105 105 } 106 106 public IValueParameter<IntValue> MaxExpressionLengthParameter { 107 get { return (IValueParameter<IntValue>)Parameters["Max ExpressionLength"]; }107 get { return (IValueParameter<IntValue>)Parameters["MaximumExpressionLength"]; } 108 108 } 109 109 public IValueParameter<IntValue> MaxExpressionDepthParameter { 110 get { return (IValueParameter<IntValue>)Parameters["Max ExpressionDepth"]; }110 get { return (IValueParameter<IntValue>)Parameters["MaximumExpressionDepth"]; } 111 111 } 112 112 public IValueParameter<IntValue> MaxFunctionDefinitionsParameter { 113 get { return (IValueParameter<IntValue>)Parameters["Max FunctionDefinitions"]; }113 get { return (IValueParameter<IntValue>)Parameters["MaximumFunctionDefinitions"]; } 114 114 } 115 115 public IValueParameter<IntValue> MaxFunctionArgumentsParameter { 116 get { return (ValueParameter<IntValue>)Parameters["Max FunctionArguments"]; }116 get { return (ValueParameter<IntValue>)Parameters["MaximumFunctionArguments"]; } 117 117 } 118 118 public IValueParameter<BoolMatrix> WorldParameter { … … 120 120 } 121 121 public IValueParameter<IntValue> MaxTimeStepsParameter { 122 get { return (IValueParameter<IntValue>)Parameters["Max TimeSteps"]; }122 get { return (IValueParameter<IntValue>)Parameters["MaximumTimeSteps"]; } 123 123 } 124 124 … … 215 215 Parameters.Add(new ValueParameter<Evaluator>("Evaluator", "The operator which should be used to evaluate artificial ant solutions.", evaluator)); 216 216 Parameters.Add(new ValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this artificial ant instance.", new DoubleValue(89))); 217 Parameters.Add(new ValueParameter<IntValue>("Max ExpressionLength", "Maximal length of the expression to control the artificial ant.", new IntValue(100)));218 Parameters.Add(new ValueParameter<IntValue>("Max ExpressionDepth", "Maximal depth of the expression to control the artificial ant.", new IntValue(10)));219 Parameters.Add(new ValueParameter<IntValue>("Max FunctionDefinitions", "Maximal number of automatically defined functions in the expression to control the artificial ant.", new IntValue(3)));220 Parameters.Add(new ValueParameter<IntValue>("Max FunctionArguments", "Maximal number of arguments of automatically defined functions in the expression to control the artificial ant.", new IntValue(3)));217 Parameters.Add(new ValueParameter<IntValue>("MaximumExpressionLength", "Maximal length of the expression to control the artificial ant.", new IntValue(100))); 218 Parameters.Add(new ValueParameter<IntValue>("MaximumExpressionDepth", "Maximal depth of the expression to control the artificial ant.", new IntValue(10))); 219 Parameters.Add(new ValueParameter<IntValue>("MaximumFunctionDefinitions", "Maximal number of automatically defined functions in the expression to control the artificial ant.", new IntValue(3))); 220 Parameters.Add(new ValueParameter<IntValue>("MaximumFunctionArguments", "Maximal number of arguments of automatically defined functions in the expression to control the artificial ant.", new IntValue(3))); 221 221 Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>("ArtificialAntExpressionGrammar", "The grammar that should be used for artificial ant expressions.", new ArtificialAntExpressionGrammar())); 222 222 Parameters.Add(new ValueParameter<BoolMatrix>("World", "The world for the artificial ant with scattered food items.", world)); 223 Parameters.Add(new ValueParameter<IntValue>("Max TimeSteps", "The number of time steps the artificial ant has available to collect all food items.", new IntValue(600)));223 Parameters.Add(new ValueParameter<IntValue>("MaximumTimeSteps", "The number of time steps the artificial ant has available to collect all food items.", new IntValue(600))); 224 224 225 225 creator.SymbolicExpressionTreeParameter.ActualName = "AntTrailSolution";
Note: See TracChangeset
for help on using the changeset viewer.