Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14542


Ignore:
Timestamp:
01/04/17 16:33:37 (7 years ago)
Author:
gkronber
Message:

#2650: merged r14504:14533 from trunk to branch

Location:
branches/symbreg-factors-2650
Files:
55 edited
3 copied

Legend:

Unmodified
Added
Removed
  • branches/symbreg-factors-2650

  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis

  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/BaselineClassifiers/OneR.cs

    r14242 r14542  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using System.Threading;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    5960    }
    6061
    61     protected override void Run() {
     62    protected override void Run(CancellationToken cancellationToken) {
    6263      var solution = CreateOneRSolution(Problem.ProblemData, MinBucketSizeParameter.Value.Value);
    6364      Results.Add(new Result("OneR solution", "The 1R classifier.", solution));
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/BaselineClassifiers/ZeroR.cs

    r14185 r14542  
    2121
    2222using System.Linq;
     23using System.Threading;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    4950    }
    5051
    51     protected override void Run() {
     52    protected override void Run(CancellationToken cancellationToken) {
    5253      var solution = CreateZeroRSolution(Problem.ProblemData);
    5354      Results.Add(new Result("ZeroR solution", "The simplest possible classifier, ZeroR always predicts the majority class.", solution));
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/FixedDataAnalysisAlgorithm.cs

    r14185 r14542  
    2121
    2222using System;
    23 using System.Threading;
    24 using System.Threading.Tasks;
    2523using HeuristicLab.Common;
    2624using HeuristicLab.Optimization;
     
    3028namespace HeuristicLab.Algorithms.DataAnalysis {
    3129  [StorableClass]
    32   public abstract class FixedDataAnalysisAlgorithm<T> : Algorithm,
    33     IDataAnalysisAlgorithm<T>,
    34     IStorableContent
    35     where T : class, IDataAnalysisProblem {
    36     public string Filename { get; set; }
    37 
     30  public abstract class FixedDataAnalysisAlgorithm<T> : BasicAlgorithm where T : class, IDataAnalysisProblem {
    3831    #region Properties
    3932    public override Type ProblemType {
     
    4437      set { base.Problem = value; }
    4538    }
    46     [Storable]
    47     private ResultCollection results;
    48     public override ResultCollection Results {
    49       get { return results; }
    50     }
    5139    #endregion
    5240
    53     private DateTime lastUpdateTime;
     41    public override bool SupportsPause { get { return false; } }
    5442
    5543    [StorableConstructor]
    5644    protected FixedDataAnalysisAlgorithm(bool deserializing) : base(deserializing) { }
    57     protected FixedDataAnalysisAlgorithm(FixedDataAnalysisAlgorithm<T> original, Cloner cloner)
    58       : base(original, cloner) {
    59       results = cloner.Clone(original.Results);
    60     }
    61     public FixedDataAnalysisAlgorithm()
    62       : base() {
    63       results = new ResultCollection();
    64     }
    65 
    66     public override void Prepare() {
    67       if (Problem != null) base.Prepare();
    68       results.Clear();
    69       OnPrepared();
    70     }
    71 
    72     public override void Start() {
    73       base.Start();
    74       var cancellationTokenSource = new CancellationTokenSource();
    75 
    76       OnStarted();
    77       Task task = Task.Factory.StartNew(Run, cancellationTokenSource.Token, cancellationTokenSource.Token);
    78       task.ContinueWith(t => {
    79         try {
    80           t.Wait();
    81         }
    82         catch (AggregateException ex) {
    83           try {
    84             ex.Flatten().Handle(x => x is OperationCanceledException);
    85           }
    86           catch (AggregateException remaining) {
    87             if (remaining.InnerExceptions.Count == 1) OnExceptionOccurred(remaining.InnerExceptions[0]);
    88             else OnExceptionOccurred(remaining);
    89           }
    90         }
    91         cancellationTokenSource.Dispose();
    92         cancellationTokenSource = null;
    93         OnStopped();
    94       });
    95     }
    96     private void Run(object state) {
    97       CancellationToken cancellationToken = (CancellationToken)state;
    98       lastUpdateTime = DateTime.UtcNow;
    99       System.Timers.Timer timer = new System.Timers.Timer(250);
    100       timer.AutoReset = true;
    101       timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
    102       timer.Start();
    103       try {
    104         Run();
    105       }
    106       finally {
    107         timer.Elapsed -= new System.Timers.ElapsedEventHandler(timer_Elapsed);
    108         timer.Stop();
    109         ExecutionTime += DateTime.UtcNow - lastUpdateTime;
    110       }
    111 
    112       cancellationToken.ThrowIfCancellationRequested();
    113     }
    114     protected abstract void Run();
    115     #region Events
    116     protected override void OnProblemChanged() {
    117       Problem.Reset += new EventHandler(Problem_Reset);
    118       base.OnProblemChanged();
    119     }
    120     private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) {
    121       System.Timers.Timer timer = (System.Timers.Timer)sender;
    122       timer.Enabled = false;
    123       DateTime now = DateTime.UtcNow;
    124       ExecutionTime += now - lastUpdateTime;
    125       lastUpdateTime = now;
    126       timer.Enabled = true;
    127     }
    128     #endregion
     45    protected FixedDataAnalysisAlgorithm(FixedDataAnalysisAlgorithm<T> original, Cloner cloner) : base(original, cloner) { }
     46    public FixedDataAnalysisAlgorithm() : base() { }
    12947
    13048  }
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/GBM/GradientBoostingRegressionAlgorithm.cs

    r14185 r14542  
    4444  [StorableClass]
    4545  [Creatable(CreatableAttribute.Categories.DataAnalysisRegression, Priority = 350)]
    46   public class GradientBoostingRegressionAlgorithm : BasicAlgorithm {
    47     public override Type ProblemType {
    48       get { return typeof(IRegressionProblem); }
    49     }
    50 
    51     public new IRegressionProblem Problem {
    52       get { return (IRegressionProblem)base.Problem; }
    53       set { base.Problem = value; }
    54     }
     46  public class GradientBoostingRegressionAlgorithm : FixedDataAnalysisAlgorithm<IRegressionProblem> {
    5547
    5648    #region ParameterNames
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/GradientBoostedTrees/GradientBoostedTreesAlgorithm.cs

    r14351 r14542  
    3838  [StorableClass]
    3939  [Creatable(CreatableAttribute.Categories.DataAnalysisRegression, Priority = 125)]
    40   public class GradientBoostedTreesAlgorithm : BasicAlgorithm {
    41     public override Type ProblemType {
    42       get { return typeof(IRegressionProblem); }
    43     }
    44     public new IRegressionProblem Problem {
    45       get { return (IRegressionProblem)base.Problem; }
    46       set { base.Problem = value; }
    47     }
    48 
     40  public class GradientBoostedTreesAlgorithm : FixedDataAnalysisAlgorithm<IRegressionProblem> {
    4941    #region ParameterNames
    5042    private const string IterationsParameterName = "Iterations";
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearDiscriminantAnalysis.cs

    r14243 r14542  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using System.Threading;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    5960
    6061    #region Fisher LDA
    61     protected override void Run() {
     62    protected override void Run(CancellationToken cancellationToken) {
    6263      var solution = CreateLinearDiscriminantAnalysisSolution(Problem.ProblemData);
    6364      Results.Add(new Result(LinearDiscriminantAnalysisSolutionResultName, "The linear discriminant analysis.", solution));
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearRegression.cs

    r14243 r14542  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using System.Threading;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    6061
    6162    #region linear regression
    62     protected override void Run() {
     63    protected override void Run(CancellationToken cancellationToken) {
    6364      double rmsError, cvRmsError;
    6465      var solution = CreateLinearRegressionSolution(Problem.ProblemData, out rmsError, out cvRmsError);
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/MultinomialLogitClassification.cs

    r14240 r14542  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using System.Threading;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    5758
    5859    #region logit classification
    59     protected override void Run() {
     60    protected override void Run(CancellationToken cancellationToken) {
    6061      double rmsError, relClassError;
    6162      var solution = CreateLogitClassificationSolution(Problem.ProblemData, out rmsError, out relClassError);
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/MctsSymbolicRegressionAlgorithm.cs

    r14185 r14542  
    3838  [StorableClass]
    3939  [Creatable(CreatableAttribute.Categories.DataAnalysisRegression, Priority = 250)]
    40   public class MctsSymbolicRegressionAlgorithm : BasicAlgorithm {
    41     public override Type ProblemType {
    42       get { return typeof(IRegressionProblem); }
    43     }
    44     public new IRegressionProblem Problem {
    45       get { return (IRegressionProblem)base.Problem; }
    46       set { base.Problem = value; }
    47     }
     40  public class MctsSymbolicRegressionAlgorithm : FixedDataAnalysisAlgorithm<IRegressionProblem> {
    4841
    4942    #region ParameterNames
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/NearestNeighbour/NearestNeighbourClassification.cs

    r14239 r14542  
    2222using System;
    2323using System.Linq;
     24using System.Threading;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     
    9192
    9293    #region nearest neighbour
    93     protected override void Run() {
     94    protected override void Run(CancellationToken cancellationToken) {
    9495      double[] weights = null;
    9596      if (Weights != null) weights = Weights.CloneAsArray();
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/NearestNeighbour/NearestNeighbourRegression.cs

    r14239 r14542  
    2121
    2222using System;
     23using System.Threading;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    9293
    9394    #region nearest neighbour
    94     protected override void Run() {
     95    protected override void Run(CancellationToken cancellationToken) {
    9596      double[] weights = null;
    9697      if (Weights != null) weights = Weights.CloneAsArray();
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkClassification.cs

    r14185 r14542  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using System.Threading;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    168169
    169170    #region neural network
    170     protected override void Run() {
     171    protected override void Run(CancellationToken cancellationToken) {
    171172      double rmsError, avgRelError, relClassError;
    172173      var solution = CreateNeuralNetworkClassificationSolution(Problem.ProblemData, HiddenLayers, NodesInFirstHiddenLayer, NodesInSecondHiddenLayer, Decay, Restarts, out rmsError, out avgRelError, out relClassError);
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleClassification.cs

    r14185 r14542  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using System.Threading;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    154155
    155156    #region neural network ensemble
    156     protected override void Run() {
     157    protected override void Run(CancellationToken cancellationToken) {
    157158      double rmsError, avgRelError, relClassError;
    158159      var solution = CreateNeuralNetworkEnsembleClassificationSolution(Problem.ProblemData, EnsembleSize, HiddenLayers, NodesInFirstHiddenLayer, NodesInSecondHiddenLayer, Decay, Restarts, out rmsError, out avgRelError, out relClassError);
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleRegression.cs

    r14185 r14542  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using System.Threading;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    154155
    155156    #region neural network ensemble
    156     protected override void Run() {
     157    protected override void Run(CancellationToken cancellationToken) {
    157158      double rmsError, avgRelError;
    158159      var solution = CreateNeuralNetworkEnsembleRegressionSolution(Problem.ProblemData, EnsembleSize, HiddenLayers, NodesInFirstHiddenLayer, NodesInSecondHiddenLayer, Decay, Restarts, out rmsError, out avgRelError);
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkRegression.cs

    r14185 r14542  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using System.Threading;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    170171
    171172    #region neural network
    172     protected override void Run() {
     173    protected override void Run(CancellationToken cancellationToken) {
    173174      double rmsError, avgRelError;
    174175      var solution = CreateNeuralNetworkRegressionSolution(Problem.ProblemData, HiddenLayers, NodesInFirstHiddenLayer, NodesInSecondHiddenLayer, Decay, Restarts, out rmsError, out avgRelError);
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/NonlinearRegression/NonlinearRegression.cs

    r14331 r14542  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using System.Threading;
    2526using HeuristicLab.Analysis;
    2627using HeuristicLab.Common;
     
    158159
    159160    #region nonlinear regression
    160     protected override void Run() {
     161    protected override void Run(CancellationToken cancellationToken) {
    161162      IRegressionSolution bestSolution = null;
    162163      if (InitializeParametersRandomly) {
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestClassification.cs

    r14185 r14542  
    2020#endregion
    2121
     22using System.Threading;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    132133
    133134    #region random forest
    134     protected override void Run() {
     135    protected override void Run(CancellationToken cancellationToken) {
    135136      double rmsError, relClassificationError, outOfBagRmsError, outOfBagRelClassificationError;
    136137      if (SetSeedRandomly) Seed = new System.Random().Next();
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestRegression.cs

    r14185 r14542  
    2020#endregion
    2121
     22using System.Threading;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    131132
    132133    #region random forest
    133     protected override void Run() {
     134    protected override void Run(CancellationToken cancellationToken) {
    134135      double rmsError, avgRelError, outOfBagRmsError, outOfBagAvgRelError;
    135136      if (SetSeedRandomly) Seed = new System.Random().Next();
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorClassification.cs

    r14185 r14542  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using System.Threading;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    143144
    144145    #region support vector classification
    145     protected override void Run() {
     146    protected override void Run(CancellationToken cancellationToken) {
    146147      IClassificationProblemData problemData = Problem.ProblemData;
    147148      IEnumerable<string> selectedInputVariables = problemData.AllowedInputVariables;
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorRegression.cs

    r14185 r14542  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using System.Threading;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    151152
    152153    #region support vector regression
    153     protected override void Run() {
     154    protected override void Run(CancellationToken cancellationToken) {
    154155      IRegressionProblemData problemData = Problem.ProblemData;
    155156      IEnumerable<string> selectedInputVariables = problemData.AllowedInputVariables;
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/TimeSeries/AutoregressiveModeling.cs

    r14185 r14542  
    2222using System;
    2323using System.Linq;
     24using System.Threading;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     
    6364    }
    6465
    65     protected override void Run() {
     66    protected override void Run(CancellationToken cancellationToken) {
    6667      double rmsError, cvRmsError;
    6768      var solution = CreateAutoRegressiveSolution(Problem.ProblemData, TimeOffset, out rmsError, out cvRmsError);
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/kMeans/KMeansClustering.cs

    r14185 r14542  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using System.Threading;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    7778
    7879    #region k-Means clustering
    79     protected override void Run() {
     80    protected override void Run(CancellationToken cancellationToken) {
    8081      var solution = CreateKMeansSolution(Problem.ProblemData, K.Value, Restarts.Value);
    8182      Results.Add(new Result(KMeansSolutionResultName, "The k-Means clustering solution.", solution));
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/HillClimber.cs

    r14185 r14542  
    4848
    4949    private const string IterationsParameterName = "Iterations";
     50    private const string BestQualityResultName = "Best quality";
     51    private const string IterationsResultName = "Iterations";
    5052
    5153    public override Type ProblemType {
    5254      get { return typeof(BinaryProblem); }
    5355    }
     56
     57    public override bool SupportsPause { get { return false; } }
     58
    5459    public new BinaryProblem Problem {
    5560      get { return (BinaryProblem)base.Problem; }
     
    6570      set { IterationsParameter.Value.Value = value; }
    6671    }
     72
     73    #region ResultsProperties
     74    private double ResultsBestQuality {
     75      get { return ((DoubleValue)Results[BestQualityResultName].Value).Value; }
     76      set { ((DoubleValue)Results[BestQualityResultName].Value).Value = value; }
     77    }
     78    private int ResultsIterations {
     79      get { return ((IntValue)Results[IterationsResultName].Value).Value; }
     80      set { ((IntValue)Results[IterationsResultName].Value).Value = value; }
     81    }
     82    #endregion
    6783
    6884    [StorableConstructor]
     
    8096      Parameters.Add(new FixedValueParameter<IntValue>(IterationsParameterName, "", new IntValue(100)));
    8197    }
     98
     99
     100    protected override void Initialize(CancellationToken cancellationToken) {
     101      Results.Add(new Result(BestQualityResultName, new DoubleValue(double.NaN)));
     102      Results.Add(new Result(IterationsResultName, new IntValue(0)));
     103      base.Initialize(cancellationToken);
     104    }
    82105    protected override void Run(CancellationToken cancellationToken) {
    83       var BestQuality = new DoubleValue(double.NaN);
    84       Results.Add(new Result("Best quality", BestQuality));
    85       for (int iteration = 0; iteration < Iterations; iteration++) {
     106      while (ResultsIterations < Iterations) {
     107        cancellationToken.ThrowIfCancellationRequested();
     108
    86109        var solution = new BinaryVector(Problem.Length);
    87110        for (int i = 0; i < solution.Length; i++) {
     
    92115
    93116        fitness = ImproveToLocalOptimum(Problem, solution, fitness, random);
    94         if (double.IsNaN(BestQuality.Value) || Problem.IsBetter(fitness, BestQuality.Value)) {
    95           BestQuality.Value = fitness;
     117        if (double.IsNaN(ResultsBestQuality) || Problem.IsBetter(fitness, ResultsBestQuality)) {
     118          ResultsBestQuality = fitness;
    96119        }
     120
     121        ResultsIterations++;
    97122      }
    98123    }
  • branches/symbreg-factors-2650/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/ParameterlessPopulationPyramid.cs

    r14185 r14542  
    5656
    5757    // Tracks all solutions in Pyramid for quick membership checks
    58     private HashSet<BinaryVector> seen = new HashSet<BinaryVector>(new EnumerableBoolEqualityComparer());
     58    private readonly HashSet<BinaryVector> seen = new HashSet<BinaryVector>(new EnumerableBoolEqualityComparer());
    5959
    6060    #region ParameterNames
     
    152152    }
    153153    #endregion
     154
     155    public override bool SupportsPause { get { return true; } }
    154156
    155157    [StorableConstructor]
     
    213215    }
    214216
    215     protected override void Run(CancellationToken cancellationToken) {
     217    protected override void Initialize(CancellationToken cancellationToken) {
    216218      // Set up the algorithm
    217219      if (SetSeedRandomly) Seed = new System.Random().Next();
     
    242244      Results.Add(new Result("Stored Solutions", table));
    243245
     246      base.Initialize(cancellationToken);
     247    }
     248
     249    protected override void Run(CancellationToken cancellationToken) {
    244250      // Loop until iteration limit reached or canceled.
    245       for (ResultsIterations = 0; ResultsIterations < MaximumIterations; ResultsIterations++) {
     251      while (ResultsIterations < MaximumIterations) {
    246252        double fitness = double.NaN;
    247253
    248254        try {
    249255          fitness = iterate();
     256          ResultsIterations++;
    250257          cancellationToken.ThrowIfCancellationRequested();
    251258        } finally {
  • branches/symbreg-factors-2650/HeuristicLab.Analysis.Views

  • branches/symbreg-factors-2650/HeuristicLab.Analysis.Views/3.3/DataTableControl.cs

    r14498 r14542  
    2727using System.Windows.Forms.DataVisualization.Charting;
    2828using HeuristicLab.Collections;
     29using HeuristicLab.MainForm.WindowsForms;
    2930
    3031namespace HeuristicLab.Analysis.Views {
    31   public partial class DataTableControl : UserControl {
     32  public partial class DataTableControl : AsynchronousContentView {
    3233    protected List<Series> invisibleSeries;
    3334    protected Dictionary<IObservableList<double>, DataRow> valuesRowsTable;
    3435
    35     private DataTable content;
    36     public DataTable Content {
    37       get { return content; }
    38       set {
    39         if (value == content) return;
    40         if (content != null) DeregisterContentEvents();
    41         content = value;
    42         if (content != null) RegisterContentEvents();
    43         OnContentChanged();
    44         SetEnabledStateOfControls();
    45       }
     36    public new DataTable Content {
     37      get { return (DataTable)base.Content; }
     38      set { base.Content = value; }
    4639    }
    4740
     
    5649
    5750    #region Event Handler Registration
    58     protected virtual void DeregisterContentEvents() {
     51    protected override void DeregisterContentEvents() {
    5952      foreach (DataRow row in Content.Rows)
    6053        DeregisterDataRowEvents(row);
     
    6558      Content.Rows.CollectionReset -= new CollectionItemsChangedEventHandler<DataRow>(Rows_CollectionReset);
    6659    }
    67     protected virtual void RegisterContentEvents() {
     60    protected override void RegisterContentEvents() {
    6861      Content.VisualPropertiesChanged += new EventHandler(Content_VisualPropertiesChanged);
    6962      Content.Rows.ItemsAdded += new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsAdded);
     
    9588    #endregion
    9689
    97     protected virtual void OnContentChanged() {
     90    protected override void OnContentChanged() {
    9891      invisibleSeries.Clear();
    9992      chart.Titles[0].Text = string.Empty;
     
    111104    }
    112105
    113     protected virtual void SetEnabledStateOfControls() {
     106    protected override void SetEnabledStateOfControls() {
    114107      chart.Enabled = Content != null;
    115108    }
     
    541534      if (!row.Values.Any()) return;
    542535
     536      var validValues = histogramRows.SelectMany(r => r.Values).Where(x => !IsInvalidValue(x)).ToList();
     537      if (!validValues.Any()) return;
     538
    543539      int bins = histogramRows.Max(r => r.VisualProperties.Bins);
    544       decimal minValue = (decimal)histogramRows.Min(r => r.Values.Min());
    545       decimal maxValue = (decimal)histogramRows.Max(r => r.Values.Max());
     540      decimal minValue = (decimal)validValues.Min();
     541      decimal maxValue = (decimal)validValues.Max();
    546542      decimal intervalWidth = (maxValue - minValue) / bins;
    547543      if (intervalWidth < 0) return;
  • branches/symbreg-factors-2650/HeuristicLab.Analysis.Views/3.3/ScatterPlotControl.cs

    r14498 r14542  
    2929using HeuristicLab.Collections;
    3030using HeuristicLab.Common;
     31using HeuristicLab.MainForm.WindowsForms;
    3132
    3233namespace HeuristicLab.Analysis.Views {
    33   public partial class ScatterPlotControl : UserControl {
     34  public partial class ScatterPlotControl : AsynchronousContentView {
    3435    protected List<Series> invisibleSeries;
    3536    protected Dictionary<IObservableList<Point2D<double>>, ScatterPlotDataRow> pointsRowsTable;
     
    3738    private double xMin, xMax, yMin, yMax;
    3839
    39     private ScatterPlot content;
    40     public ScatterPlot Content {
    41       get { return content; }
    42       set {
    43         if (value == content) return;
    44         if (content != null) DeregisterContentEvents();
    45         content = value;
    46         if (content != null) RegisterContentEvents();
    47         OnContentChanged();
    48         SetEnabledStateOfControls();
    49       }
     40    public new ScatterPlot Content {
     41      get { return (ScatterPlot)base.Content; }
     42      set { base.Content = value; }
    5043    }
    5144
     
    6154
    6255    #region Event Handler Registration
    63     protected virtual void DeregisterContentEvents() {
     56    protected override void DeregisterContentEvents() {
    6457      foreach (ScatterPlotDataRow row in Content.Rows)
    6558        DeregisterScatterPlotDataRowEvents(row);
     
    7063      Content.Rows.CollectionReset -= new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_CollectionReset);
    7164    }
    72     protected virtual void RegisterContentEvents() {
     65    protected override void RegisterContentEvents() {
    7366      Content.VisualPropertiesChanged += new EventHandler(Content_VisualPropertiesChanged);
    7467      Content.Rows.ItemsAdded += new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsAdded);
     
    9891    #endregion
    9992
    100     protected virtual void OnContentChanged() {
     93    protected override void OnContentChanged() {
    10194      invisibleSeries.Clear();
    10295      chart.Titles[0].Text = string.Empty;
     
    114107    }
    115108
    116     protected virtual void SetEnabledStateOfControls() {
     109    protected override void SetEnabledStateOfControls() {
    117110      chart.Enabled = Content != null;
    118111    }
     
    508501
    509502    private void FillSeriesWithRowValues(Series series, ScatterPlotDataRow row) {
     503      bool zerosOnly = true;
    510504      for (int i = 0; i < row.Points.Count; i++) {
    511505        var value = row.Points[i];
     
    518512        }
    519513        series.Points.Add(point);
    520       }
     514        if (value.X != 0.0f)
     515          zerosOnly = false;
     516      }
     517      if (zerosOnly) // if all x-values are zero, the x-values are interpreted as 1, 2, 3, ...
     518        series.Points.Add(new DataPoint(1, 1) { IsEmpty = true });
    521519      double correlation = Correlation(row.Points);
    522520      series.LegendToolTip = string.Format("Correlation (R²) = {0:G4}", correlation * correlation);
  • branches/symbreg-factors-2650/HeuristicLab.DataPreprocessing.Views/3.4/HeuristicLab.DataPreprocessing.Views-3.4.csproj

    r14421 r14542  
    9898  <ItemGroup>
    9999    <Compile Include="DataPreprocessingMenuItem.cs" />
     100    <Compile Include="PreprocessingCheckedVariablesView.cs">
     101      <SubType>UserControl</SubType>
     102    </Compile>
     103    <Compile Include="PreprocessingCheckedVariablesView.Designer.cs">
     104      <DependentUpon>PreprocessingCheckedVariablesView.cs</DependentUpon>
     105    </Compile>
    100106    <Compile Include="PreprocessingFeatureCorrelationView.cs">
    101107      <SubType>UserControl</SubType>
     
    165171      <DependentUpon>FilterView.cs</DependentUpon>
    166172    </Compile>
    167     <Compile Include="ScatterPlotMultiView.cs" />
     173    <Compile Include="ScatterPlotMultiView.cs">
     174      <SubType>UserControl</SubType>
     175    </Compile>
    168176    <Compile Include="ScatterPlotMultiView.Designer.cs">
    169177      <DependentUpon>ScatterPlotMultiView.cs</DependentUpon>
     
    181189      <DependentUpon>SearchAndReplaceDialog.cs</DependentUpon>
    182190    </Compile>
    183     <Compile Include="HistogramView.cs" />
     191    <Compile Include="HistogramView.cs">
     192      <SubType>UserControl</SubType>
     193    </Compile>
    184194    <Compile Include="HistogramView.Designer.cs">
    185195      <DependentUpon>HistogramView.cs</DependentUpon>
    186196    </Compile>
    187     <Compile Include="LineChartView.cs" />
     197    <Compile Include="LineChartView.cs">
     198      <SubType>UserControl</SubType>
     199    </Compile>
    188200    <Compile Include="LineChartView.Designer.cs">
    189201      <DependentUpon>LineChartView.cs</DependentUpon>
     
    196208    </Compile>
    197209    <Compile Include="Plugin.cs" />
    198     <Compile Include="PreprocessingChartView.cs" />
     210    <Compile Include="PreprocessingChartView.cs">
     211      <SubType>UserControl</SubType>
     212    </Compile>
    199213    <Compile Include="PreprocessingChartView.Designer.cs">
    200214      <DependentUpon>PreprocessingChartView.cs</DependentUpon>
  • branches/symbreg-factors-2650/HeuristicLab.MainForm.WindowsForms/3.3/Views/View.cs

    r14185 r14542  
    3434      this.closeReason = CloseReason.None;
    3535      this.readOnly = false;
     36
    3637      if (ViewAttribute.HasViewAttribute(this.GetType()))
    3738        this.Caption = ViewAttribute.GetViewName(this.GetType());
     
    4546      set {
    4647        if (InvokeRequired) {
    47           Action<string> action = delegate(string s) { this.Caption = s; };
     48          Action<string> action = delegate (string s) { this.Caption = s; };
    4849          Invoke(action, value);
    4950        } else {
     
    6162      set {
    6263        if (InvokeRequired) {
    63           Action<bool> action = delegate(bool b) { this.ReadOnly = b; };
     64          Action<bool> action = delegate (bool b) { this.ReadOnly = b; };
    6465          Invoke(action, value);
    6566        } else {
     
    9495
    9596    protected override void OnEnabledChanged(EventArgs e) {
     97      SuspendRepaint();
    9698      base.OnEnabledChanged(e);
    9799      if (Enabled) SetEnabledStateOfControls();
     100      ResumeRepaint(true);
    98101    }
    99102
  • branches/symbreg-factors-2650/HeuristicLab.Optimization

  • branches/symbreg-factors-2650/HeuristicLab.Optimization.Views

  • branches/symbreg-factors-2650/HeuristicLab.Optimization.Views/3.3/BasicAlgorithmView.cs

    r14185 r14542  
    3636    protected override void SetEnabledStateOfControls() {
    3737      base.SetEnabledStateOfControls();
    38       pauseButton.Enabled = false;
     38      pauseButton.Enabled &= Content != null && Content.SupportsPause;
    3939    }
    4040
    4141    protected override void SetEnabledStateOfExecutableButtons() {
    4242      base.SetEnabledStateOfExecutableButtons();
    43       pauseButton.Enabled = false;
     43      pauseButton.Enabled &= Content != null && Content.SupportsPause;
    4444    }
    4545  }
  • branches/symbreg-factors-2650/HeuristicLab.Optimization/3.3/Algorithms/BasicAlgorithm.cs

    r14185 r14542  
    2424using System.Threading.Tasks;
    2525using HeuristicLab.Common;
     26using HeuristicLab.Core;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2728
     
    2930  [StorableClass]
    3031  public abstract class BasicAlgorithm : Algorithm, IStorableContent {
     32
     33    private bool pausePending;
     34    private DateTime lastUpdateTime;
     35
    3136    public string Filename { get; set; }
    3237
     38    public abstract bool SupportsPause { get; }
     39
    3340    [Storable]
    34     private ResultCollection results;
     41    private bool initialized;
     42    [Storable]
     43    private readonly ResultCollection results;
    3544    public override ResultCollection Results {
    3645      get { return results; }
     
    5867      base.Prepare();
    5968      results.Clear();
     69      initialized = false;
    6070      OnPrepared();
    6171    }
     
    6474      base.Start();
    6575      CancellationTokenSource = new CancellationTokenSource();
     76      pausePending = false;
     77      OnStarted();
    6678
    67       OnStarted();
    68       Task task = Task.Factory.StartNew(Run, cancellationTokenSource.Token, cancellationTokenSource.Token);
     79      Task task = Task.Factory.StartNew(Run, CancellationTokenSource.Token, CancellationTokenSource.Token);
    6980      task.ContinueWith(t => {
    7081        try {
    7182          t.Wait();
    72         } catch (AggregateException ex) {
     83        }
     84        catch (AggregateException ex) {
    7385          try {
    7486            ex.Flatten().Handle(x => x is OperationCanceledException);
    75           } catch (AggregateException remaining) {
     87          }
     88          catch (AggregateException remaining) {
    7689            if (remaining.InnerExceptions.Count == 1) OnExceptionOccurred(remaining.InnerExceptions[0]);
    7790            else OnExceptionOccurred(remaining);
     
    8093        CancellationTokenSource.Dispose();
    8194        CancellationTokenSource = null;
    82         OnStopped();
     95        if (pausePending) OnPaused();
     96        else OnStopped();
    8397      });
    8498    }
    8599
    86100    public override void Pause() {
    87       throw new NotSupportedException("Pause is not supported in basic algorithms.");
     101      // CancellationToken.ThrowIfCancellationRequested() must be called from within the Run method, otherwise pause does nothing
     102      // alternatively check the IsCancellationRequested property of the cancellation token
     103      if (!SupportsPause)
     104        throw new NotSupportedException("Pause is not supported by this algorithm.");
     105
     106      base.Pause();
     107      pausePending = true;
     108      CancellationTokenSource.Cancel();
    88109    }
    89110
     
    92113      // alternatively check the IsCancellationRequested property of the cancellation token
    93114      base.Stop();
    94       CancellationTokenSource.Cancel();
     115      if (ExecutionState == ExecutionState.Paused) OnStopped();
     116      else CancellationTokenSource.Cancel();
    95117    }
    96118
    97 
    98     private DateTime lastUpdateTime;
    99119    private void Run(object state) {
    100120      CancellationToken cancellationToken = (CancellationToken)state;
     
    105125      timer.Start();
    106126      try {
     127        if (!initialized)
     128          Initialize(cancellationToken);
     129        initialized = true;
    107130        Run(cancellationToken);
    108       } finally {
     131      }
     132      finally {
    109133        timer.Elapsed -= new System.Timers.ElapsedEventHandler(timer_Elapsed);
    110134        timer.Stop();
     
    113137    }
    114138
     139    protected virtual void Initialize(CancellationToken cancellationToken) { }
    115140    protected abstract void Run(CancellationToken cancellationToken);
    116141
  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis

  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression

  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4

  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj

    r13241 r14542  
    129129    <Compile Include="Plugin.cs" />
    130130    <Compile Include="SingleObjective\ConstantOptimizationAnalyzer.cs" />
     131    <Compile Include="SingleObjective\Evaluators\SymbolicRegressionVarianceModelEvaluator.cs" />
    131132    <Compile Include="SingleObjective\Evaluators\SymbolicRegressionMeanRelativeErrorEvaluator.cs" />
    132133    <Compile Include="SingleObjective\SymbolicRegressionSolutionsAnalyzer.cs" />
  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Views

  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r14498 r14542  
    428428    <Compile Include="Solution Views\TimeSeriesPrognosisSolutionView.Designer.cs">
    429429      <DependentUpon>TimeSeriesPrognosisSolutionView.cs</DependentUpon>
     430    </Compile>
     431    <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisResidualsLineChartView.cs">
     432      <SubType>UserControl</SubType>
     433    </Compile>
     434    <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisResidualsLineChartView.Designer.cs">
     435      <DependentUpon>TimeSeriesPrognosisResidualsLineChartView.cs</DependentUpon>
    430436    </Compile>
    431437    <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisLineChartView.cs">
  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartViewBase.cs

    r14498 r14542  
    253253    }
    254254
    255     private void ToggleSeriesData(Series series) {
     255    public void ToggleSeriesData(Series series) {
    256256      if (series.Points.Count > 0) {  //checks if series is shown
    257257        if (this.chart.Series.Any(s => s != series && s.Points.Count > 0)) {
  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualsLineChartView.cs

    r14498 r14542  
    4343    }
    4444
    45     private void CalcResiduals(int[] idx, double[] x) {
     45    protected void CalcResiduals(int[] idx, double[] x) {
    4646      var problemData = Content.ProblemData;
    4747      var target = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, idx).ToArray();
     
    8888        base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_ALL_SERIES_NAME].ChartType = SeriesChartType.RangeColumn;
    8989        base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_ALL_SERIES_NAME].Points.DataBindXY(idx, res.Select(_ => 0.0).ToArray(), res);
     90        ToggleSeriesData(base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_ALL_SERIES_NAME]); // don't show by default
    9091      }
    9192    }
  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r14232 r14542  
    4141
    4242    #region parameter properites
     43    //mkommend: inserted parameter caching due to performance reasons
     44    private IFixedValueParameter<Dataset> datasetParameter;
    4345    public IFixedValueParameter<Dataset> DatasetParameter {
    44       get { return (IFixedValueParameter<Dataset>)Parameters[DatasetParameterName]; }
    45     }
     46      get {
     47        if (datasetParameter == null) datasetParameter = (IFixedValueParameter<Dataset>)Parameters[DatasetParameterName];
     48        return datasetParameter;
     49      }
     50    }
     51
     52    private IFixedValueParameter<ReadOnlyCheckedItemList<StringValue>> inputVariablesParameter;
    4653    public IFixedValueParameter<ReadOnlyCheckedItemList<StringValue>> InputVariablesParameter {
    47       get { return (IFixedValueParameter<ReadOnlyCheckedItemList<StringValue>>)Parameters[InputVariablesParameterName]; }
    48     }
     54      get {
     55        if (inputVariablesParameter == null) inputVariablesParameter = (IFixedValueParameter<ReadOnlyCheckedItemList<StringValue>>)Parameters[InputVariablesParameterName];
     56        return inputVariablesParameter;
     57      }
     58    }
     59
     60    private IFixedValueParameter<IntRange> trainingPartitionParameter;
    4961    public IFixedValueParameter<IntRange> TrainingPartitionParameter {
    50       get { return (IFixedValueParameter<IntRange>)Parameters[TrainingPartitionParameterName]; }
    51     }
     62      get {
     63        if (trainingPartitionParameter == null) trainingPartitionParameter = (IFixedValueParameter<IntRange>)Parameters[TrainingPartitionParameterName];
     64        return trainingPartitionParameter;
     65      }
     66    }
     67
     68    private IFixedValueParameter<IntRange> testPartitionParameter;
    5269    public IFixedValueParameter<IntRange> TestPartitionParameter {
    53       get { return (IFixedValueParameter<IntRange>)Parameters[TestPartitionParameterName]; }
    54     }
     70      get {
     71        if (testPartitionParameter == null) testPartitionParameter = (IFixedValueParameter<IntRange>)Parameters[TestPartitionParameterName];
     72        return testPartitionParameter;
     73      }
     74    }
     75
    5576    public IFixedValueParameter<ReadOnlyItemList<ITransformation>> TransformationsParameter {
    5677      get { return (IFixedValueParameter<ReadOnlyItemList<ITransformation>>)Parameters[TransformationsParameterName]; }
     
    102123    public virtual bool IsTrainingSample(int index) {
    103124      return index >= 0 && index < Dataset.Rows &&
    104         TrainingPartition.Start <= index && index < TrainingPartition.End &&
    105         (index < TestPartition.Start || TestPartition.End <= index);
     125             TrainingPartition.Start <= index && index < TrainingPartition.End &&
     126             (index < TestPartition.Start || TestPartition.End <= index);
    106127    }
    107128
     
    214235        InputVariables.SetItemCheckedState(inputVariable, variable != null && data.InputVariables.ItemChecked(variable));
    215236      }
    216 
    217       TrainingPartition.Start = TrainingPartition.End = 0;
    218       TestPartition.Start = 0;
    219       TestPartition.End = Dataset.Rows;
    220237    }
    221238  }
  • branches/symbreg-factors-2650/HeuristicLab.Problems.Instances.Scheduling/3.3/JSSPORLIBInstanceProvider.cs

    r14185 r14542  
    6767          var parser = new JSSPORLIBParser();
    6868          parser.Parse(stream);
    69           var instance = Load(parser);
    70           instance.Name = id.Name;
    71           instance.Description = id.Description;
    72 
    73           return instance;
     69          return Load(parser);
    7470        }
    7571      }
     
    8278      var parser = new JSSPORLIBParser();
    8379      parser.Parse(path);
    84       var instance = Load(parser);
    85       instance.Name = Path.GetFileName(path);
    86       instance.Description = "Loaded from file \"" + path + "\" on " + DateTime.Now.ToString();
    87       return instance;
     80      return Load(parser);
    8881    }
    8982
    9083    private JSSPData Load(JSSPORLIBParser parser) {
    9184      var instance = new JSSPData {
     85        Name = parser.Name,
     86        Description = parser.Description,
    9287        Jobs = parser.Jobs,
    9388        Resources = parser.Resources,
  • branches/symbreg-factors-2650/HeuristicLab.Problems.Instances.Scheduling/3.3/JSSPORLIBParser.cs

    r14185 r14542  
    2424using System.IO;
    2525using System.Linq;
     26using System.Text;
    2627
    2728namespace HeuristicLab.Problems.Instances.Scheduling {
     
    5354
    5455    public void Export(string file) {
    55       using (Stream stream = new FileStream(file, FileMode.Open, FileAccess.Read)) {
     56      using (Stream stream = new FileStream(file, FileMode.Create, FileAccess.ReadWrite)) {
    5657        Export(stream);
    5758      }
     
    6566    /// </remarks>
    6667    /// <param name="stream">The stream to read data from.</param>
    67     /// <returns>True if the file was successfully read or false otherwise.</returns>
    6868    public void Parse(Stream stream) {
    69       var reader = new StreamReader(stream);
    70       Name = reader.ReadLine().Trim();
    71       Description = reader.ReadLine().Trim();
    72       var delim = new char[] { ' ', '\t' };
     69      using (var reader = new StreamReader(stream, Encoding.UTF8, true, 4092, true)) {
     70        Name = reader.ReadLine().Trim();
     71        Description = reader.ReadLine().Trim();
     72        var delim = new char[] {' ', '\t'};
    7373
    74       var info = reader.ReadLine().Split(delim, StringSplitOptions.RemoveEmptyEntries);
    75       Jobs = int.Parse(info[0]);
    76       Resources = int.Parse(info[1]);
    77       ProcessingTimes = new double[Jobs, Resources];
    78       Demands = new int[Jobs, Resources];
     74        var info = reader.ReadLine().Split(delim, StringSplitOptions.RemoveEmptyEntries);
     75        Jobs = int.Parse(info[0]);
     76        Resources = int.Parse(info[1]);
     77        ProcessingTimes = new double[Jobs, Resources];
     78        Demands = new int[Jobs, Resources];
    7979
    80       for (int k = 0; k < Jobs; k++) {
    81         if (reader.EndOfStream) throw new InvalidDataException("Unexpected End of Stream.");
    82         var valLine = reader.ReadLine();
    83         while (String.IsNullOrWhiteSpace(valLine)) valLine = reader.ReadLine();
    84         var vals = valLine.Split(delim, StringSplitOptions.RemoveEmptyEntries);
    85         if (vals.Length > 2 * Resources) {
    86           if (DueDates == null) DueDates = new double[Jobs];
    87           DueDates[k] = double.Parse(vals.Last(), CultureInfo.InvariantCulture.NumberFormat);
    88         }
     80        for (int k = 0; k < Jobs; k++) {
     81          if (reader.EndOfStream) throw new InvalidDataException("Unexpected End of Stream.");
     82          var valLine = reader.ReadLine();
     83          while (String.IsNullOrWhiteSpace(valLine)) valLine = reader.ReadLine();
     84          var vals = valLine.Split(delim, StringSplitOptions.RemoveEmptyEntries);
     85          if (vals.Length > 2 * Resources) {
     86            if (DueDates == null) DueDates = new double[Jobs];
     87            DueDates[k] = double.Parse(vals.Last(), CultureInfo.InvariantCulture.NumberFormat);
     88          }
    8989
    90         for (int i = 0; i < Resources; i++) {
    91           Demands[k, i] = int.Parse(vals[2 * i]);
    92           ProcessingTimes[k, i] = double.Parse(vals[2 * i + 1], CultureInfo.InvariantCulture.NumberFormat);
     90          for (int i = 0; i < Resources; i++) {
     91            Demands[k, i] = int.Parse(vals[2 * i]);
     92            ProcessingTimes[k, i] = double.Parse(vals[2 * i + 1], CultureInfo.InvariantCulture.NumberFormat);
     93          }
    9394        }
    9495      }
    95 
    9696    }
    9797
     98    /// <summary>
     99    /// Writes to the given stream data which is expected to be in the JSSP ORLIB format.
     100    /// </summary>
     101    /// <remarks>
     102    /// The stream is not closed or disposed. The caller has to take care of that.
     103    /// </remarks>
     104    /// <param name="stream">The stream to write data to.</param>
    98105    public void Export(Stream stream) {
    99       var writer = new StreamWriter(stream);
    100       writer.WriteLine(Name);
    101       writer.WriteLine(Description);
    102       writer.WriteLine(Jobs.ToString(CultureInfo.InvariantCulture.NumberFormat) + " " + Resources.ToString(CultureInfo.InvariantCulture.NumberFormat));
    103       for (int i = 0; i < Jobs; i++) {
    104         for (int j = 0; j < Resources; j++) {
    105           writer.Write(Demands[i, j] + " " + ProcessingTimes[i, j] + " ");
     106      using (var writer = new StreamWriter(stream, Encoding.UTF8, 4092, true)) {
     107        writer.WriteLine(Name);
     108        writer.WriteLine(Description);
     109        writer.WriteLine(Jobs.ToString(CultureInfo.InvariantCulture.NumberFormat) + " " + Resources.ToString(CultureInfo.InvariantCulture.NumberFormat));
     110        for (int i = 0; i < Jobs; i++) {
     111          for (int j = 0; j < Resources; j++) {
     112            writer.Write(Demands[i, j] + " " + ProcessingTimes[i, j] + " ");
     113          }
     114          if (DueDates != null) writer.Write(DueDates[i].ToString("r", CultureInfo.InvariantCulture.NumberFormat));
     115          writer.WriteLine();
    106116        }
    107         if (DueDates != null) writer.Write(DueDates[i].ToString(CultureInfo.InvariantCulture.NumberFormat));
    108         writer.WriteLine();
     117        writer.Flush();
    109118      }
    110       writer.Flush();
    111119    }
    112120
  • branches/symbreg-factors-2650/HeuristicLab.Problems.Instances.VehicleRouting/3.4/GoldenFormat/GoldenParser.cs

    r14185 r14542  
    366366
    367367          int index = int.Parse(tokens[0]);
    368           double value = double.Parse(tokens[1]);
     368          double value = double.Parse(tokens[1], System.Globalization.CultureInfo.InvariantCulture);
    369369
    370370          demands[index] = value;
  • branches/symbreg-factors-2650/HeuristicLab.Problems.Instances.VehicleRouting/3.4/LiLimFormat/LiLimParser.cs

    r14185 r14542  
    149149
    150150        vehicles = int.Parse(m[0].Value);
    151         capacity = double.Parse(m[1].Value);
     151        capacity = double.Parse(m[1].Value, System.Globalization.CultureInfo.InvariantCulture);
    152152
    153153        line = reader.ReadLine();
  • branches/symbreg-factors-2650/HeuristicLab.Problems.Instances.VehicleRouting/3.4/SolomonFormat/SolomonFormatInstanceProvider.cs

    r14498 r14542  
    2121
    2222using System;
     23using System.Globalization;
    2324using System.IO;
    2425using System.Linq;
     
    7475            break;
    7576          case "Distance":
    76             double quality = double.Parse(reader.ReadLine());
     77            double quality = double.Parse(reader.ReadLine(), CultureInfo.InvariantCulture);
    7778            instance.BestKnownQuality = quality;
    7879            break;
  • branches/symbreg-factors-2650/HeuristicLab.Problems.Instances.VehicleRouting/3.4/SolomonFormat/SolomonParser.cs

    r14185 r14542  
    143143
    144144        vehicles = int.Parse(m[0].Value);
    145         capacity = double.Parse(m[1].Value);
     145        capacity = double.Parse(m[1].Value, System.Globalization.CultureInfo.InvariantCulture);
    146146
    147147        for (int i = 0; i < 4; i++) {
  • branches/symbreg-factors-2650/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs

    r14185 r14542  
    4343    #region Default Instance
    4444    private static readonly JSSPData DefaultInstance = new JSSPData() {
     45      Name = "Job Shop Scheduling Problem (JSSP)",
     46      Description = "The default instance of the JSSP problem in HeuristicLab",
    4547      Jobs = 10,
    4648      Resources = 10,
     
    225227          BestKnownQuality = new DoubleValue(MakespanEvaluator.GetMakespan(BestKnownSolution));
    226228      }
    227 
     229      Name = data.Name;
     230      Description = data.Description;
    228231      JobData = jobData;
    229232      Jobs = data.Jobs;
  • branches/symbreg-factors-2650/HeuristicLab.Random/3.3/RandomEnumerable.cs

    r14185 r14542  
    269269        // swapped element because we already returned it.
    270270      }
    271       yield return elements[0];
     271      if (elements.Length > 0)
     272        yield return elements[0];
    272273    }
    273274  }
  • branches/symbreg-factors-2650/HeuristicLab.Tests

  • branches/symbreg-factors-2650/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPTimeSeriesSampleTest.cs

    r14185 r14542  
    5050      SamplesUtils.RunAlgorithm(osga);
    5151
    52       Assert.AreEqual(0.020952753415199643, SamplesUtils.GetDoubleResult(osga, "BestQuality"), 1E-8);
    53       Assert.AreEqual(0.023220938866319357, SamplesUtils.GetDoubleResult(osga, "CurrentAverageQuality"), 1E-8);
    54       Assert.AreEqual(0.023716788824595391, SamplesUtils.GetDoubleResult(osga, "CurrentWorstQuality"), 1E-8);
    55       Assert.AreEqual(48200, SamplesUtils.GetIntResult(osga, "EvaluatedSolutions"));
     52      Assert.AreEqual(0.015441526903606416, SamplesUtils.GetDoubleResult(osga, "BestQuality"), 1E-8);
     53      Assert.AreEqual(0.017420834241279298, SamplesUtils.GetDoubleResult(osga, "CurrentAverageQuality"), 1E-8);
     54      Assert.AreEqual(0.065195703753298972, SamplesUtils.GetDoubleResult(osga, "CurrentWorstQuality"), 1E-8);
     55      Assert.AreEqual(92000, SamplesUtils.GetIntResult(osga, "EvaluatedSolutions"));
    5656    }
    5757
     
    6363      problem.MaximumSymbolicExpressionTreeDepth.Value = 12;
    6464      problem.EvaluatorParameter.Value.HorizonParameter.Value.Value = 10;
     65      problem.ApplyLinearScaling.Value = true;
    6566
    6667      foreach (var symbol in problem.SymbolicExpressionTreeGrammar.Symbols) {
  • branches/symbreg-factors-2650/HeuristicLab.Tests/HeuristicLab.Algorithms.ParameterlessPopulationPyramid-3.3/ParameterlessPopulationPyramidTest.cs

    r14185 r14542  
    3939      PrivateObject hidden = new PrivateObject(solver);
    4040      try {
    41         hidden.Invoke("Run", new CancellationToken());
     41        var ct = new CancellationToken();
     42        hidden.Invoke("Initialize", ct);
     43        hidden.Invoke("Run", ct);
    4244      } catch (OperationCanceledException) {
    4345        // Ignore
Note: See TracChangeset for help on using the changeset viewer.