Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/19/10 10:18:15 (14 years ago)
Author:
gkronber
Message:

Worked on ADF aware evaluation for symbolic regression problems #938 (Data types and operators for regression problems)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionEvaluator.cs

    r3377 r3409  
    4444        this.row = row;
    4545        pc = 0;
     46        arguments.Clear();
    4647        var estimatedValue = Evaluate();
    4748        if (double.IsNaN(estimatedValue) || double.IsInfinity(estimatedValue)) yield return 0.0;
     
    5051    }
    5152
     53    private List<double> arguments = new List<double>();
    5254    public double Evaluate() {
    5355      var currentInstr = code[pc++];
     
    8183            return p;
    8284          }
     85        case CodeSymbol.Call: {
     86            // save current arguments
     87            var oldArgs = new List<double>(arguments);
     88            arguments.Clear();
     89            // evaluate sub-trees
     90            for (int i = 0; i < currentInstr.nArguments; i++) {
     91              arguments.Add(Evaluate());
     92            }
     93            // save the pc
     94            int nextPc = pc;
     95            // set pc to start of function 
     96            pc = currentInstr.iArg0;
     97            // evaluate the function
     98            double v = Evaluate();
     99            // restore the pc => evaluation will continue at point after my subtrees 
     100            pc = nextPc;
     101            // restore arguments
     102            arguments = oldArgs;
     103            return v;
     104          }
     105        case CodeSymbol.Arg: {
     106            return arguments[currentInstr.iArg0];
     107          }
    83108        case CodeSymbol.Dynamic: {
    84109            var variableTreeNode = currentInstr.dynamicNode as VariableTreeNode;
Note: See TracChangeset for help on using the changeset viewer.