- Timestamp:
- 05/03/17 01:31:10 (8 years ago)
- Location:
- branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Configuration/PushConfiguration.cs
r14905 r14909 166 166 EnabledExpressions.Clear(); 167 167 168 // Enable those are required169 168 foreach (StackTypes type in Enum.GetValues(types.GetType())) { 170 169 if (type == StackTypes.None) continue; 171 172 170 enabledStacks[type] = false; 173 174 if (types.HasFlag(type)) 175 EnableStack(type, false, true); 171 } 172 173 foreach (var pair in ExpressionTable.StackDependencyToNamesTable) { 174 if (types.HasFlag(pair.Key)) { 175 foreach (var name in pair.Value) { 176 EnableExpression(name, true); 177 } 178 } 176 179 } 177 180 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/ExpressionTable.cs
r14875 r14909 141 141 public static IReadOnlyList<string> GetExpressionsByStackTypes(StackTypes allowedTypes) { 142 142 return stackDependencyToNamesTable 143 .Where(entry => (entry.Key & ~allowedTypes) == StackTypes.None)143 .Where(entry => (entry.Key & ~allowedTypes) == 0x0) 144 144 .SelectMany(entry => entry.Value) 145 145 .ToArray(); -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/VectorNthExpressions.cs
r14834 r14909 16 16 IPushStack<List<T>> vectorStack, 17 17 IPushStack<T> literalStack) { 18 if (vectorStack.IsEmpty || interpreter.IntegerStack.IsEmpty) return false;18 if (vectorStack.IsEmpty || vectorStack.Top.Count == 0 || interpreter.IntegerStack.IsEmpty) return false; 19 19 20 20 var vector = vectorStack.Pop(); -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/VectorSetExpressions.cs
r14875 r14909 17 17 bool isLiteralTypeInteger = false) { 18 18 if (vectorStack.IsEmpty || 19 vectorStack.Top.Count == 0 || 19 20 literalStack.IsEmpty || 20 21 (isLiteralTypeInteger && interpreter.IntegerStack.Count < 2) || … … 38 39 39 40 if (index < 0) 40 index = vector.Count - index;41 index *= -1; 41 42 42 43 vector[index] = literal; -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/VectorSubExpressions.cs
r14875 r14909 16 16 if (vectorStack.IsEmpty || interpreter.IntegerStack.Count < 2) return false; 17 17 18 var first = (int)Math.Min(vectorStack. Count, Math.Max(0, interpreter.IntegerStack[1]));19 var second = (int)Math.Min(vectorStack. Count, Math.Max(first, interpreter.IntegerStack.Top));18 var first = (int)Math.Min(vectorStack.Top.Count, Math.Max(0, interpreter.IntegerStack[1])); 19 var second = (int)Math.Min(vectorStack.Top.Count, Math.Max(first, interpreter.IntegerStack.Top)); 20 20 interpreter.IntegerStack.Remove(2); 21 21 22 if (vectorStack.Top.Count == 0) 23 return true; 24 22 25 var result = vectorStack.Top.GetRange(first, second - first); 23 vectorStack. Push(result);26 vectorStack.SetTop(result); 24 27 return true; 25 28 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/VectorTakeExpressions.cs
r14834 r14909 16 16 17 17 var count = (int)interpreter.IntegerStack.Pop(); 18 19 if (vectorStack.Top.Count == 0) 20 return true; 21 22 count %= vectorStack.Top.Count; 23 24 if (count < 0) 25 count *= -1; 26 18 27 var result = vectorStack.Top.GetRange(0, count); 28 vectorStack.SetTop(result); 19 29 20 vectorStack.Push(result);21 30 return true; 22 31 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/BenchmarkSuite/PushBenchmarkSuiteEvaluator.cs
r14908 r14909 2 2 using System; 3 3 using System.Collections.Generic; 4 using System.Linq; 5 4 6 using Common; 5 7 using Core; … … 7 9 8 10 using HeuristicLab.BenchmarkSuite; 9 using HeuristicLab.BenchmarkSuite.Problems;10 11 using HeuristicLab.Parameters; 11 12 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 131 132 interpreter.IntegerStack.Push(example.InputInteger); 132 133 interpreter.FloatStack.Push(example.InputFloat); 134 interpreter.CharStack.Push(example.InputChar); 135 interpreter.StringStack.Push(example.InputString); 136 interpreter.StringVectorStack.Push(example.InputStringVector.Select(v => new List<string>(v))); 137 interpreter.IntegerVectorStack.Push(example.InputIntegerVector.Select(v => new List<long>(v))); 138 interpreter.FloatVectorStack.Push(example.InputFloatVector.Select(v => new List<double>(v))); 133 139 134 140 interpreter.Run(program); -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Stack/IPushStack.cs
r14875 r14909 15 15 void Push(IReadOnlyList<T> items, int startIndex = 0); 16 16 void Push(IReadOnlyList<T> items); 17 void Push(IEnumerable<T> items); 17 18 T Peek(); 18 19 T[] Peek(int count); -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Stack/PushStack.cs
r14908 r14909 230 230 } 231 231 232 public void Push(IEnumerable<T> items) { 233 if (!IsEnabled) return; 234 235 data.AddRange(items); 236 } 237 232 238 public void Insert(int index, T item) { 233 239 if (!IsEnabled) return;
Note: See TracChangeset
for help on using the changeset viewer.