Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/29/17 18:05:17 (7 years ago)
Author:
pkimmesw
Message:

#2665 Fixed Integer Overflow Exceptions, Adjusted Offspring Selection Experiments

Location:
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/ExpressionsClassDiagramm.cd

    r15334 r15344  
    22<ClassDiagram MajorVersion="1" MinorVersion="1">
    33  <Class Name="HeuristicLab.Problems.ProgramSynthesis.Push.Expressions.Expression">
    4     <Position X="3" Y="0.5" Width="2" />
     4    <Position X="2.75" Y="0.5" Width="2" />
    55    <Members>
    66      <Method Name="Expression" Hidden="true" />
    7       <Method Name="IPooledObject.Init" Hidden="true" />
    87      <Method Name="IPooledObject.Reset" Hidden="true" />
    98    </Members>
    109    <TypeIdentifier>
    11       <HashCode>EAAAAAgAJAAAAAAMAAAAAAAAAAAAACAAAQAAAAAAABA=</HashCode>
     10      <HashCode>EAAAAAgAJAAAAAAEAAAAAAAAAAAAACAAAQAAAAAAABA=</HashCode>
    1211      <FileName>Push\Expressions\Expression.cs</FileName>
    1312    </TypeIdentifier>
     
    1514  </Class>
    1615  <Class Name="HeuristicLab.Problems.ProgramSynthesis.Push.Expressions.PushProgram">
    17     <Position X="0.5" Y="4.5" Width="2" />
     16    <Position X="0.5" Y="3.5" Width="2" />
    1817    <Compartments>
    1918      <Compartment Name="Fields" Collapsed="true" />
     
    2120    </Compartments>
    2221    <TypeIdentifier>
    23       <HashCode>AMtgMCECJAAABAAcgAYAAAQCQkABAeBgAQEIIgCAABo=</HashCode>
     22      <HashCode>AMtgMCECJAAABAAUgAYAAAQCQkABAeBgAQEIIgCAABo=</HashCode>
    2423      <FileName>Push\Expressions\PushProgram.cs</FileName>
    2524    </TypeIdentifier>
     
    2726  </Class>
    2827  <Class Name="HeuristicLab.Problems.ProgramSynthesis.Push.Expressions.StatefulExpression&lt;T&gt;">
    29     <Position X="2.75" Y="4.5" Width="2" />
     28    <Position X="2.75" Y="3.5" Width="2" />
    3029    <Compartments>
    3130      <Compartment Name="Fields" Collapsed="true" />
     
    3332    </Compartments>
    3433    <TypeIdentifier>
    35       <HashCode>AAggAAAAAACABAAIgAAAAAAAAAAAAKAAAAAABAAAAAA=</HashCode>
     34      <HashCode>AAggAAAAAACABAAAgAAAAAAAAAAAAKAAAAAABAAAAAA=</HashCode>
    3635      <FileName>Push\Expressions\StatefulExpression.cs</FileName>
    3736    </TypeIdentifier>
     
    3938  </Class>
    4039  <Class Name="HeuristicLab.Problems.ProgramSynthesis.Push.Expressions.StatelessExpression">
    41     <Position X="5" Y="4.5" Width="2" />
     40    <Position X="5" Y="3.5" Width="2" />
    4241    <Members>
    4342      <Field Name="hashCode" Hidden="true" />
     
    5150    </TypeIdentifier>
    5251  </Class>
    53   <Font Name="Segoe UI" Size="9" />
     52  <Font Name="Courier" Size="9" />
    5453</ClassDiagram>
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/HeuristicLab.Problems.ProgramSynthesis.csproj

    r15334 r15344  
    310310  </ItemGroup>
    311311  <ItemGroup>
    312     <None Include="ExpressionsClassDiagramm.cd" />
     312    <None Include="ExpressionsClassDiagramm.cd">
     313      <SubType>Designer</SubType>
     314    </None>
    313315    <None Include="packages.config" />
    314316  </ItemGroup>
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Configuration/PushConfiguration.cs

    r15341 r15344  
    4444    public PushConfiguration(PushConfiguration origin, Cloner cloner) : base(origin, cloner) {
    4545      Parameters = cloner.Clone(origin.Parameters);
     46      FloatStringFormat = origin.FloatStringFormat;
    4647    }
    4748
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Evaluator/PushBenchmarkSuiteEvaluator.cs

    r15341 r15344  
    560560      }
    561561
    562       return diff;
     562      return double.IsNaN(diff) || double.IsInfinity(diff)
     563         ? worstResult
     564         : diff;
    563565    }
    564566
     
    581583      }
    582584
    583       return diff;
     585      return double.IsNaN(diff) || double.IsInfinity(diff)
     586        ? worstResult
     587        : diff;
    584588    }
    585589  }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/EmptyExpression.cs

    r15334 r15344  
    11namespace HeuristicLab.Problems.ProgramSynthesis.Push.Expressions {
    2   using System.Collections.Generic;
    32
    43  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    1211  /// </summary>
    1312  [StorableClass]
    14   public abstract class EmptyExpression<T> : StatelessExpression {
     13  public abstract class EmptyExpression : StatelessExpression {
    1514    protected EmptyExpression() { }
    1615    [StorableConstructor]
     
    2120    }
    2221
    23     public void Eval(IPushStack<T> stack, IPushStack<bool> booleanStack) {
     22    public void Eval(IPushStack stack, IPushStack<bool> booleanStack) {
    2423      booleanStack.Push(stack.IsEmpty);
    2524    }
     
    3231    "Pushes TRUE onto the BOOLEAN stack if the EXEC stack is empty, otherwise FALSE.",
    3332    StackTypes.Boolean)]
    34   public class ExecEmptyExpression : EmptyExpression<Expression> {
     33  public class ExecEmptyExpression : EmptyExpression {
    3534    public ExecEmptyExpression() { }
    3635    [StorableConstructor]
     
    4847    "Pushes TRUE onto the BOOLEAN stack if the CODE stack is empty, otherwise FALSE.",
    4948    StackTypes.Boolean)]
    50   public class CodeEmptyExpression : EmptyExpression<Expression> {
     49  public class CodeEmptyExpression : EmptyExpression {
    5150    public CodeEmptyExpression() { }
    5251    [StorableConstructor]
     
    6362    "Pushes TRUE onto the BOOLEAN stack if the INTEGER stack is empty, otherwise FALSE.",
    6463    StackTypes.Boolean)]
    65   public class IntegerEmptyExpression : EmptyExpression<long> {
     64  public class IntegerEmptyExpression : EmptyExpression {
    6665    public IntegerEmptyExpression() { }
    6766    [StorableConstructor]
     
    7776    "FLOAT.EMPTY", "Pushes TRUE onto the BOOLEAN stack if the FLOAT stack is empty, otherwise FALSE.",
    7877    StackTypes.Boolean)]
    79   public class FloatEmptyExpression : EmptyExpression<double> {
     78  public class FloatEmptyExpression : EmptyExpression {
    8079    public FloatEmptyExpression() { }
    8180    [StorableConstructor]
     
    9190    "BOOLEAN.EMPTY",
    9291    "Pushes TRUE onto the BOOLEAN stack if the BOOLEAN stack is empty, otherwise FALSE.")]
    93   public class BooleanEmptyExpression : EmptyExpression<bool> {
     92  public class BooleanEmptyExpression : EmptyExpression {
    9493    public BooleanEmptyExpression() { }
    9594    [StorableConstructor]
     
    106105    "Pushes TRUE onto the BOOLEAN stack if the CHAR stack is empty, otherwise FALSE.",
    107106    StackTypes.Boolean)]
    108   public class CharEmptyExpression : EmptyExpression<char> {
     107  public class CharEmptyExpression : EmptyExpression {
    109108    public CharEmptyExpression() { }
    110109    [StorableConstructor]
     
    121120    "Pushes TRUE onto the BOOLEAN stack if the STRING stack is empty, otherwise FALSE.",
    122121    StackTypes.Boolean)]
    123   public class StringEmptyExpression : EmptyExpression<string> {
     122  public class StringEmptyExpression : EmptyExpression {
    124123    public StringEmptyExpression() { }
    125124    [StorableConstructor]
     
    136135    "Pushes TRUE onto the BOOLEAN stack if the INTEGER[] stack is empty, otherwise FALSE.",
    137136    StackTypes.Boolean)]
    138   public class IntegerVectorEmptyExpression : EmptyExpression<IReadOnlyList<long>> {
     137  public class IntegerVectorEmptyExpression : EmptyExpression {
    139138    public IntegerVectorEmptyExpression() { }
    140139    [StorableConstructor]
     
    151150    "Pushes TRUE onto the BOOLEAN stack if the FLOAT[] stack is empty, otherwise FALSE.",
    152151    StackTypes.Boolean)]
    153   public class FloatVectorEmptyExpression : EmptyExpression<IReadOnlyList<double>> {
     152  public class FloatVectorEmptyExpression : EmptyExpression {
    154153    public FloatVectorEmptyExpression() { }
    155154    [StorableConstructor]
     
    166165    "Pushes TRUE onto the BOOLEAN stack if the BOOLEAN[] stack is empty, otherwise FALSE.",
    167166    StackTypes.Boolean)]
    168   public class BooleanVectorEmptyExpression : EmptyExpression<IReadOnlyList<bool>> {
     167  public class BooleanVectorEmptyExpression : EmptyExpression {
    169168    public BooleanVectorEmptyExpression() { }
    170169    [StorableConstructor]
     
    181180    "Pushes TRUE onto the BOOLEAN stack if the STRING[] stack is empty, otherwise FALSE.",
    182181    StackTypes.Boolean)]
    183   public class StringVectorEmptyExpression : EmptyExpression<IReadOnlyList<string>> {
     182  public class StringVectorEmptyExpression : EmptyExpression {
    184183    public StringVectorEmptyExpression() { }
    185184    [StorableConstructor]
     
    189188    }
    190189  }
     190
     191  [StorableClass]
     192  [PushExpression(
     193  StackTypes.Print,
     194  "PRINT.EMPTY",
     195  "Pushes TRUE onto the BOOLEAN stack if the PRINT stack is empty, otherwise FALSE.",
     196  StackTypes.Boolean)]
     197  public class PrintEmptyExpression : EmptyExpression {
     198    public PrintEmptyExpression() { }
     199    [StorableConstructor]
     200    protected PrintEmptyExpression(bool deserializing) : base(deserializing) { }
     201    public override void Eval(IInternalPushInterpreter interpreter) {
     202      Eval(interpreter.PrintStack, interpreter.BooleanStack);
     203    }
     204  }
    191205}
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/Expression.cs

    r15334 r15344  
    1616    [StorableConstructor]
    1717    protected Expression(bool deserializing) { }
     18    protected Expression(Expression origin, Cloner cloner) { }
    1819
    1920    public bool IsProgram { get { return GetType() == typeof(PushProgram); } }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/IntegerExpressions.cs

    r15032 r15344  
    2828      var first = interpreter.IntegerStack.Pop();
    2929      var second = interpreter.IntegerStack.Top;
    30       var result = second + first;
     30      var result = unchecked(second + first);
    3131
    3232      interpreter.IntegerStack.Top = result;
     
    5454      var first = interpreter.IntegerStack.Pop();
    5555      var second = interpreter.IntegerStack.Top;
    56       var result = second - first;
     56      var result = unchecked(second - first);
    5757
    5858      interpreter.IntegerStack.Top = result;
     
    8080      var first = interpreter.IntegerStack.Pop();
    8181      var second = interpreter.IntegerStack.Top;
    82       var result = second * first;
     82      var result = unchecked(second * first);
    8383
    8484      interpreter.IntegerStack.Top = result;
     
    101101
    102102    public override bool IsNoop(IInternalPushInterpreter interpreter) {
    103       return interpreter.IntegerStack.Count < 2 || interpreter.IntegerStack.Top == 0;
     103      return interpreter.IntegerStack.Count < 2 ||
     104             interpreter.IntegerStack.Top == 0 ||
     105             (interpreter.IntegerStack.Top == -1 && interpreter.IntegerStack[1] == long.MinValue);
    104106    }
    105107
     
    127129
    128130    public override bool IsNoop(IInternalPushInterpreter interpreter) {
    129       return interpreter.IntegerStack.Count < 2 || interpreter.IntegerStack.Top == 0;
     131      return interpreter.IntegerStack.Count < 2 ||
     132             interpreter.IntegerStack.Top == 0 ||
     133             (interpreter.IntegerStack.Top == -1 && interpreter.IntegerStack[1] == long.MinValue);
    130134    }
    131135
     
    348352
    349353    public override void Eval(IInternalPushInterpreter interpreter) {
    350       var value = (long)(interpreter.FloatStack.Pop());
     354      var value = unchecked((long)interpreter.FloatStack.Pop());
    351355      interpreter.IntegerStack.Push(value);
    352356    }
     
    424428
    425429    public override void Eval(IInternalPushInterpreter interpreter) {
    426       interpreter.IntegerStack.Top += 1;
     430      var result = unchecked(interpreter.IntegerStack.Top + 1);
     431      interpreter.IntegerStack.Top = result;
    427432    }
    428433  }
     
    446451
    447452    public override void Eval(IInternalPushInterpreter interpreter) {
    448       interpreter.IntegerStack.Top -= 1;
     453      var result = unchecked(interpreter.IntegerStack.Top - 1);
     454      interpreter.IntegerStack.Top = result;
    449455    }
    450456  }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/PushProgram.cs

    r15334 r15344  
    5151      depth = origin.depth;
    5252      treeIndex = origin.treeIndex;
    53       expressions = new List<Expression>(origin.expressions);
     53
     54      var expressionsCopy = new List<Expression>(origin.expressions.Count);
     55      for (var i = 0; i < origin.expressions.Count; i++) {
     56        expressionsCopy.Add(cloner.Clone(origin.expressions[i]));
     57      }
     58
     59      expressions = expressionsCopy;
    5460    }
    5561
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/StatelessExpression.cs

    r15032 r15344  
    22  using System;
    33
     4  using HeuristicLab.Common;
    45  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    56
     
    1617    [StorableConstructor]
    1718    protected StatelessExpression(bool deserializing) : base(deserializing) { }
     19
     20    protected StatelessExpression(StatelessExpression origin, Cloner cloner) : base(origin, cloner) { }
    1821
    1922    public override int GetHashCode() {
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/BenchmarkSuite/IntegerVectorPushBenchmarkSuiteProblem.cs

    r15334 r15344  
    4848      PushEvaluator.LoadData(data);
    4949
    50       Name = "Push Problem: " + data.Name;
     50      Name = "[Push][IntVector] " + data.Name;
    5151      Description = data.Description;
    5252      BestKnownQuality = data.BestResult;
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/BenchmarkSuite/PlushPushBenchmarkSuiteProblem.cs

    r15334 r15344  
    4545      PushEvaluator.LoadData(data);
    4646
    47       Name = "Push Problem: " + data.Name;
     47      Name = "[Push][Plush] " + data.Name;
    4848      Description = data.Description;
    4949      BestKnownQuality = data.BestResult;
Note: See TracChangeset for help on using the changeset viewer.