Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/21/11 16:23:48 (12 years ago)
Author:
sforsten
Message:

#1669: benchmark problems of Nguyen, Korns and Keijzer from http://groups.csail.mit.edu/EVO-DesignOpt/GPBenchmarks/ have been added. The benchmark problems from http://www.vanillamodeling.com/ have been adapted to the ones from Vladislavleva.

Not all benchmarks are working correctly so far, but they will be tested soon.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Benchmarks/3.4/Generator/RegressionBenchmark.cs

    r6991 r7025  
    2020#endregion
    2121
    22 using System.Collections;
    2322using System.Collections.Generic;
    2423using System.Linq;
     
    3130
    3231    #region properties
    33     public abstract List<string> InputVariable { get; }
    34     public abstract string TargetVariable { get; }
    35     public abstract IntRange TrainingPartition { get; }
    36     public abstract IntRange TestPartition { get; }
     32    protected string targetVariable;
     33    protected List<string> inputVariables;
     34    protected IntRange trainingPartition;
     35    protected IntRange testPartition;
     36
     37    public List<string> InputVariable {
     38      get { return inputVariables; }
     39    }
     40
     41    public string TargetVariable {
     42      get { return targetVariable; }
     43    }
     44
     45    public IntRange TrainingPartition {
     46      get { return trainingPartition; }
     47    }
     48
     49    public IntRange TestPartition {
     50      get { return testPartition; }
     51    }
    3752    #endregion
    3853
     
    4257    }
    4358
    44     protected abstract List<double> CalculateFunction(Dictionary<string, IList<double>> data);
     59    protected abstract List<double> CalculateFunction(List<List<double>> data);
    4560
    46     protected abstract Dictionary<string, IList<double>> GenerateInput(Dictionary<string, IList<double>> data);
     61    protected abstract List<List<double>> GenerateInput(List<List<double>> dataList);
    4762
    4863    public IDataAnalysisProblemData GenerateProblemData() {
    49       Dictionary<string, IList<double>> data = new Dictionary<string, IList<double>>();
    50       data.Add(this.TargetVariable, new List<double>());
    51       foreach (var variable in this.InputVariable) {
    52         data.Add(variable, new List<double>());
    53       }
     64      List<string> varNames = new List<string>();
     65      varNames.Add(this.TargetVariable);
     66      varNames.AddRange(InputVariable);
    5467
    55       data = GenerateInput(data);
     68      List<List<double>> dataList = GenerateInput(new List<List<double>>());
    5669
    57       List<IList> values = new List<IList>();
    58       foreach (var valueList in data.Values) {
    59         values.Add((IList)valueList);
    60       }
     70      dataList.Insert(0, CalculateFunction(dataList));
    6171
    62       Dataset dataset = new Dataset(data.Keys, values);
    63       dataset.Name = this.Name;
     72      Dataset dataset = new Dataset(varNames, dataList);
    6473
    6574      RegressionProblemData problemData = new RegressionProblemData(dataset, dataset.DoubleVariables.Skip(1), dataset.DoubleVariables.First());
    6675
    6776      problemData.Name = "Data generated for benchmark problem \"" + this.Name + "\"";
    68 
     77      problemData.Description = this.Description;
    6978
    7079      problemData.TestPartition.Start = this.TestPartition.Start;
     
    7786    }
    7887
    79     //private Dictionary<string, IList<double>> CalculateValues(Dictionary<string, IList<double>> data, DatasetDefinition dataDef) {
    80     //  Random rand = new Random();
    81     //  var combinationDataSet = AllCombinationsOf(dataDef.RangeVariables.Values.Select(range => range.Values).ToList());
    82     //  int index = 0;
    83     //  var help = dataDef.RangeVariables.Keys;
    84     //  foreach (var dataSet in combinationDataSet) {
    85     //    data[help.ElementAt(index)] = dataSet;
    86     //    index++;
    87     //  }
    88     //  List<string> vars = new List<string>(dataDef.RandomVariables.Keys);
    89     //  for (int i = 0; i < dataDef.AmountOfPoints; i++) {
    90     //    foreach (var variable in vars) {
    91     //      data[variable].Add(dataDef.RandomVariables[variable].Next());
    92     //    }
    93     //    //  data[TargetVariable].Add(CalculateFunction(data, vars));
    94     //  }
    95     //  int bla = 0;
    96     //  var test = data.Values.Select((ind) => (ind.ElementAt(bla)));
    97 
    98     //  return data;
    99     //}
    100 
    101     public static List<double> generateSteps(DoubleRange range, double stepWidth) {
     88    public static List<double> GenerateSteps(DoubleRange range, double stepWidth) {
    10289      return Enumerable.Range(0, (int)((range.End - range.Start) / stepWidth) + 1)
    10390                                      .Select(i => (range.Start + i * stepWidth))
     
    10592    }
    10693
    107     public static List<double> generateUniformDistributedValues(int amount, DoubleRange range) {
     94    public static List<double> GenerateUniformDistributedValues(int amount, DoubleRange range) {
    10895      List<double> values = new List<double>();
    10996      System.Random rand = new System.Random();
     
    114101    }
    115102
    116     public static List<double> generateNormalDistributedValues(int amount, double mu, double sigma) {
     103    public static List<double> GenerateNormalDistributedValues(int amount, double mu, double sigma) {
    117104      List<double> values = new List<double>();
    118105      FastRandom rand = new FastRandom();
     
    133120        combinations = AddExtraSet(combinations, set);
    134121
     122      combinations = (from i in Enumerable.Range(0, sets.Count)
     123                      select (from list in combinations
     124                              select list.ElementAt(i)).ToList<double>()).ToList<List<double>>();
     125
    135126      return combinations;
    136127    }
Note: See TracChangeset for help on using the changeset viewer.