Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/07/08 15:10:51 (16 years ago)
Author:
gkronber
Message:

implemented #195

Location:
trunk/sources/HeuristicLab.Functions
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Functions/BakedTreeEvaluator.cs

    r363 r365  
    9696            return currInstr.d_arg0;
    9797          }
     98        case EvaluatorSymbolTable.DIFFERENTIAL: {
     99            int row = sampleIndex + currInstr.i_arg1;
     100            if(row < 1 || row >= dataset.Rows) return double.NaN;
     101            else return currInstr.d_arg0 * (dataset.GetValue(row, currInstr.i_arg0) - dataset.GetValue(row - 1, currInstr.i_arg0));
     102          }
    98103        case EvaluatorSymbolTable.MULTIPLICATION: {
    99104            double result = EvaluateBakedCode();
  • trunk/sources/HeuristicLab.Functions/FunctionView.cs

    r308 r365  
    168168      public void Visit(Cosinus cosinus) {
    169169        name = "Sin";
     170      }
     171
     172      public void Visit(Differential diff) {
     173        string timeOffset = "";
     174        int sampleOffset = ((ConstrainedIntData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Differential.OFFSET).Value).Data;
     175        int variableIndex = ((ConstrainedIntData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Differential.INDEX).Value).Data;
     176        double weight = ((ConstrainedDoubleData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Differential.WEIGHT).Value).Data;
     177        if(sampleOffset < 0) {
     178          timeOffset = "(t" + sampleOffset + ")";
     179        } else if(sampleOffset > 0) {
     180          timeOffset = "(t+" + sampleOffset + ")";
     181        } else {
     182          timeOffset = "";
     183        }
     184        name = "Diff" + variableIndex + timeOffset + " * " + weight;
    170185      }
    171186
  • trunk/sources/HeuristicLab.Functions/HeuristicLab.Functions.csproj

    r308 r365  
    5656    <Compile Include="BakedTreeEvaluator.cs" />
    5757    <Compile Include="Constant.cs" />
     58    <Compile Include="Differential.cs" />
    5859    <Compile Include="GreaterThan.cs" />
    5960    <Compile Include="IfThenElse.cs">
  • trunk/sources/HeuristicLab.Functions/IFunctionVisitor.cs

    r308 r365  
    3333    void Visit(Constant constant);
    3434    void Visit(Cosinus cosinus);
     35    void Visit(Differential differential);
    3536    void Visit(Division division);
    3637    void Visit(Equal equal);
  • trunk/sources/HeuristicLab.Functions/ModelAnalyzerExporter.cs

    r344 r365  
    5959    public void Visit(Cosinus cosinus) {
    6060      VisitFunction("Trigonometrics[1]", cosinus);
     61    }
     62
     63    public void Visit(Differential differential) {
     64      double weight = ((ConstrainedDoubleData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Differential.WEIGHT).Value).Data;
     65      double index = ((ConstrainedIntData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Differential.INDEX).Value).Data;
     66      double offset = ((ConstrainedIntData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Differential.OFFSET).Value).Data;
     67
     68      prefix += currentIndend + "[T]Differential(" + weight.ToString("r") + ";" + index + ";" + -offset + ")";
    6169    }
    6270
  • trunk/sources/HeuristicLab.Functions/SymbolTable.cs

    r319 r365  
    3434    public const int CONSTANT = 4;
    3535    public const int COSINUS = 5;
     36    public const int DIFFERENTIAL = 25;
    3637    public const int DIVISION = 6;
    3738    public const int EQU = 7;
     
    8283      staticTypes[typeof(Variable)] = VARIABLE;
    8384      staticTypes[typeof(Xor)] = XOR;
     85      staticTypes[typeof(Differential)] = DIFFERENTIAL;
    8486    }
    8587
Note: See TracChangeset for help on using the changeset viewer.