Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/05/08 21:34:12 (16 years ago)
Author:
gkronber
Message:

fixed a stupid mistake introduced with r702 #328 (GP evaluation doesn't work in a thread parallel engine).

Location:
trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/AveragePercentageChangeEvaluator.cs

    r702 r712  
    4545      bool differential = GetVariableValue<BoolData>("Differential", scope, true).Data;
    4646      DoubleData apc = GetVariableValue<DoubleData>("APC", scope, false, false);
    47       if(apc == null) {
     47      if (apc == null) {
    4848        apc = new DoubleData();
    4949        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("APC"), apc));
     
    5151
    5252      double percentageSum = 0;
    53       for(int sample = start; sample < end; sample++) {
     53      for (int sample = start; sample < end; sample++) {
    5454        double prevOriginal;
    5555        double originalPercentageChange;
    5656        double estimatedPercentageChange;
    57         if(differential) {
    58           prevOriginal = dataset.GetValue(targetVariable,sample - 1);
    59           originalPercentageChange = (dataset.GetValue(targetVariable,sample) - prevOriginal) / prevOriginal;
     57        if (differential) {
     58          prevOriginal = dataset.GetValue(sample - 1, targetVariable);
     59          originalPercentageChange = (dataset.GetValue(sample, targetVariable) - prevOriginal) / prevOriginal;
    6060          estimatedPercentageChange = (evaluator.Evaluate(sample) - prevOriginal) / prevOriginal;
    61           if(updateTargetValues) {
    62             dataset.SetValue(targetVariable, sample, estimatedPercentageChange * prevOriginal + prevOriginal);
     61          if (updateTargetValues) {
     62            dataset.SetValue(sample, targetVariable, estimatedPercentageChange * prevOriginal + prevOriginal);
    6363          }
    6464        } else {
    65           originalPercentageChange = dataset.GetValue(targetVariable,sample);
     65          originalPercentageChange = dataset.GetValue(sample, targetVariable);
    6666          estimatedPercentageChange = evaluator.Evaluate(sample);
    67           if(updateTargetValues) {
    68             dataset.SetValue(targetVariable, sample, estimatedPercentageChange);
     67          if (updateTargetValues) {
     68            dataset.SetValue(sample, targetVariable, estimatedPercentageChange);
    6969          }
    7070        }
    71         if(!double.IsNaN(originalPercentageChange) && !double.IsInfinity(originalPercentageChange)) {
    72           if((estimatedPercentageChange > 0 && originalPercentageChange > 0) ||
     71        if (!double.IsNaN(originalPercentageChange) && !double.IsInfinity(originalPercentageChange)) {
     72          if ((estimatedPercentageChange > 0 && originalPercentageChange > 0) ||
    7373            (estimatedPercentageChange < 0 && originalPercentageChange < 0)) {
    7474            percentageSum += Math.Abs(originalPercentageChange);
    75           } else if((estimatedPercentageChange > 0 && originalPercentageChange < 0) ||
     75          } else if ((estimatedPercentageChange > 0 && originalPercentageChange < 0) ||
    7676            (estimatedPercentageChange < 0 && originalPercentageChange > 0)) {
    7777            percentageSum -= Math.Abs(originalPercentageChange);
     
    8181
    8282      percentageSum /= (end - start);
    83       if(double.IsNaN(percentageSum) || double.IsInfinity(percentageSum)) {
     83      if (double.IsNaN(percentageSum) || double.IsInfinity(percentageSum)) {
    8484        percentageSum = double.MinValue;
    8585      }
  • trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/ProfitEvaluator.cs

    r702 r712  
    4747      double transactionCost = GetVariableValue<DoubleData>("TransactionCost", scope, true).Data;
    4848      DoubleData profit = GetVariableValue<DoubleData>("Profit", scope, false, false);
    49       if(profit == null) {
     49      if (profit == null) {
    5050        profit = new DoubleData();
    5151        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("Profit"), profit));
     
    5555      double cB = 0;
    5656      double exchangeRate = double.MaxValue;
    57       for(int sample = start; sample < end; sample++) {
     57      for (int sample = start; sample < end; sample++) {
    5858        exchangeRate = dataset.GetValue(sample, exchangeRateVarIndex);
    59         double originalPercentageChange = dataset.GetValue(targetVariable, sample);
     59        double originalPercentageChange = dataset.GetValue(sample, targetVariable);
    6060        double estimatedPercentageChange = evaluator.Evaluate(sample);
    61         if(updateTargetValues) {
    62           dataset.SetValue(targetVariable, sample, estimatedPercentageChange);
     61        if (updateTargetValues) {
     62          dataset.SetValue(sample, targetVariable, estimatedPercentageChange);
    6363        }
    64         if(!double.IsNaN(originalPercentageChange) && !double.IsInfinity(originalPercentageChange)) {
    65           if(estimatedPercentageChange > 0) {
     64        if (!double.IsNaN(originalPercentageChange) && !double.IsInfinity(originalPercentageChange)) {
     65          if (estimatedPercentageChange > 0) {
    6666            // prediction is the rate of B/A will increase (= get more B for one A) => exchange all B to A
    6767            cA += (cB / exchangeRate) * (1 - transactionCost);
    6868            cB = 0;
    69           } else if(estimatedPercentageChange < 0) {
     69          } else if (estimatedPercentageChange < 0) {
    7070            // prediction is the rate of B/A will drop (= get more A for one B) => exchange all A to B
    7171            cB += (cA * exchangeRate) * (1 - transactionCost);
     
    7575      }
    7676
    77       if(double.IsNaN(cA) || double.IsInfinity(cA) || double.IsInfinity(cB) || double.IsNaN(cB)) {
     77      if (double.IsNaN(cA) || double.IsInfinity(cA) || double.IsInfinity(cB) || double.IsNaN(cB)) {
    7878        cA = 0;
    7979        cB = 0;
  • trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/TheilInequalityCoefficientEvaluator.cs

    r702 r712  
    5555
    5656    public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {
    57     #region create result variables
     57      #region create result variables
    5858      DoubleData theilInequaliy = GetVariableValue<DoubleData>("TheilInequalityCoefficient", scope, false, false);
    59       if(theilInequaliy == null) {
     59      if (theilInequaliy == null) {
    6060        theilInequaliy = new DoubleData();
    6161        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TheilInequalityCoefficient"), theilInequaliy));
    6262      }
    6363      DoubleData uBias = GetVariableValue<DoubleData>("TheilInequalityCoefficientBias", scope, false, false);
    64       if(uBias == null) {
     64      if (uBias == null) {
    6565        uBias = new DoubleData();
    6666        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TheilInequalityCoefficientBias"), uBias));
    6767      }
    6868      DoubleData uVariance = GetVariableValue<DoubleData>("TheilInequalityCoefficientVariance", scope, false, false);
    69       if(uVariance == null) {
     69      if (uVariance == null) {
    7070        uVariance = new DoubleData();
    7171        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TheilInequalityCoefficientVariance"), uVariance));
    7272      }
    7373      DoubleData uCovariance = GetVariableValue<DoubleData>("TheilInequalityCoefficientCovariance", scope, false, false);
    74       if(uCovariance == null) {
     74      if (uCovariance == null) {
    7575        uCovariance = new DoubleData();
    7676        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TheilInequalityCoefficientCovariance"), uCovariance));
     
    8383      double[] originalChanges = new double[end - start];
    8484      int nSamples = 0;
    85       for(int sample = start; sample < end; sample++) {
    86         double prevValue = dataset.GetValue(targetVariable, sample - 1);
     85      for (int sample = start; sample < end; sample++) {
     86        double prevValue = dataset.GetValue(sample - 1, targetVariable);
    8787        double estimatedChange = evaluator.Evaluate(sample) - prevValue;
    88         double originalChange = dataset.GetValue(targetVariable, sample) - prevValue;
    89         if(updateTargetValues) {
    90           dataset.SetValue(targetVariable, sample, estimatedChange + prevValue);
     88        double originalChange = dataset.GetValue(sample, targetVariable) - prevValue;
     89        if (updateTargetValues) {
     90          dataset.SetValue(sample, targetVariable, estimatedChange + prevValue);
    9191        }
    92         if(!double.IsNaN(originalChange) && !double.IsInfinity(originalChange)) {
     92        if (!double.IsNaN(originalChange) && !double.IsInfinity(originalChange)) {
    9393          double error = estimatedChange - originalChange;
    9494          errorsSquaredSum += error * error;
     
    100100      }
    101101      double quality = Math.Sqrt(errorsSquaredSum / nSamples) / Math.Sqrt(originalSquaredSum / nSamples);
    102       if(double.IsNaN(quality) || double.IsInfinity(quality))
     102      if (double.IsNaN(quality) || double.IsInfinity(quality))
    103103        quality = double.MaxValue;
    104104      theilInequaliy.Data = quality; // U2
Note: See TracChangeset for help on using the changeset viewer.