Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/07/10 14:11:12 (14 years ago)
Author:
mkommend
Message:

Implemented VariableCondition symbol (ticket #1325).

Location:
branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.DataAnalysis/3.3
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj

    r5051 r5060  
    156156    <Compile Include="Symbolic\Symbols\Derivative.cs" />
    157157    <Compile Include="Symbolic\Symbols\Integral.cs" />
     158    <Compile Include="Symbolic\Symbols\VariableCondition.cs" />
     159    <Compile Include="Symbolic\Symbols\VariableConditionTreeNode.cs" />
    158160    <Compile Include="TableFileParser.cs" />
    159161    <None Include="HeuristicLab.snk" />
  • branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/FullFunctionalExpressionGrammar.cs

    r5051 r5060  
    6060      var or = new Or();
    6161      var not = new Not();
     62
    6263      var timeLag = new TimeLag();
    6364      timeLag.InitialFrequency = 0.0;
    6465      var integral = new Integral();
    6566      integral.InitialFrequency = 0.0;
    66       var derivativ = new Derivative();
    67       derivativ.InitialFrequency = 0.0;
     67      var derivative = new Derivative();
     68      derivative.InitialFrequency = 0.0;
     69
     70      var variableCondition = new VariableCondition();
     71      variableCondition.InitialFrequency = 0.0;
    6872
    6973      var constant = new Constant();
     
    7478      laggedVariable.InitialFrequency = 0.0;
    7579
    76       var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, exp, @if, gt, lt, and, or, not, timeLag, integral, derivativ, constant, variableSymbol, laggedVariable };
    77       var unaryFunctionSymbols = new List<Symbol>() { sin, cos, tan, log, exp, not, timeLag, integral, derivativ };
    78       var binaryFunctionSymbols = new List<Symbol>() { gt, lt };
     80      var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, exp, @if, gt, lt,
     81        and, or, not, timeLag, integral, derivative, variableCondition, constant, variableSymbol, laggedVariable };
     82      var unaryFunctionSymbols = new List<Symbol>() { sin, cos, tan, log, exp, not, timeLag, integral, derivative };
     83      var binaryFunctionSymbols = new List<Symbol>() { gt, lt, variableCondition };
    7984      var functionSymbols = new List<Symbol>() { add, sub, mul, div, mean, and, or };
    8085      var terminalSymbols = new List<Symbol>() { variableSymbol, constant, laggedVariable };
  • branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionInterpreter.cs

    r5052 r5060  
    7171      public const byte Integral = 23;
    7272      public const byte Derivative = 24;
     73
     74      public const byte VariableCondition = 25;
    7375    }
    7476
     
    9799      { typeof(TimeLag), OpCodes.TimeLag},
    98100      { typeof(Integral), OpCodes.Integral},
    99       { typeof(Derivative), OpCodes.Derivative}
     101      { typeof(Derivative), OpCodes.Derivative},
     102      { typeof(VariableCondition),OpCodes.VariableCondition}
    100103    };
    101104    private const int ARGUMENT_STACK_SIZE = 1024;
     
    147150        var variableTreeNode = instr.dynamicNode as LaggedVariableTreeNode;
    148151        instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
     152      } else if (instr.opCode == OpCodes.VariableCondition) {
     153        var variableConditionTreeNode = instr.dynamicNode as VariableConditionTreeNode;
     154        instr.iArg0 = (ushort)dataset.GetVariableIndex(variableConditionTreeNode.VariableName);
    149155      }
    150156      return instr;
     
    344350            return (f_0 + 2 * f_1 - 2 * f_3 - f_4) / 8; // h = 1
    345351          }
     352
     353        //mkommend: this symbol uses the logistic function f(x) = 1 / (1 + e^(-alpha * x) )
     354        //to determine the relative amounts of the true and false branch see http://en.wikipedia.org/wiki/Logistic_function
     355        case OpCodes.VariableCondition: {
     356            var variableConditionTreeNode = (VariableConditionTreeNode)currentInstr.dynamicNode;
     357            double variableValue = dataset[row, currentInstr.iArg0];
     358            double x = variableValue - variableConditionTreeNode.Threshold;
     359            double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x));
     360
     361            double trueBranch = Evaluate();
     362            double falseBranch = Evaluate();
     363
     364            return trueBranch * p + falseBranch * (1 - p);
     365          }
    346366        default: throw new NotSupportedException();
    347367      }
  • branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Variable.cs

    r4989 r5060  
    9191    #endregion
    9292    [StorableConstructor]
    93     protected Variable(bool deserializing) : base(deserializing) {
     93    protected Variable(bool deserializing)
     94      : base(deserializing) {
    9495      variableNames = new List<string>();
    9596    }
  • branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/VariableTreeNode.cs

    r4989 r5060  
    5555
    5656    public override bool HasLocalParameters {
    57       get {
    58         return true;
    59       }
     57      get { return true; }
    6058    }
    6159
Note: See TracChangeset for help on using the changeset viewer.