Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/11/11 15:03:46 (14 years ago)
Author:
gkronber
Message:

Merged changes from trunk to data analysis exploration branch and added fractional distance metric evaluator. #1142

Location:
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/ArithmeticExpressionGrammar.cs

    r4341 r5275  
    2121
    2222using System.Collections.Generic;
     23using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    3031  [Item("ArithmeticExpressionGrammar", "Represents a grammar for functional expressions using only arithmetic operations.")]
    3132  public class ArithmeticExpressionGrammar : DefaultSymbolicExpressionGrammar {
     33
     34    [StorableConstructor]
     35    protected ArithmeticExpressionGrammar(bool deserializing) : base(deserializing) { }
     36    protected ArithmeticExpressionGrammar(ArithmeticExpressionGrammar original, Cloner cloner) : base(original, cloner) { }
    3237    public ArithmeticExpressionGrammar()
    3338      : base() {
    3439      Initialize();
    3540    }
    36 
    37     [StorableConstructor]
    38     protected ArithmeticExpressionGrammar(bool deserializing) : base(deserializing) { }
     41    public override IDeepCloneable Clone(Cloner cloner) {
     42      return new ArithmeticExpressionGrammar(this, cloner);
     43    }
    3944
    4045    private void Initialize() {
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/BasicExpressionGrammar.cs

    r4193 r5275  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
     28using HeuristicLab.Common;
    2829namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    2930  [StorableClass]
     
    3334    private HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols.Variable variableSymbol;
    3435
     36    [StorableConstructor]
     37    protected BasicExpressionGrammar(bool deserializing) : base(deserializing) { }
     38    protected BasicExpressionGrammar(BasicExpressionGrammar original, Cloner cloner)
     39      : base(original, cloner) {
     40      foreach (var symb in Symbols) {
     41        var varSym = symb as HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols.Variable;
     42        if (varSym != null) this.variableSymbol = varSym;
     43        break;
     44      }
     45    }
    3546    public BasicExpressionGrammar()
    3647      : base() {
     
    3849    }
    3950
    40     [StorableConstructor]
    41     protected BasicExpressionGrammar(bool deserializing) : base(deserializing) { }
     51    public override IDeepCloneable Clone(Cloner cloner) {
     52      return new BasicExpressionGrammar(this, cloner);
     53    }
    4254
    4355    private void Initialize() {
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/FullFunctionalExpressionGrammar.cs

    r4341 r5275  
    2121
    2222using System.Collections.Generic;
     23using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    3031  [Item("FullFunctionalExpressionGrammar", "Represents a grammar for functional expressions using all available functions.")]
    3132  public class FullFunctionalExpressionGrammar : DefaultSymbolicExpressionGrammar {
     33    [StorableConstructor]
     34    protected FullFunctionalExpressionGrammar(bool deserializing) : base(deserializing) { }
     35    protected FullFunctionalExpressionGrammar(FullFunctionalExpressionGrammar original, Cloner cloner) : base(original, cloner) { }
    3236    public FullFunctionalExpressionGrammar()
    3337      : base() {
    3438      Initialize();
    3539    }
    36     [StorableConstructor]
    37     protected FullFunctionalExpressionGrammar(bool deserializing) : base(deserializing) { }
     40
     41    public override IDeepCloneable Clone(Cloner cloner) {
     42      return new FullFunctionalExpressionGrammar(this, cloner);
     43    }
    3844
    3945    private void Initialize() {
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionInterpreter.cs

    r4193 r5275  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    3233  [StorableClass]
    3334  [Item("SimpleArithmeticExpressionInterpreter", "Interpreter for arithmetic symbolic expression trees including function calls.")]
    34   // not thread safe!
    35   public class SimpleArithmeticExpressionInterpreter : NamedItem, ISymbolicExpressionTreeInterpreter {
     35  public sealed class SimpleArithmeticExpressionInterpreter : NamedItem, ISymbolicExpressionTreeInterpreter {
    3636    private class OpCodes {
    3737      public const byte Add = 1;
     
    6565      public const byte Constant = 20;
    6666      public const byte Arg = 21;
    67       public const byte Differential = 22;
    6867    }
    6968
     
    9089      { typeof(Constant), OpCodes.Constant },
    9190      { typeof(Argument), OpCodes.Arg },
    92       { typeof(DifferentialVariable), OpCodes.Differential},
    9391    };
    9492    private const int ARGUMENT_STACK_SIZE = 1024;
    9593
    96     private Dataset dataset;
    97     private int row;
    98     private Instruction[] code;
    99     private int pc;
    100     private double[] argumentStack = new double[ARGUMENT_STACK_SIZE];
    101     private int argStackPointer;
    102 
    10394    public override bool CanChangeName {
    10495      get { return false; }
     
    10899    }
    109100
     101    [StorableConstructor]
     102    private SimpleArithmeticExpressionInterpreter(bool deserializing) : base(deserializing) { }
     103    private SimpleArithmeticExpressionInterpreter(SimpleArithmeticExpressionInterpreter original, Cloner cloner) : base(original, cloner) { }
     104    public override IDeepCloneable Clone(Cloner cloner) {
     105      return new SimpleArithmeticExpressionInterpreter(this, cloner);
     106    }
     107
    110108    public SimpleArithmeticExpressionInterpreter()
    111109      : base() {
     
    113111
    114112    public IEnumerable<double> GetSymbolicExpressionTreeValues(SymbolicExpressionTree tree, Dataset dataset, IEnumerable<int> rows) {
    115       this.dataset = dataset;
    116113      var compiler = new SymbolicExpressionTreeCompiler();
    117       compiler.AddInstructionPostProcessingHook(PostProcessInstruction);
    118       code = compiler.Compile(tree, MapSymbolToOpCode);
    119       foreach (var row in rows) {
    120         this.row = row;
    121         pc = 0;
    122         argStackPointer = 0;
    123         yield return Evaluate();
    124       }
    125     }
    126 
    127     private Instruction PostProcessInstruction(Instruction instr) {
    128       if (instr.opCode == OpCodes.Variable) {
    129         var variableTreeNode = instr.dynamicNode as VariableTreeNode;
    130         instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
    131       } else if (instr.opCode == OpCodes.LagVariable) {
    132         var variableTreeNode = instr.dynamicNode as LaggedVariableTreeNode;
    133         instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
    134       } else if (instr.opCode == OpCodes.Differential) {
    135         var variableTreeNode = instr.dynamicNode as DifferentialVariableTreeNode;
    136         instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
    137       }
    138       return instr;
     114      Instruction[] code = compiler.Compile(tree, MapSymbolToOpCode);
     115
     116      for (int i = 0; i < code.Length; i++) {
     117        Instruction instr = code[i];
     118        if (instr.opCode == OpCodes.Variable) {
     119          var variableTreeNode = instr.dynamicNode as VariableTreeNode;
     120          instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
     121          code[i] = instr;
     122        } else if (instr.opCode == OpCodes.LagVariable) {
     123          var variableTreeNode = instr.dynamicNode as LaggedVariableTreeNode;
     124          instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
     125          code[i] = instr;
     126        }
     127      }
     128
     129      double[] argumentStack = new double[ARGUMENT_STACK_SIZE];
     130      foreach (var rowEnum in rows) {
     131        int row = rowEnum;
     132        int pc = 0;
     133        int argStackPointer = 0;
     134        yield return Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     135      }
     136    }
     137
     138    private double Evaluate(Dataset dataset, ref int row, Instruction[] code, ref int pc, double[] argumentStack, ref int argStackPointer) {
     139      Instruction currentInstr = code[pc++];
     140      switch (currentInstr.opCode) {
     141        case OpCodes.Add: {
     142            double s = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     143            for (int i = 1; i < currentInstr.nArguments; i++) {
     144              s += Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     145            }
     146            return s;
     147          }
     148        case OpCodes.Sub: {
     149            double s = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     150            for (int i = 1; i < currentInstr.nArguments; i++) {
     151              s -= Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     152            }
     153            if (currentInstr.nArguments == 1) s = -s;
     154            return s;
     155          }
     156        case OpCodes.Mul: {
     157            double p = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     158            for (int i = 1; i < currentInstr.nArguments; i++) {
     159              p *= Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     160            }
     161            return p;
     162          }
     163        case OpCodes.Div: {
     164            double p = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     165            for (int i = 1; i < currentInstr.nArguments; i++) {
     166              p /= Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     167            }
     168            if (currentInstr.nArguments == 1) p = 1.0 / p;
     169            return p;
     170          }
     171        case OpCodes.Average: {
     172            double sum = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     173            for (int i = 1; i < currentInstr.nArguments; i++) {
     174              sum += Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     175            }
     176            return sum / currentInstr.nArguments;
     177          }
     178        case OpCodes.Cos: {
     179            return Math.Cos(Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer));
     180          }
     181        case OpCodes.Sin: {
     182            return Math.Sin(Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer));
     183          }
     184        case OpCodes.Tan: {
     185            return Math.Tan(Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer));
     186          }
     187        case OpCodes.Exp: {
     188            return Math.Exp(Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer));
     189          }
     190        case OpCodes.Log: {
     191            return Math.Log(Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer));
     192          }
     193        case OpCodes.IfThenElse: {
     194            double condition = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     195            double result;
     196            if (condition > 0.0) {
     197              result = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer); SkipBakedCode(code, ref pc);
     198            } else {
     199              SkipBakedCode(code, ref pc); result = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     200            }
     201            return result;
     202          }
     203        case OpCodes.AND: {
     204            double result = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     205            for (int i = 1; i < currentInstr.nArguments; i++) {
     206              if (result <= 0.0) SkipBakedCode(code, ref pc);
     207              else {
     208                result = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     209              }
     210            }
     211            return result <= 0.0 ? -1.0 : 1.0;
     212          }
     213        case OpCodes.OR: {
     214            double result = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     215            for (int i = 1; i < currentInstr.nArguments; i++) {
     216              if (result > 0.0) SkipBakedCode(code, ref pc);
     217              else {
     218                result = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     219              }
     220            }
     221            return result > 0.0 ? 1.0 : -1.0;
     222          }
     223        case OpCodes.NOT: {
     224            return -Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     225          }
     226        case OpCodes.GT: {
     227            double x = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     228            double y = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     229            if (x > y) return 1.0;
     230            else return -1.0;
     231          }
     232        case OpCodes.LT: {
     233            double x = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     234            double y = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     235            if (x < y) return 1.0;
     236            else return -1.0;
     237          }
     238        case OpCodes.Call: {
     239            // evaluate sub-trees
     240            // push on argStack in reverse order
     241            for (int i = 0; i < currentInstr.nArguments; i++) {
     242              argumentStack[argStackPointer + currentInstr.nArguments - i] = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     243            }
     244            argStackPointer += currentInstr.nArguments;
     245
     246            // save the pc
     247            int nextPc = pc;
     248            // set pc to start of function 
     249            pc = currentInstr.iArg0;
     250            // evaluate the function
     251            double v = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     252
     253            // decrease the argument stack pointer by the number of arguments pushed
     254            // to set the argStackPointer back to the original location
     255            argStackPointer -= currentInstr.nArguments;
     256
     257            // restore the pc => evaluation will continue at point after my subtrees 
     258            pc = nextPc;
     259            return v;
     260          }
     261        case OpCodes.Arg: {
     262            return argumentStack[argStackPointer - currentInstr.iArg0];
     263          }
     264        case OpCodes.Variable: {
     265            var variableTreeNode = currentInstr.dynamicNode as VariableTreeNode;
     266            return dataset[row, currentInstr.iArg0] * variableTreeNode.Weight;
     267          }
     268        case OpCodes.LagVariable: {
     269            var laggedVariableTreeNode = currentInstr.dynamicNode as LaggedVariableTreeNode;
     270            int actualRow = row + laggedVariableTreeNode.Lag;
     271            if (actualRow < 0 || actualRow >= dataset.Rows) throw new ArgumentException("Out of range access to dataset row: " + row);
     272            return dataset[actualRow, currentInstr.iArg0] * laggedVariableTreeNode.Weight;
     273          }
     274        case OpCodes.Constant: {
     275            var constTreeNode = currentInstr.dynamicNode as ConstantTreeNode;
     276            return constTreeNode.Value;
     277          }
     278        default: throw new NotSupportedException();
     279      }
    139280    }
    140281
     
    146287    }
    147288
    148     private double Evaluate() {
    149       Instruction currentInstr = code[pc++];
    150       switch (currentInstr.opCode) {
    151         case OpCodes.Add: {
    152             double s = Evaluate();
    153             for (int i = 1; i < currentInstr.nArguments; i++) {
    154               s += Evaluate();
    155             }
    156             return s;
    157           }
    158         case OpCodes.Sub: {
    159             double s = Evaluate();
    160             for (int i = 1; i < currentInstr.nArguments; i++) {
    161               s -= Evaluate();
    162             }
    163             if (currentInstr.nArguments == 1) s = -s;
    164             return s;
    165           }
    166         case OpCodes.Mul: {
    167             double p = Evaluate();
    168             for (int i = 1; i < currentInstr.nArguments; i++) {
    169               p *= Evaluate();
    170             }
    171             return p;
    172           }
    173         case OpCodes.Div: {
    174             double p = Evaluate();
    175             for (int i = 1; i < currentInstr.nArguments; i++) {
    176               p /= Evaluate();
    177             }
    178             if (currentInstr.nArguments == 1) p = 1.0 / p;
    179             return p;
    180           }
    181         case OpCodes.Average: {
    182             double sum = Evaluate();
    183             for (int i = 1; i < currentInstr.nArguments; i++) {
    184               sum += Evaluate();
    185             }
    186             return sum / currentInstr.nArguments;
    187           }
    188         case OpCodes.Cos: {
    189             return Math.Cos(Evaluate());
    190           }
    191         case OpCodes.Sin: {
    192             return Math.Sin(Evaluate());
    193           }
    194         case OpCodes.Tan: {
    195             return Math.Tan(Evaluate());
    196           }
    197         case OpCodes.Exp: {
    198             return Math.Exp(Evaluate());
    199           }
    200         case OpCodes.Log: {
    201             return Math.Log(Evaluate());
    202           }
    203         case OpCodes.IfThenElse: {
    204             double condition = Evaluate();
    205             double result;
    206             if (condition > 0.0) {
    207               result = Evaluate(); SkipBakedCode();
    208             } else {
    209               SkipBakedCode(); result = Evaluate();
    210             }
    211             return result;
    212           }
    213         case OpCodes.AND: {
    214             double result = Evaluate();
    215             for (int i = 1; i < currentInstr.nArguments; i++) {
    216               if (result <= 0.0) SkipBakedCode();
    217               else {
    218                 result = Evaluate();
    219               }
    220             }
    221             return result <= 0.0 ? -1.0 : 1.0;
    222           }
    223         case OpCodes.OR: {
    224             double result = Evaluate();
    225             for (int i = 1; i < currentInstr.nArguments; i++) {
    226               if (result > 0.0) SkipBakedCode();
    227               else {
    228                 result = Evaluate();
    229               }
    230             }
    231             return result > 0.0 ? 1.0 : -1.0;
    232           }
    233         case OpCodes.NOT: {
    234             return -Evaluate();
    235           }
    236         case OpCodes.GT: {
    237             double x = Evaluate();
    238             double y = Evaluate();
    239             if (x > y) return 1.0;
    240             else return -1.0;
    241           }
    242         case OpCodes.LT: {
    243             double x = Evaluate();
    244             double y = Evaluate();
    245             if (x < y) return 1.0;
    246             else return -1.0;
    247           }
    248         case OpCodes.Call: {
    249             // evaluate sub-trees
    250             // push on argStack in reverse order
    251             for (int i = 0; i < currentInstr.nArguments; i++) {
    252               argumentStack[argStackPointer + currentInstr.nArguments - i] = Evaluate();
    253             }
    254             argStackPointer += currentInstr.nArguments;
    255 
    256             // save the pc
    257             int nextPc = pc;
    258             // set pc to start of function 
    259             pc = currentInstr.iArg0;
    260             // evaluate the function
    261             double v = Evaluate();
    262 
    263             // decrease the argument stack pointer by the number of arguments pushed
    264             // to set the argStackPointer back to the original location
    265             argStackPointer -= currentInstr.nArguments;
    266 
    267             // restore the pc => evaluation will continue at point after my subtrees 
    268             pc = nextPc;
    269             return v;
    270           }
    271         case OpCodes.Arg: {
    272             return argumentStack[argStackPointer - currentInstr.iArg0];
    273           }
    274         case OpCodes.Variable: {
    275             var variableTreeNode = currentInstr.dynamicNode as VariableTreeNode;
    276             return dataset[row, currentInstr.iArg0] * variableTreeNode.Weight;
    277           }
    278         case OpCodes.LagVariable: {
    279             var lagVariableTreeNode = currentInstr.dynamicNode as LaggedVariableTreeNode;
    280             int actualRow = row + lagVariableTreeNode.Lag;
    281             if (actualRow < 0 || actualRow >= dataset.Rows) throw new ArgumentException("Out of range access to dataset row: " + row);
    282             return dataset[actualRow, currentInstr.iArg0] * lagVariableTreeNode.Weight;
    283           }
    284         case OpCodes.Differential: {
    285             var diffTreeNode = currentInstr.dynamicNode as DifferentialVariableTreeNode;
    286             if (row < 2 || row >= dataset.Rows - 2) throw new ArgumentException("Out of range access to dataset row: " + row);
    287             return (-dataset[row + 2, currentInstr.iArg0] + 8 * dataset[row + 1, currentInstr.iArg0] - 8 * dataset[row - 1, currentInstr.iArg0] + dataset[row - 2, currentInstr.iArg0]) * (1.0/12.0) * diffTreeNode.Weight;
    288           }
    289 
    290         case OpCodes.Constant: {
    291             var constTreeNode = currentInstr.dynamicNode as ConstantTreeNode;
    292             return constTreeNode.Value;
    293           }
    294         default: throw new NotSupportedException();
    295       }
    296     }
    297 
    298289    // skips a whole branch
    299     protected void SkipBakedCode() {
     290    private void SkipBakedCode(Instruction[] code, ref int pc) {
    300291      int i = 1;
    301292      while (i > 0) {
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SymbolicSimplifier.cs

    r4554 r5275  
    354354      while (sum.SubTrees.Count > 0) sum.RemoveSubTree(0);
    355355      var groupedVarNodes = from node in subtrees.OfType<VariableTreeNode>()
    356                             where node.Symbol.Name == "Variable"
    357356                            group node by node.VariableName into g
    358357                            select g;
    359       var unchangedSubTrees = subtrees.Where(t => t.Symbol.Name != "Variable");
     358      var unchangedSubTrees = subtrees.Where(t => !(t is VariableTreeNode));
    360359
    361360      foreach (var variableNodeGroup in groupedVarNodes) {
     
    430429      while (prod.SubTrees.Count > 0) prod.RemoveSubTree(0);
    431430      var groupedVarNodes = from node in subtrees.OfType<VariableTreeNode>()
    432                             where node.Symbol.Name == "Variable"
    433431                            group node by node.VariableName into g
    434432                            orderby g.Count()
    435433                            select g;
    436434      var constantProduct = (from node in subtrees.OfType<VariableTreeNode>()
    437                              where node.Symbol.Name == "Variable"
    438435                             select node.Weight)
    439436                            .Concat(from node in subtrees.OfType<ConstantTreeNode>()
     
    443440
    444441      var unchangedSubTrees = from tree in subtrees
    445                               where !(tree is VariableTreeNode && tree.Symbol.Name == "Variable")
     442                              where !(tree is VariableTreeNode)
    446443                              where !(tree is ConstantTreeNode)
    447444                              select tree;
     
    485482      } else if (IsAddition(x)) {
    486483        // (x0 + x1 + .. + xn) * -1 => (-x0 + -x1 + .. + -xn)       
    487         foreach (var subTree in x.SubTrees) {
    488           Negate(subTree);
    489         }
     484        for (int i = 0; i < x.SubTrees.Count; i++)
     485          x.SubTrees[i] = Negate(x.SubTrees[i]);
    490486      } else if (IsMultiplication(x) || IsDivision(x)) {
    491487        // x0 * x1 * .. * xn * -1 => x0 * x1 * .. * -xn
    492         Negate(x.SubTrees.Last()); // last is maybe a constant, prefer to negate the constant
     488        x.SubTrees[x.SubTrees.Count - 1] = Negate(x.SubTrees.Last()); // last is maybe a constant, prefer to negate the constant
    493489      } else {
    494490        // any other function
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Addition.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Addition", "Symbol that represents the + operator.")]
    2829  public sealed class Addition : Symbol {
     30    [StorableConstructor]
     31    private Addition(bool deserializing) : base(deserializing) { }
     32    private Addition(Addition original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Addition(this, cloner);
     35    }
    2936    public Addition() : base("Addition", "Symbol that represents the + operator.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/And.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("And", "Symbol that represents the boolean AND operator.")]
    2829  public sealed class And : Symbol {
     30    [StorableConstructor]
     31    private And(bool deserializing) : base(deserializing) { }
     32    private And(And original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new And(this, cloner);
     35    }
    2936    public And() : base("And", "Symbol that represents the boolean AND operator.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Average.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Average", "Symbol that represents the average (arithmetic mean) function.")]
    2829  public sealed class Average : Symbol {
     30    [StorableConstructor]
     31    private Average(bool deserializing) : base(deserializing) { }
     32    private Average(Average original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Average(this, cloner);
     35    }
    2936    public Average() : base("Average", "Symbol that represents the average (arithmetic mean) function.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Constant.cs

    r4068 r5275  
    5454    }
    5555    [Storable]
    56     private double manipulatorNu;
    57     public double ManipulatorNu {
    58       get { return manipulatorNu; }
     56    private double manipulatorMu;
     57    public double ManipulatorMu {
     58      get { return manipulatorMu; }
    5959      set {
    60         if (value != manipulatorNu) {
    61           manipulatorNu = value;
     60        if (value != manipulatorMu) {
     61          manipulatorMu = value;
    6262          OnChanged(EventArgs.Empty);
    6363        }
     
    7777    }
    7878    #endregion
     79    [StorableConstructor]
     80    private Constant(bool deserializing) : base(deserializing) { }
     81    private Constant(Constant original, Cloner cloner)
     82      : base(original, cloner) {
     83      minValue = original.minValue;
     84      maxValue = original.maxValue;
     85      manipulatorMu = original.manipulatorMu;
     86      manipulatorSigma = original.manipulatorSigma;
     87    }
    7988    public Constant()
    8089      : base("Constant", "Represents a constant value.") {
    81       manipulatorNu = 0.0;
     90      manipulatorMu = 0.0;
    8291      manipulatorSigma = 1.0;
    8392      minValue = -20.0;
     
    9099
    91100    public override IDeepCloneable Clone(Cloner cloner) {
    92       Constant clone = (Constant)base.Clone(cloner);
    93       clone.minValue = minValue;
    94       clone.maxValue = maxValue;
    95       clone.manipulatorNu = manipulatorNu;
    96       clone.manipulatorSigma = manipulatorSigma;
    97       return clone;
     101      return new Constant(this, cloner);
    98102    }
    99103  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/ConstantTreeNode.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    3839    }
    3940
    40     private ConstantTreeNode() : base() { }
     41    [StorableConstructor]
     42    private ConstantTreeNode(bool deserializing) : base(deserializing) { }
    4143
    42     // copy constructor
    43     private ConstantTreeNode(ConstantTreeNode original)
    44       : base(original) {
     44    private ConstantTreeNode(ConstantTreeNode original, Cloner cloner)
     45      : base(original, cloner) {
    4546      constantValue = original.constantValue;
    4647    }
    4748
     49    private ConstantTreeNode() : base() { }
    4850    public ConstantTreeNode(Constant constantSymbol) : base(constantSymbol) { }
    4951
     
    6163    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
    6264      base.ShakeLocalParameters(random, shakingFactor);
    63       double x = NormalDistributedRandom.NextDouble(random, Symbol.ManipulatorNu, Symbol.ManipulatorSigma);
     65      double x = NormalDistributedRandom.NextDouble(random, Symbol.ManipulatorMu, Symbol.ManipulatorSigma);
    6466      Value = Value + x * shakingFactor;
    6567    }
    6668
    67     public override object Clone() {
    68       return new ConstantTreeNode(this);
     69    public override IDeepCloneable Clone(Cloner cloner) {
     70      return new ConstantTreeNode(this, cloner);
    6971    }
    7072
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Cosine.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Cosine", "Symbol that represents the cosine function.")]
    2829  public sealed class Cosine : Symbol {
     30    [StorableConstructor]
     31    private Cosine(bool deserializing) : base(deserializing) { }
     32    private Cosine(Cosine original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Cosine(this, cloner);
     35    }
    2936    public Cosine() : base("Cosine", "Symbol that represents the cosine function.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/DifferentialVariable.cs

    r4193 r5275  
    2828  [Item("DifferentialVariable", "Represents the differential of a variable value.")]
    2929  public sealed class DifferentialVariable : Variable {
     30    [StorableConstructor]
     31    private DifferentialVariable(bool deserializing) : base(deserializing) { }
     32    private DifferentialVariable(DifferentialVariable original, Cloner cloner)
     33      : base(original, cloner) {
     34    }
    3035    public DifferentialVariable()
    3136      : base("DifferentialVariable", "Represents the differential of a variable value.") {
     
    3540      return new DifferentialVariableTreeNode(this);
    3641    }
    37 
    3842    public override IDeepCloneable Clone(Cloner cloner) {
    39       DifferentialVariable clone = (DifferentialVariable)base.Clone(cloner);
    40       return clone;
     43      return new DifferentialVariable(this, cloner);
    4144    }
    4245  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/DifferentialVariableTreeNode.cs

    r4193 r5275  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Common;
    2526namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols {
    2627  [StorableClass]
     
    3031    }
    3132
     33    [StorableConstructor]
     34    protected DifferentialVariableTreeNode(bool deserializing) : base(deserializing) { }
     35    protected DifferentialVariableTreeNode(DifferentialVariableTreeNode original, Cloner cloner)
     36      : base(original, cloner) {
     37    }
    3238    private DifferentialVariableTreeNode() { }
    33 
    34     // copy constructor
    35     private DifferentialVariableTreeNode(DifferentialVariableTreeNode original)
    36       : base(original) {
    37     }
    3839
    3940    public DifferentialVariableTreeNode(DifferentialVariable differentialSymbol) : base(differentialSymbol) { }
    4041
    4142
    42     public override object Clone() {
    43       return new DifferentialVariableTreeNode(this);
     43    public override IDeepCloneable Clone(Cloner cloner) {
     44      return new DifferentialVariableTreeNode(this, cloner);
    4445    }
    45 
    4646  }
    4747}
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Division.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Division", "Symbol that represents the / operator.")]
    2829  public sealed class Division : Symbol {
     30    [StorableConstructor]
     31    private Division(bool deserializing) : base(deserializing) { }
     32    private Division(Division original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Division(this, cloner);
     35    }
    2936    public Division() : base("Division", "Symbol that represents the / operator.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Exponential.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Exponential", "Symbol that represents the exponential function.")]
    2829  public sealed class Exponential : Symbol {
     30    [StorableConstructor]
     31    private Exponential(bool deserializing) : base(deserializing) { }
     32    private Exponential(Exponential original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Exponential(this, cloner);
     35    }
    2936    public Exponential() : base("Exponential", "Symbol that represents the exponential function.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/GreaterThan.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("GreaterThan", "Symbol that represents a greater than relation.")]
    2829  public sealed class GreaterThan : Symbol {
     30    [StorableConstructor]
     31    private GreaterThan(bool deserializing) : base(deserializing) { }
     32    private GreaterThan(GreaterThan original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new GreaterThan(this, cloner);
     35    }
    2936    public GreaterThan() : base("GreaterThan", "Symbol that represents a greater than relation.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/IfThenElse.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("IfThenElse", "Symbol that represents a conditional operator.")]
    2829  public sealed class IfThenElse : Symbol {
     30    [StorableConstructor]
     31    private IfThenElse(bool deserializing) : base(deserializing) { }
     32    private IfThenElse(IfThenElse original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new IfThenElse(this, cloner);
     35    }
    2936    public IfThenElse() : base("IfThenElse", "Symbol that represents a conditional operator.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/LaggedVariable.cs

    r4068 r5275  
    4040      set { maxLag = value; }
    4141    }
     42    [StorableConstructor]
     43    private LaggedVariable(bool deserializing) : base(deserializing) { }
     44    private LaggedVariable(LaggedVariable original, Cloner cloner)
     45      : base(original, cloner) {
     46      minLag = original.minLag;
     47      maxLag = original.maxLag;
     48    }
    4249    public LaggedVariable()
    4350      : base("LaggedVariable", "Represents a variable value with a time offset.") {
     
    5057
    5158    public override IDeepCloneable Clone(Cloner cloner) {
    52       LaggedVariable clone = (LaggedVariable)base.Clone(cloner);
    53       clone.minLag = minLag;
    54       clone.maxLag = maxLag;
    55       return clone;
     59      return new LaggedVariable(this, cloner);
    5660    }
    5761  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/LaggedVariableTreeNode.cs

    r4068 r5275  
    2121
    2222using System;
     23using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3637    }
    3738
    38     private LaggedVariableTreeNode() { }
    39 
    40     // copy constructor
    41     private LaggedVariableTreeNode(LaggedVariableTreeNode original)
    42       : base(original) {
     39    [StorableConstructor]
     40    private LaggedVariableTreeNode(bool deserializing) : base(deserializing) { }
     41    private LaggedVariableTreeNode(LaggedVariableTreeNode original, Cloner cloner)
     42      : base(original, cloner) {
    4343      lag = original.lag;
    4444    }
     45    private LaggedVariableTreeNode() { }
    4546
    4647    public LaggedVariableTreeNode(LaggedVariable variableSymbol) : base(variableSymbol) { }
     
    6263    }
    6364
    64 
    65     public override object Clone() {
    66       return new LaggedVariableTreeNode(this);
     65    public override IDeepCloneable Clone(Cloner cloner) {
     66      return new LaggedVariableTreeNode(this, cloner);
    6767    }
    6868
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/LessThan.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("LessThan", "Symbol that represents a less than relation.")]
    2829  public sealed class LessThan : Symbol {
     30    [StorableConstructor]
     31    private LessThan(bool deserializing) : base(deserializing) { }
     32    private LessThan(LessThan original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new LessThan(this, cloner);
     35    }
    2936    public LessThan() : base("LessThan", "Symbol that represents a less than relation.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Logarithm.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Logarithm", "Symbol that represents the logarithm function.")]
    2829  public sealed class Logarithm : Symbol {
     30    [StorableConstructor]
     31    private Logarithm(bool deserializing) : base(deserializing) { }
     32    private Logarithm(Logarithm original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Logarithm(this, cloner);
     35    }
    2936    public Logarithm() : base("Logarithm", "Symbol that represents the logarithm function.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Multiplication.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Multiplication", "Symbol that represents the * operator.")]
    2829  public sealed class Multiplication : Symbol {
     30    [StorableConstructor]
     31    private Multiplication(bool deserializing) : base(deserializing) { }
     32    private Multiplication(Multiplication original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Multiplication(this, cloner);
     35    }
    2936    public Multiplication() : base("Multiplication", "Symbol that represents the * operator.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Not.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Not", "Symbol that represents the boolean NOT operator.")]
    2829  public sealed class Not : Symbol {
     30    [StorableConstructor]
     31    private Not(bool deserializing) : base(deserializing) { }
     32    private Not(Not original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Not(this, cloner);
     35    }
    2936    public Not() : base("Not", "Symbol that represents the boolean NOT operator.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Or.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Or", "Symbol that represents the boolean OR operator.")]
    2829  public sealed class Or : Symbol {
     30    [StorableConstructor]
     31    private Or(bool deserializing) : base(deserializing) { }
     32    private Or(Or original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Or(this, cloner);
     35    }
    2936    public Or() : base("Or", "Symbol that represents the boolean OR operator.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Sine.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Sine", "Symbol that represents the sine function.")]
    2829  public sealed class Sine : Symbol {
     30    [StorableConstructor]
     31    private Sine(bool deserializing) : base(deserializing) { }
     32    private Sine(Sine original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Sine(this, cloner);
     35    }
    2936    public Sine() : base("Sine", "Symbol that represents the sine function.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Subtraction.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Subtraction", "Symbol that represents the - operator.")]
    2829  public sealed class Subtraction : Symbol {
     30    [StorableConstructor]
     31    private Subtraction(bool deserializing) : base(deserializing) { }
     32    private Subtraction(Subtraction original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Subtraction(this, cloner);
     35    }
    2936    public Subtraction() : base("Subtraction", "Symbol that represents the - operator.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Tangent.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Tangent", "Symbol that represents the tangent trigonometric function.")]
    2829  public sealed class Tangent : Symbol {
     30    [StorableConstructor]
     31    private Tangent(bool deserializing) : base(deserializing) { }
     32    private Tangent(Tangent original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Tangent(this, cloner);
     35    }
    2936    public Tangent() : base("Tangent", "Symbol that represents the tangent trigonometric function.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Variable.cs

    r4068 r5275  
    3333    #region Properties
    3434    [Storable]
    35     private double weightNu;
    36     public double WeightNu {
    37       get { return weightNu; }
     35    private double weightMu;
     36    public double WeightMu {
     37      get { return weightMu; }
    3838      set {
    39         if (value != weightNu) {
    40           weightNu = value;
     39        if (value != weightMu) {
     40          weightMu = value;
    4141          OnChanged(EventArgs.Empty);
    4242        }
     
    5656    }
    5757    [Storable]
    58     private double weightManipulatorNu;
    59     public double WeightManipulatorNu {
    60       get { return weightManipulatorNu; }
     58    private double weightManipulatorMu;
     59    public double WeightManipulatorMu {
     60      get { return weightManipulatorMu; }
    6161      set {
    62         if (value != weightManipulatorNu) {
    63           weightManipulatorNu = value;
     62        if (value != weightManipulatorMu) {
     63          weightManipulatorMu = value;
    6464          OnChanged(EventArgs.Empty);
    6565        }
     
    9090    }
    9191    #endregion
     92    [StorableConstructor]
     93    protected Variable(bool deserializing) : base(deserializing) {
     94      variableNames = new List<string>();
     95    }
     96    protected Variable(Variable original, Cloner cloner)
     97      : base(original, cloner) {
     98      weightMu = original.weightMu;
     99      weightSigma = original.weightSigma;
     100      variableNames = new List<string>(original.variableNames);
     101      weightManipulatorMu = original.weightManipulatorMu;
     102      weightManipulatorSigma = original.weightManipulatorSigma;
     103    }
    92104    public Variable() : this("Variable", "Represents a variable value.") { }
    93105    public Variable(string name, string description)
    94106      : base(name, description) {
    95       weightNu = 1.0;
     107      weightMu = 1.0;
    96108      weightSigma = 1.0;
    97       weightManipulatorNu = 0.0;
     109      weightManipulatorMu = 0.0;
    98110      weightManipulatorSigma = 1.0;
    99111      variableNames = new List<string>();
     
    105117
    106118    public override IDeepCloneable Clone(Cloner cloner) {
    107       Variable clone = (Variable)base.Clone(cloner);
    108       clone.weightNu = weightNu;
    109       clone.weightSigma = weightSigma;
    110       clone.variableNames = new List<string>(variableNames);
    111       clone.weightManipulatorNu = weightManipulatorNu;
    112       clone.weightManipulatorSigma = weightManipulatorSigma;
    113       return clone;
     119      return new Variable(this, cloner);
    114120    }
    115121  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/VariableTreeNode.cs

    r4220 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    23 using HeuristicLab.Common;
    2424using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    4444    }
    4545
    46 
    47     protected VariableTreeNode() { }
    48 
    49     // copy constructor
    50     protected VariableTreeNode(VariableTreeNode original)
    51       : base(original) {
     46    [StorableConstructor]
     47    protected VariableTreeNode(bool deserializing) : base(deserializing) { }
     48    protected VariableTreeNode(VariableTreeNode original, Cloner cloner)
     49      : base(original, cloner) {
    5250      weight = original.weight;
    5351      variableName = original.variableName;
    5452    }
    55 
     53    protected VariableTreeNode() { }
    5654    public VariableTreeNode(Variable variableSymbol) : base(variableSymbol) { }
    5755
     
    6462    public override void ResetLocalParameters(IRandom random) {
    6563      base.ResetLocalParameters(random);
    66       weight = NormalDistributedRandom.NextDouble(random, Symbol.WeightNu, Symbol.WeightSigma);
     64      weight = NormalDistributedRandom.NextDouble(random, Symbol.WeightMu, Symbol.WeightSigma);
    6765      variableName = Symbol.VariableNames.SelectRandom(random);
    6866    }
     
    7068    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
    7169      base.ShakeLocalParameters(random, shakingFactor);
    72       double x = NormalDistributedRandom.NextDouble(random, Symbol.WeightManipulatorNu, Symbol.WeightManipulatorSigma);
     70      double x = NormalDistributedRandom.NextDouble(random, Symbol.WeightManipulatorMu, Symbol.WeightManipulatorSigma);
    7371      weight = weight + x * shakingFactor;
    7472      variableName = Symbol.VariableNames.SelectRandom(random);
    7573    }
    7674
    77 
    78     public override object Clone() {
    79       return new VariableTreeNode(this);
     75    public override IDeepCloneable Clone(Cloner cloner) {
     76      return new VariableTreeNode(this, cloner);
    8077    }
    8178
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/VariableFrequencyAnalyser.cs

    r4125 r5275  
    2222using System.Collections.Generic;
    2323using System.Linq;
     24using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Data;
     
    6162    }
    6263    #endregion
     64    [StorableConstructor]
     65    protected VariableFrequencyAnalyser(bool deserializing) : base(deserializing) { }
     66    protected VariableFrequencyAnalyser(VariableFrequencyAnalyser original, Cloner cloner)
     67      : base(original, cloner) {
     68    }
    6369    public VariableFrequencyAnalyser()
    6470      : base() {
     
    6975
    7076    public override IOperation Apply() {
    71       var inputVariables = DataAnalysisProblemData.InputVariables.Select(x => x.Value);
     77      var inputVariables = DataAnalysisProblemData.InputVariables.CheckedItems.Select(x => x.Value.Value);
    7278      if (VariableFrequencies == null) {
    7379        VariableFrequencies = new DoubleMatrix(0, 1, inputVariables);
     
    8086        VariableFrequencies[lastRowIndex, columnIndex] = pair.Value;
    8187      }
    82       return null;
     88      return base.Apply();
    8389    }
    8490
Note: See TracChangeset for help on using the changeset viewer.