Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9991


Ignore:
Timestamp:
09/19/13 11:29:28 (11 years ago)
Author:
gkronber
Message:

#1508

  • fixed a bug in the ECB problem instance provider (reversed time series)
  • improved the ProblemInstanceProviderViewGeneric class to show a progress bar while loading the problem instance
  • fixed the build fail (in SolutionLineChartView)
Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Trading.Views/3.4/SolutionLineChartView.cs

    r9796 r9991  
    6565        this.chart.Series[SIGNALS_SERIES_NAME].Tag = Content;
    6666
    67         IEnumerable<double> accumulatedPrice = GetAccumulatedPrices(Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.PriceVariable));
     67        IEnumerable<double> accumulatedPrice = GetAccumulatedPrices(Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.PriceChangeVariable));
    6868        this.chart.Series.Add(PRICEVARIABLE_SERIES_NAME);
    6969        this.chart.Series[PRICEVARIABLE_SERIES_NAME].LegendText = PRICEVARIABLE_SERIES_NAME;
     
    7272        this.chart.Series[PRICEVARIABLE_SERIES_NAME].Tag = Content;
    7373
    74         IEnumerable<double> profit = OnlineProfitCalculator.GetProfits(Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.PriceVariable), Content.Signals, Content.ProblemData.TransactionCosts);
     74        IEnumerable<double> profit = OnlineProfitCalculator.GetProfits(Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.PriceChangeVariable), Content.Signals, Content.ProblemData.TransactionCosts);
    7575        IEnumerable<double> accumulatedProfits = GetAccumulatedPrices(profit);
    7676        this.chart.Series.Add(ASSET_SERIES_NAME);
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Trading/3.4/EcbProblemInstanceProvider.cs

    r9989 r9991  
    7878      var tList = new List<DateTime>();
    7979      var dList = new List<double>();
    80       double prevValue = 0;
    8180      values.Add(tList);
    8281      values.Add(dList);
     
    10099                if (descriptor.Name.Contains(reader.GetAttribute("currency"))) {
    101100                  reader.MoveToAttribute("rate");
    102                   var curValue = reader.ReadContentAsDouble();
    103                   if (!dList.Any())
    104                     dList.Add(0.0);
    105                   else {
    106                     dList.Add(curValue - prevValue);
    107                   }
    108                   prevValue = curValue;
     101                  dList.Add(reader.ReadContentAsDouble());
    109102
    110103                  reader.MoveToElement();
     
    117110          }
    118111      }
    119       var allowedInputVariables = new string[] { descriptor.Name };
    120       var targetVariable = descriptor.Name;
    121       var ds = new Dataset(new string[] { "Day", descriptor.Name }, values);
     112      // entries in ECB XML are ordered most recent first => reverse lists
     113      tList.Reverse();
     114      dList.Reverse();
     115      // calculate exchange rate deltas
     116      var changes = new[] { 0.0 } // first element
     117        .Concat(dList.Zip(dList.Skip(1), (prev, cur) => cur - prev)).ToList();
     118      values.Add(changes);
     119
     120      var targetVariable = "d(" + descriptor.Name + ")";
     121      var allowedInputVariables = new string[] { targetVariable };
     122
     123      var ds = new Dataset(new string[] { "Day", descriptor.Name, targetVariable }, values);
    122124      return new ProblemData(ds, allowedInputVariables, targetVariable);
    123125    }
  • trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceProviderViewGeneric.cs

    r9456 r9991  
    2121
    2222using System;
     23using System.ComponentModel;
    2324using System.Linq;
     25using System.Threading.Tasks;
    2426using System.Windows.Forms;
    2527using HeuristicLab.MainForm;
     
    8890
    8991    private void instancesComboBox_SelectionChangeCommitted(object sender, System.EventArgs e) {
     92      toolTip.SetToolTip(instancesComboBox, String.Empty);
    9093      if (instancesComboBox.SelectedIndex >= 0) {
    9194        var descriptor = (IDataDescriptor)instancesComboBox.SelectedItem;
    92         T instance = Content.LoadData(descriptor);
    93         try {
    94           GenericConsumer.Load(instance);
    95         } catch (Exception ex) {
    96           ErrorHandling.ShowErrorDialog(String.Format("This problem does not support loading the instance {0}", descriptor.Name), ex);
    97         }
    98         toolTip.SetToolTip(instancesComboBox, descriptor.Description);
    99       } else toolTip.SetToolTip(instancesComboBox, String.Empty);
     95
     96        IContentView activeView = (IContentView)MainFormManager.MainForm.ActiveView;
     97        var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
     98        // lock active view and show progress bar
     99        mainForm.AddOperationProgressToContent(activeView.Content, "Loading problem instance.");
     100        // continuation for removing the progess bar from the active view
     101        Action<Task> removeProgressFromContent = (_) => mainForm.RemoveOperationProgressFromContent(activeView.Content);
     102
     103        // task structure:
     104        // loadFromProvider
     105        // |
     106        // +-> on fault -> show error dialog -> remove progress bar
     107        // |
     108        // `-> success  -> loadToProblem
     109        //                 |
     110        //                 +-> on fault -> show error dialog -> remove progress bar
     111        //                 |
     112        //                 `-> success -> set tool tip -> remove progress bar
     113        var loadFromProvider = new Task<T>(() => Content.LoadData(descriptor));
     114
     115        // success
     116        var loadToProblem = loadFromProvider
     117          .ContinueWith(task => GenericConsumer.Load(task.Result), TaskContinuationOptions.OnlyOnRanToCompletion);
     118        // on error
     119        loadFromProvider
     120          .ContinueWith(task => { ErrorHandling.ShowErrorDialog(String.Format("Could not load the problem instance {0}", descriptor.Name), task.Exception); }, TaskContinuationOptions.OnlyOnFaulted)
     121          .ContinueWith(removeProgressFromContent);
     122
     123        // success
     124        loadToProblem
     125          .ContinueWith(task => toolTip.SetToolTip(instancesComboBox, descriptor.Description), TaskContinuationOptions.OnlyOnRanToCompletion)
     126          .ContinueWith(removeProgressFromContent);
     127        // on error
     128        loadToProblem.ContinueWith(task => { ErrorHandling.ShowErrorDialog(String.Format("This problem does not support loading the instance {0}", descriptor.Name), task.Exception); }, TaskContinuationOptions.OnlyOnFaulted)
     129        .ContinueWith(removeProgressFromContent);
     130
     131        // start async loading task
     132        loadFromProvider.Start();
     133      }
    100134    }
    101135  }
Note: See TracChangeset for help on using the changeset viewer.