- Timestamp:
- 05/02/17 22:03:01 (8 years ago)
- Location:
- branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Attributes/PushExpressionAttriubte.cs
r14834 r14908 11 11 12 12 public PushExpressionAttribute(StackTypes stackType, string expressionName, StackTypes additionalStackDependencies = default(StackTypes)) { 13 this.StackType = stackType;14 this.AdditionalStackDependencies = additionalStackDependencies;15 this.ExpressionName = expressionName;13 StackType = stackType; 14 AdditionalStackDependencies = additionalStackDependencies; 15 ExpressionName = expressionName; 16 16 } 17 17 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/List/SkipList.cs
r14875 r14908 50 50 51 51 public SkipListNode(T value) { 52 this.Value = value;52 Value = value; 53 53 } 54 54 … … 62 62 63 63 public virtual bool IsHeader() { 64 return this.GetType() == typeof(SkipListNodeHeader<T>);64 return GetType() == typeof(SkipListNodeHeader<T>); 65 65 } 66 66 67 67 public virtual bool IsFooter() { 68 return this.GetType() == typeof(SkipListNodeFooter<T>);68 return GetType() == typeof(SkipListNodeFooter<T>); 69 69 } 70 70 } … … 162 162 /// </summary> 163 163 protected void clearEmptyLevels() { 164 if ( this.levels > 1) //more than one level, don't want to remove bottom level164 if (levels > 1) //more than one level, don't want to remove bottom level 165 165 { 166 SkipListNode<T> currentNode = t his.topLeft;167 168 while (currentNode != this.bottomLeft) //do not remove the bottom level166 SkipListNode<T> currentNode = topLeft; 167 168 while (currentNode != bottomLeft) //do not remove the bottom level 169 169 { 170 170 if (currentNode.IsHeader() && currentNode.Next.IsFooter()) { … … 181 181 182 182 //Update counters 183 this.levels--;183 levels--; 184 184 185 185 currentNode = belowNode; //scan down … … 197 197 198 198 //Add levels to entire list if necessary 199 int newLevelCount = valueLevels - this.levels; //number of levels missing199 int newLevelCount = valueLevels - levels; //number of levels missing 200 200 while (newLevelCount > 0) { 201 201 //Create new level … … 203 203 204 204 //Link down 205 newLevel.Below = t his.topLeft;206 t his.topLeft.Above = newLevel;207 t his.topLeft = newLevel; //update reference to most top-left node205 newLevel.Below = topLeft; 206 topLeft.Above = newLevel; 207 topLeft = newLevel; //update reference to most top-left node 208 208 209 209 //Update counters 210 210 newLevelCount--; 211 this.levels++;211 levels++; 212 212 } 213 213 214 214 //Insert the value in the proper position, creating as many levels as was randomly determined 215 SkipListNode<T> currentNode = t his.topLeft;215 SkipListNode<T> currentNode = topLeft; 216 216 SkipListNode<T> lastNodeAbove = null; //keeps track of the upper-level nodes in a tower 217 int currentLevel = this.levels - 1;217 int currentLevel = levels - 1; 218 218 219 219 while (currentLevel >= 0 && currentNode != null) { … … 256 256 } 257 257 258 this.size++; //update count258 size++; //update count 259 259 } 260 260 … … 263 263 /// </summary> 264 264 public virtual SkipListNode<T> Find(T value) { 265 SkipListNode<T> foundNode = t his.topLeft;265 SkipListNode<T> foundNode = topLeft; 266 266 267 267 //Look for the highest-level node with an element value matching the parameter value … … 286 286 /// </summary> 287 287 public virtual SkipListNode<T> FindLowest(T value) { 288 SkipListNode<T> valueNode = this.Find(value);289 return this.FindLowest(valueNode);288 SkipListNode<T> valueNode = Find(value); 289 return FindLowest(valueNode); 290 290 } 291 291 … … 309 309 /// </summary> 310 310 public virtual SkipListNode<T> FindHighest(T value) { 311 SkipListNode<T> valueNode = this.Find(value);312 return this.FindHighest(valueNode);311 SkipListNode<T> valueNode = Find(value); 312 return FindHighest(valueNode); 313 313 } 314 314 … … 332 332 /// </summary> 333 333 public virtual bool Contains(T value) { 334 return ( this.Find(value) != null);334 return (Find(value) != null); 335 335 } 336 336 … … 339 339 /// </summary> 340 340 public virtual bool Remove(T value) { 341 SkipListNode<T> valueNode = this.FindHighest(value);342 return this.Remove(valueNode);341 SkipListNode<T> valueNode = FindHighest(value); 342 return Remove(valueNode); 343 343 } 344 344 … … 352 352 //Make sure node is top-level node in it's tower 353 353 if (valueNode.Above != null) 354 valueNode = this.FindHighest(valueNode);354 valueNode = FindHighest(valueNode); 355 355 356 356 //---Delete nodes going down the tower … … 372 372 373 373 //update counter 374 this.size--;374 size--; 375 375 376 376 //Clean up the Skip List by removing levels that are now empty 377 this.clearEmptyLevels();377 clearEmptyLevels(); 378 378 379 379 return true; … … 385 385 /// </summary> 386 386 public virtual void Clear() { 387 SkipListNode<T> currentNode = this.Head;387 SkipListNode<T> currentNode = Head; 388 388 389 389 while (currentNode != null) { … … 391 391 392 392 if (!currentNode.IsHeader() && !currentNode.IsFooter()) { 393 this.Remove(currentNode);393 Remove(currentNode); 394 394 } 395 395 … … 409 409 /// </summary> 410 410 public virtual void CopyTo(T[] array, int startIndex) { 411 IEnumerator<T> enumerator = this.GetEnumerator();411 IEnumerator<T> enumerator = GetEnumerator(); 412 412 413 413 for (int i = startIndex; i < array.Length; i++) { … … 423 423 /// </summary> 424 424 public virtual int GetHeight(T value) { 425 SkipListNode<T> valueNode = this.FindLowest(value);426 return this.GetHeight(valueNode);425 SkipListNode<T> valueNode = FindLowest(value); 426 return GetHeight(valueNode); 427 427 } 428 428 … … 459 459 /// </summary> 460 460 IEnumerator IEnumerable.GetEnumerator() { 461 return this.GetEnumerator();461 return GetEnumerator(); 462 462 } 463 463 … … 480 480 object IEnumerator.Current 481 481 { 482 get { return this.Current; }482 get { return Current; } 483 483 } 484 484 … … 493 493 public bool MoveNext() { 494 494 if (current == null) 495 current = this.skipList.Head.Next; //Head is header node, start after495 current = skipList.Head.Next; //Head is header node, start after 496 496 else 497 497 current = current.Next; -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/Pool/PooledList.cs
r14777 r14908 7 7 public class PooledList<T> : List<T>, IPooledObject { 8 8 public void Reset() { 9 this.Clear();9 Clear(); 10 10 } 11 11 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/Pool/PooledObject.cs
r14834 r14908 16 16 17 17 public virtual void Dispose() { 18 this.resetor(this.item);19 this.pool.Free(this);18 resetor(item); 19 pool.Free(this); 20 20 } 21 21 22 22 public void Reset() { 23 this.resetor(this.item);23 resetor(item); 24 24 } 25 25 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/Tree/TreeNode.cs
r14777 r14908 15 15 16 16 public void Add(T value) { 17 this.Children.Add(new TreeNode<T>(value));17 Children.Add(new TreeNode<T>(value)); 18 18 } 19 19 20 20 public void AddNode(TreeNode<T> node) { 21 this.Children.Add(node);21 Children.Add(node); 22 22 } 23 23 -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/DefineExpressions.cs
r14875 r14908 36 36 if (interpreter.Configuration.TopLevelPushCode && (interpreter.CodeStack.Count < 2)) return false; 37 37 38 this.Eval(38 Eval( 39 39 interpreter.CodeStack, 40 40 interpreter.NameStack, … … 53 53 if (interpreter.ExecStack.Count < 2) return false; 54 54 55 var noop = this.Eval(55 var noop = Eval( 56 56 interpreter.ExecStack, 57 57 interpreter.NameStack, … … 70 70 71 71 public override bool Eval(IInternalPushInterpreter interpreter) { 72 return this.Eval(72 return Eval( 73 73 interpreter.FloatStack, 74 74 interpreter.NameStack, … … 81 81 public class IntegerDefineExpression : DefineExpression<long> { 82 82 public override bool Eval(IInternalPushInterpreter interpreter) { 83 return this.Eval(83 return Eval( 84 84 interpreter.IntegerStack, 85 85 interpreter.NameStack, … … 92 92 public class BooleanDefineExpression : DefineExpression<bool> { 93 93 public override bool Eval(IInternalPushInterpreter interpreter) { 94 return this.Eval(94 return Eval( 95 95 interpreter.BooleanStack, 96 96 interpreter.NameStack, -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/DoCountExpressions.cs
r14834 r14908 52 52 53 53 public override bool Eval(IInternalPushInterpreter interpreter) { 54 return this.Eval(interpreter, interpreter.CodeStack);54 return Eval(interpreter, interpreter.CodeStack); 55 55 } 56 56 … … 84 84 85 85 public override bool Eval(IInternalPushInterpreter interpreter) { 86 return this.Eval(interpreter, interpreter.ExecStack);86 return Eval(interpreter, interpreter.ExecStack); 87 87 } 88 88 -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/DoRangeExpressions.cs
r14875 r14908 57 57 public CodeDoRangeExpression(LoopState state) : base(state) { } 58 58 public override bool Eval(IInternalPushInterpreter interpreter) { 59 return this.Eval(interpreter, interpreter.CodeStack);59 return Eval(interpreter, interpreter.CodeStack); 60 60 } 61 61 … … 99 99 public ExecDoRangeExpression(LoopState state) : base(state) { } 100 100 public override bool Eval(IInternalPushInterpreter interpreter) { 101 return this.Eval(interpreter, interpreter.ExecStack);101 return Eval(interpreter, interpreter.ExecStack); 102 102 } 103 103 protected override LoopExpression Clone(LoopState state, IInternalPushInterpreter interpreter) { -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/DoTimesExpressions.cs
r14834 r14908 23 23 24 24 protected override void PushIteration(IInternalPushInterpreter interpreter) { 25 var newState = LoopState.Create(interpreter.PoolContainer.LoopStatePool, State.Body, State.CurrentIndex + this.State.Incrementor, State.DestinationIndex, State.Incrementor);25 var newState = LoopState.Create(interpreter.PoolContainer.LoopStatePool, State.Body, State.CurrentIndex + State.Incrementor, State.DestinationIndex, State.Incrementor); 26 26 var nextLoopExpression = Clone(newState, interpreter); 27 27 … … 30 30 31 31 protected override void PushLastIteration(IInternalPushInterpreter interpreter) { 32 interpreter.ExecStack.Push( this.State.Body);32 interpreter.ExecStack.Push(State.Body); 33 33 } 34 34 } … … 47 47 48 48 public override bool Eval(IInternalPushInterpreter interpreter) { 49 return this.Eval(interpreter, interpreter.CodeStack);49 return Eval(interpreter, interpreter.CodeStack); 50 50 } 51 51 … … 74 74 75 75 public override bool Eval(IInternalPushInterpreter interpreter) { 76 return this.Eval(interpreter, interpreter.ExecStack);76 return Eval(interpreter, interpreter.ExecStack); 77 77 } 78 78 -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/DuplicateExpressions.cs
r14875 r14908 24 24 public class IntegerDuplicateExpression : DuplicateExpression<long> { 25 25 public override bool Eval(IInternalPushInterpreter interpreter) { 26 return this.Eval(interpreter.IntegerStack);26 return Eval(interpreter.IntegerStack); 27 27 } 28 28 } … … 31 31 public class FloatDuplicateExpression : DuplicateExpression<double> { 32 32 public override bool Eval(IInternalPushInterpreter interpreter) { 33 return this.Eval(interpreter.FloatStack);33 return Eval(interpreter.FloatStack); 34 34 } 35 35 } … … 38 38 public class BooleanDuplicateExpression : DuplicateExpression<bool> { 39 39 public override bool Eval(IInternalPushInterpreter interpreter) { 40 return this.Eval(interpreter.BooleanStack);40 return Eval(interpreter.BooleanStack); 41 41 } 42 42 } … … 45 45 public class NameDuplicateExpression : DuplicateExpression<string> { 46 46 public override bool Eval(IInternalPushInterpreter interpreter) { 47 return this.Eval(interpreter.NameStack);47 return Eval(interpreter.NameStack); 48 48 } 49 49 } … … 52 52 public class ExecDuplicateExpression : DuplicateExpression<Expression> { 53 53 public override bool Eval(IInternalPushInterpreter interpreter) { 54 return this.Eval(interpreter.ExecStack);54 return Eval(interpreter.ExecStack); 55 55 } 56 56 } … … 59 59 public class CodeDuplicateExpression : DuplicateExpression<Expression> { 60 60 public override bool Eval(IInternalPushInterpreter interpreter) { 61 return this.Eval(interpreter.CodeStack);61 return Eval(interpreter.CodeStack); 62 62 } 63 63 } … … 66 66 public class IntegerVectorDuplicateExpression : DuplicateExpression<List<long>> { 67 67 public override bool Eval(IInternalPushInterpreter interpreter) { 68 return this.Eval(interpreter.IntegerVectorStack);68 return Eval(interpreter.IntegerVectorStack); 69 69 } 70 70 } … … 73 73 public class FloatVectorDuplicateExpression : DuplicateExpression<List<double>> { 74 74 public override bool Eval(IInternalPushInterpreter interpreter) { 75 return this.Eval(interpreter.FloatVectorStack);75 return Eval(interpreter.FloatVectorStack); 76 76 } 77 77 } … … 80 80 public class BooleanVectorDuplicateExpression : DuplicateExpression<List<bool>> { 81 81 public override bool Eval(IInternalPushInterpreter interpreter) { 82 return this.Eval(interpreter.BooleanVectorStack);82 return Eval(interpreter.BooleanVectorStack); 83 83 } 84 84 } … … 87 87 public class StringVectorDuplicateExpression : DuplicateExpression<List<string>> { 88 88 public override bool Eval(IInternalPushInterpreter interpreter) { 89 return this.Eval(interpreter.StringVectorStack);89 return Eval(interpreter.StringVectorStack); 90 90 } 91 91 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/Expression.cs
r14905 r14908 25 25 26 26 public override string ToString() { 27 return this.StringRepresentation;27 return StringRepresentation; 28 28 } 29 29 -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/LoopExpression.cs
r14834 r14908 46 46 var hash = 19; 47 47 48 if ( this.Body != null)49 hash = hash * 31 + this.Body.GetHashCode();48 if (Body != null) 49 hash = hash * 31 + Body.GetHashCode(); 50 50 51 hash = hash * 31 + this.CurrentIndex.GetHashCode();52 hash = hash * 31 + this.DestinationIndex.GetHashCode();53 hash = hash * 31 + this.Incrementor.GetHashCode();51 hash = hash * 31 + CurrentIndex.GetHashCode(); 52 hash = hash * 31 + DestinationIndex.GetHashCode(); 53 hash = hash * 31 + Incrementor.GetHashCode(); 54 54 55 55 return hash; … … 64 64 protected bool Eval(IInternalPushInterpreter interpreter, IPushStack<Expression> sourceStack, bool pushCurrentIndex = false) { 65 65 // if not initialized 66 if ( this.State.Body == null) {67 if ( this.HasInsufficientArguments(interpreter, sourceStack)) return false;66 if (State.Body == null) { 67 if (HasInsufficientArguments(interpreter, sourceStack)) return false; 68 68 69 var state = this.InitState(interpreter, sourceStack);69 var state = InitState(interpreter, sourceStack); 70 70 var initLoopExpression = Clone(state, interpreter); 71 71 … … 75 75 76 76 // if loop end reached 77 if ( this.State.DestinationIndex == this.State.CurrentIndex) {78 this.PushLastIteration(interpreter);77 if (State.DestinationIndex == State.CurrentIndex) { 78 PushLastIteration(interpreter); 79 79 return true; 80 80 } 81 81 82 this.PushIteration(interpreter);82 PushIteration(interpreter); 83 83 84 84 return true; … … 100 100 101 101 protected virtual void PushIteration(IInternalPushInterpreter interpreter) { 102 interpreter.IntegerStack.Push( this.State.CurrentIndex);102 interpreter.IntegerStack.Push(State.CurrentIndex); 103 103 104 104 var newState = LoopState.Create( -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/PushExpressions.cs
r14875 r14908 10 10 11 11 protected bool Eval(IPushStack<T> stack) { 12 stack.Push( this.State);12 stack.Push(State); 13 13 return true; 14 14 } 15 15 16 public override string StringRepresentation { get { return this.State.ToString(); } }16 public override string StringRepresentation { get { return State.ToString(); } } 17 17 } 18 18 -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/PushProgram.cs
r14875 r14908 43 43 public int Count { get { return expressions.Count; } } 44 44 45 public IReadOnlyList<Expression> Expressions { get { return this.expressions; } }45 public IReadOnlyList<Expression> Expressions { get { return expressions; } } 46 46 47 47 public static PushProgram Create(IManagedPool<PushProgram> pool, IReadOnlyList<Expression> expressions) { … … 152 152 return true; 153 153 154 if ( this.GetType() != obj.GetType())154 if (GetType() != obj.GetType()) 155 155 return false; 156 156 … … 168 168 169 169 public override bool Eval(IInternalPushInterpreter interpreter) { 170 interpreter.ExecStack.Push( this.expressions);170 interpreter.ExecStack.Push(expressions); 171 171 return true; 172 172 } … … 184 184 get 185 185 { 186 return this.IsEmpty186 return IsEmpty 187 187 ? 1 188 188 // + 1 because "this" is also counted … … 192 192 193 193 public IEnumerable<Expression> DepthLast() { 194 foreach (var expr in this.expressions) {194 foreach (var expr in expressions) { 195 195 if (expr.IsProgram) 196 196 foreach (var sub in ((PushProgram)expr).DepthLast()) … … 226 226 227 227 public IList<Expression> CopyExpressions() { 228 return new List<Expression>( this.expressions);228 return new List<Expression>(expressions); 229 229 } 230 230 … … 233 233 234 234 var copy = expressionListPool.Get(); 235 copy.AddRange( this.expressions);235 copy.AddRange(expressions); 236 236 237 237 return copy; … … 241 241 var maxDepth = 1; 242 242 for (var i = 0; i < Count; i++) { 243 var expression = this.expressions[i];243 var expression = expressions[i]; 244 244 if (!expression.IsProgram) continue; 245 245 var expandExpression = (PushProgram)expression; … … 265 265 266 266 for (var i = Count - 1; i >= 0; i--) { 267 var subExpression = this.expressions[i];267 var subExpression = expressions[i]; 268 268 269 269 local_treeIndex[i] = next; … … 283 283 284 284 for (var i = 0; i < Count; i++) { 285 hash = hash * 31 + this.expressions[i].GetHashCode();285 hash = hash * 31 + expressions[i].GetHashCode(); 286 286 } 287 287 … … 349 349 350 350 return TreeIndex[mid] == index 351 ? resolver(parent, this, this.expressions[mid], mid, parentIndex)352 : ( this.expressions[mid + 1] as PushProgram).GetFromTree(index - TreeIndex[mid + 1], mid + 1,351 ? resolver(parent, this, expressions[mid], mid, parentIndex) 352 : (expressions[mid + 1] as PushProgram).GetFromTree(index - TreeIndex[mid + 1], mid + 1, 353 353 this, resolver); 354 354 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/StatefulExpression.cs
r14777 r14908 11 11 12 12 protected StatefulExpression(T state) { 13 this.State = state;13 State = state; 14 14 } 15 15 16 16 protected virtual int CalcHashCode() { 17 return this.State.GetHashCode();17 return State.GetHashCode(); 18 18 } 19 19 … … 22 22 get 23 23 { 24 if (stringRepresentation == null) stringRepresentation = this.State.ToString();24 if (stringRepresentation == null) stringRepresentation = State.ToString(); 25 25 return stringRepresentation; 26 26 } … … 31 31 return true; 32 32 33 if ( this.GetType() != obj.GetType())33 if (GetType() != obj.GetType()) 34 34 return false; 35 35 36 36 var other = (StatefulExpression<T>)obj; 37 37 38 return ReferenceEquals( this.State, other.State) ||39 this.GetHashCode() == other.GetHashCode();38 return ReferenceEquals(State, other.State) || 39 GetHashCode() == other.GetHashCode(); 40 40 } 41 41 -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/YankDuplicateExpressions.cs
r14875 r14908 26 26 public class IntegerYankDuplicateExpression : YankDuplicateExpression<long> { 27 27 public override bool Eval(IInternalPushInterpreter interpreter) { 28 return this.Eval(interpreter.IntegerStack, interpreter.IntegerStack);28 return Eval(interpreter.IntegerStack, interpreter.IntegerStack); 29 29 } 30 30 } … … 33 33 public class FloatYankDuplicateExpression : YankDuplicateExpression<double> { 34 34 public override bool Eval(IInternalPushInterpreter interpreter) { 35 return this.Eval(interpreter.FloatStack, interpreter.IntegerStack);35 return Eval(interpreter.FloatStack, interpreter.IntegerStack); 36 36 } 37 37 } … … 40 40 public class BooleanYankDuplicateExpression : YankDuplicateExpression<bool> { 41 41 public override bool Eval(IInternalPushInterpreter interpreter) { 42 return this.Eval(interpreter.BooleanStack, interpreter.IntegerStack);42 return Eval(interpreter.BooleanStack, interpreter.IntegerStack); 43 43 } 44 44 } … … 47 47 public class NameYankDuplicateExpression : YankDuplicateExpression<string> { 48 48 public override bool Eval(IInternalPushInterpreter interpreter) { 49 return this.Eval(interpreter.NameStack, interpreter.IntegerStack);49 return Eval(interpreter.NameStack, interpreter.IntegerStack); 50 50 } 51 51 } … … 54 54 public class ExecYankDuplicateExpression : YankDuplicateExpression<Expression> { 55 55 public override bool Eval(IInternalPushInterpreter interpreter) { 56 return this.Eval(interpreter.ExecStack, interpreter.IntegerStack);56 return Eval(interpreter.ExecStack, interpreter.IntegerStack); 57 57 } 58 58 } … … 61 61 public class CodeYankDuplicateExpression : YankDuplicateExpression<Expression> { 62 62 public override bool Eval(IInternalPushInterpreter interpreter) { 63 return this.Eval(interpreter.CodeStack, interpreter.IntegerStack);63 return Eval(interpreter.CodeStack, interpreter.IntegerStack); 64 64 } 65 65 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/YankExpressions.cs
r14875 r14908 27 27 public class IntegerYankExpression : YankExpression<long> { 28 28 public override bool Eval(IInternalPushInterpreter interpreter) { 29 return this.Eval(interpreter.IntegerStack, interpreter.IntegerStack);29 return Eval(interpreter.IntegerStack, interpreter.IntegerStack); 30 30 } 31 31 } … … 34 34 public class FloatYankExpression : YankExpression<double> { 35 35 public override bool Eval(IInternalPushInterpreter interpreter) { 36 return this.Eval(interpreter.FloatStack, interpreter.IntegerStack);36 return Eval(interpreter.FloatStack, interpreter.IntegerStack); 37 37 } 38 38 } … … 41 41 public class BooleanYankExpression : YankExpression<bool> { 42 42 public override bool Eval(IInternalPushInterpreter interpreter) { 43 return this.Eval(interpreter.BooleanStack, interpreter.IntegerStack);43 return Eval(interpreter.BooleanStack, interpreter.IntegerStack); 44 44 } 45 45 } … … 48 48 public class NameYankExpression : YankExpression<string> { 49 49 public override bool Eval(IInternalPushInterpreter interpreter) { 50 return this.Eval(interpreter.NameStack, interpreter.IntegerStack);50 return Eval(interpreter.NameStack, interpreter.IntegerStack); 51 51 } 52 52 } … … 55 55 public class ExecYankExpression : YankExpression<Expression> { 56 56 public override bool Eval(IInternalPushInterpreter interpreter) { 57 return this.Eval(interpreter.ExecStack, interpreter.IntegerStack);57 return Eval(interpreter.ExecStack, interpreter.IntegerStack); 58 58 } 59 59 } … … 62 62 public class CodeYankExpression : YankExpression<Expression> { 63 63 public override bool Eval(IInternalPushInterpreter interpreter) { 64 return this.Eval(interpreter.CodeStack, interpreter.IntegerStack);64 return Eval(interpreter.CodeStack, interpreter.IntegerStack); 65 65 } 66 66 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/PushInterpreter.cs
r14897 r14908 241 241 242 242 IsPaused = false; 243 this.Run();243 Run(); 244 244 } 245 245 … … 360 360 361 361 private Task InterpretAsync() { 362 currentTask = Task.Run(() => this.Run());362 currentTask = Task.Run(() => Run()); 363 363 364 364 return currentTask; -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/BenchmarkSuite/BenchmarkSuitePushSolutionView.cs
r14897 r14908 37 37 38 38 ~BenchmarkSuitePushSolutionView() { 39 this.interpreter.Dispose();39 interpreter.Dispose(); 40 40 } 41 41 42 42 private void InitEvents() { 43 this.exampleComboBox.SelectedIndexChanged += this.SelectedExampleIndexChanged;44 this.pushDebugger.OnReset += this.PushDebuggerReset;43 exampleComboBox.SelectedIndexChanged += SelectedExampleIndexChanged; 44 pushDebugger.OnReset += PushDebuggerReset; 45 45 } 46 46 47 47 private void PushDebuggerReset(object sender, IPushInterpreter interpreter) { 48 if ( this.exampleComboBox.SelectedIndex < 0) return;49 50 var example = Evaluator.Data.Examples[ this.exampleComboBox.SelectedIndex];48 if (exampleComboBox.SelectedIndex < 0) return; 49 50 var example = Evaluator.Data.Examples[exampleComboBox.SelectedIndex]; 51 51 52 52 interpreter.BooleanStack.Push(example.InputBoolean); … … 62 62 63 63 private void SelectedExampleIndexChanged(object sender, EventArgs e) { 64 this.pushDebugger.ResetDebugging();64 pushDebugger.ResetDebugging(); 65 65 } 66 66 … … 80 80 81 81 protected override void OnContentChanged() { 82 if ( this.Content == null) return;83 84 this.Name = "Push Solution";85 this.nameTextBox.Text = this.Name;86 87 this.pool = new PushInterpreterPool(this.Content.Config);88 89 if ( this.interpreter != null) {90 this.interpreter.Dispose();91 } 92 93 this.interpreter = this.pool.Create(this.Content.Random);94 this.UpdateExamples(Evaluator.Data);95 96 if ( this.exampleComboBox.SelectedIndex < 0) {97 this.exampleComboBox.SelectedIndex = 0; // Triggers ResetDebugging via event98 } 99 100 this.InitResultGrid();101 this.pushDebugger.Content = this.Content;82 if (Content == null) return; 83 84 Name = "Push Solution"; 85 nameTextBox.Text = Name; 86 87 pool = new PushInterpreterPool(Content.Config); 88 89 if (interpreter != null) { 90 interpreter.Dispose(); 91 } 92 93 interpreter = pool.Create(Content.Random); 94 UpdateExamples(Evaluator.Data); 95 96 if (exampleComboBox.SelectedIndex < 0) { 97 exampleComboBox.SelectedIndex = 0; // Triggers ResetDebugging via event 98 } 99 100 InitResultGrid(); 101 pushDebugger.Content = Content; 102 102 } 103 103 104 104 private void InitResultGrid() { 105 this.resultsDataGrid.Columns.Clear();106 this.resultsDataGrid.Rows.Clear();105 resultsDataGrid.Columns.Clear(); 106 resultsDataGrid.Rows.Clear(); 107 107 108 108 var cellTemplate = new DataGridViewTextBoxCell(); … … 118 118 119 119 column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; 120 this.resultsDataGrid.Columns.Add(column);120 resultsDataGrid.Columns.Add(column); 121 121 } 122 122 … … 139 139 outputColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; 140 140 141 this.resultsDataGrid.Columns.Add(estimatedOutputColumn);142 this.resultsDataGrid.Columns.Add(outputColumn);141 resultsDataGrid.Columns.Add(estimatedOutputColumn); 142 resultsDataGrid.Columns.Add(outputColumn); 143 143 } 144 144 … … 158 158 relativeDiffColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; 159 159 160 this.resultsDataGrid.Columns.Add(absoluteDiffColumn);161 this.resultsDataGrid.Columns.Add(relativeDiffColumn);162 163 using (var pushInterpreter = this.pool.Create(this.Content.Random)) {160 resultsDataGrid.Columns.Add(absoluteDiffColumn); 161 resultsDataGrid.Columns.Add(relativeDiffColumn); 162 163 using (var pushInterpreter = pool.Create(Content.Random)) { 164 164 for (var i = 0; i < data.Examples.Length; i++) { 165 165 var example = data.Examples[i]; … … 169 169 170 170 row.HeaderCell.Value = row.Index + 1; 171 row.CreateCells( this.resultsDataGrid);171 row.CreateCells(resultsDataGrid); 172 172 173 173 for (var j = 0; j < data.InputArgumentTypes.Length; j++) { … … 177 177 for (var j = 0; j < data.OutputArgumentTypes.Length; j++) { 178 178 row.Cells[data.InputArgumentTypes.Length + j * 2].Value = ViewHelper.StringifyOutput(data.OutputArgumentTypes[j], example, Separator); 179 row.Cells[data.InputArgumentTypes.Length + j * 2 + 1].Value = this.StringifyResult(data.OutputArgumentTypes[j], pushInterpreter, example, Separator);179 row.Cells[data.InputArgumentTypes.Length + j * 2 + 1].Value = StringifyResult(data.OutputArgumentTypes[j], pushInterpreter, example, Separator); 180 180 } 181 181 … … 183 183 row.Cells[data.TotalArgumentCount + 2].Value = relativeDiff + "%"; 184 184 185 this.resultsDataGrid.Rows.Add(row);185 resultsDataGrid.Rows.Add(row); 186 186 pushInterpreter.Reset(); 187 187 } … … 192 192 switch (type) { 193 193 case ExampleArgumentType.Integer: 194 case ExampleArgumentType.IntegerVector: return interpreter.IntegerStack.IsEmpty ? EmptySign : string.Join(valueSeparator, interpreter.IntegerStack.Peek( this.GetCount(interpreter.IntegerStack, example.OutputInteger)));194 case ExampleArgumentType.IntegerVector: return interpreter.IntegerStack.IsEmpty ? EmptySign : string.Join(valueSeparator, interpreter.IntegerStack.Peek(GetCount(interpreter.IntegerStack, example.OutputInteger))); 195 195 196 196 case ExampleArgumentType.Float: 197 case ExampleArgumentType.FloatVector: return interpreter.FloatStack.IsEmpty ? EmptySign : string.Join(valueSeparator, interpreter.FloatStack.Peek( this.GetCount(interpreter.FloatStack, example.OutputFloat)).Select(d => d.ToString(CultureInfo.CurrentUICulture)));197 case ExampleArgumentType.FloatVector: return interpreter.FloatStack.IsEmpty ? EmptySign : string.Join(valueSeparator, interpreter.FloatStack.Peek(GetCount(interpreter.FloatStack, example.OutputFloat)).Select(d => d.ToString(CultureInfo.CurrentUICulture))); 198 198 199 199 case ExampleArgumentType.Boolean: return interpreter.BooleanStack.IsEmpty ? EmptySign : interpreter.BooleanStack.Top.ToString(); … … 201 201 202 202 case ExampleArgumentType.String: 203 case ExampleArgumentType.StringVector: return interpreter.StringStack.IsEmpty ? EmptySign : string.Join(valueSeparator, interpreter.StringStack.Peek( this.GetCount(interpreter.StringStack, example.OutputString)));203 case ExampleArgumentType.StringVector: return interpreter.StringStack.IsEmpty ? EmptySign : string.Join(valueSeparator, interpreter.StringStack.Peek(GetCount(interpreter.StringStack, example.OutputString))); 204 204 default: return string.Empty; 205 205 } … … 211 211 212 212 private void UpdateExamples(ProblemData data) { 213 this.exampleComboBox.Items.Clear();213 exampleComboBox.Items.Clear(); 214 214 if (data == null) return; 215 215 … … 220 220 221 221 foreach (var str in stringRepresentations) { 222 this.exampleComboBox.Items.Add(str);222 exampleComboBox.Items.Add(str); 223 223 } 224 224 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/BenchmarkSuite/PushBenchmarkSuiteEvaluator.cs
r14907 r14908 69 69 70 70 public void LoadData(ProblemData data) { 71 this.Data = data;71 Data = data; 72 72 73 73 DataBounds.TrainingRange.Start = 0; -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/PushProblem.cs
r14897 r14908 72 72 73 73 private void EnabledExpressionsChanged(object sender, EnabledExpressionsChangedEventArgs e) { 74 this.Encoding.Bounds[0, 1] = config.EnabledExpressions.Count;75 this.Encoding.BoundsParameter.Value[0, 1] = config.EnabledExpressions.Count;74 Encoding.Bounds[0, 1] = config.EnabledExpressions.Count; 75 Encoding.BoundsParameter.Value[0, 1] = config.EnabledExpressions.Count; 76 76 } 77 77 … … 228 228 public IValueParameter<IntValue> MaxPointsInProgramParameter 229 229 { 230 get { return (IValueParameter<IntValue>) this.Parameters[MaxPointsInProgramParameterName]; }230 get { return (IValueParameter<IntValue>)Parameters[MaxPointsInProgramParameterName]; } 231 231 } 232 232 … … 250 250 public IValueParameter<IntValue> MinPointsInProgramParameter 251 251 { 252 get { return (IValueParameter<IntValue>) this.Parameters[MinPointsInProgramParameterName]; }252 get { return (IValueParameter<IntValue>)Parameters[MinPointsInProgramParameterName]; } 253 253 } 254 254 … … 287 287 public IValueParameter<BoolValue> TopLevelPushCodeParameter 288 288 { 289 get { return (IValueParameter<BoolValue>) this.Parameters[TopLevelPushCodeParameterName]; }289 get { return (IValueParameter<BoolValue>)Parameters[TopLevelPushCodeParameterName]; } 290 290 } 291 291 … … 305 305 public IValueParameter<BoolValue> TopLevelPopCodeParameter 306 306 { 307 get { return (IValueParameter<BoolValue>) this.Parameters[TopLevelPopCodeParameterName]; }307 get { return (IValueParameter<BoolValue>)Parameters[TopLevelPopCodeParameterName]; } 308 308 } 309 309 -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Selector/LexicaseSelector.cs
r14875 r14908 56 56 57 57 public LexicaseSelector() { 58 this.Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>(58 Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>( 59 59 PushProblem.CaseQualitiesScopeParameterName, 60 60 "The quality of every single training case for each individual.")); -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Stack/PushStack.cs
r14875 r14908 237 237 238 238 public bool Remove(T item) { 239 return this.data.Remove(item);239 return data.Remove(item); 240 240 } 241 241 … … 245 245 246 246 public void Remove(int count) { 247 this.data.RemoveRange(this.Count - count, count);247 data.RemoveRange(Count - count, count); 248 248 } 249 249
Note: See TracChangeset
for help on using the changeset viewer.