Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/26/14 12:50:13 (11 years ago)
Author:
gkronber
Message:

#2026 performance improvement for the second symbolic regression example

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GPDL/Examples/symbreg HEAL.txt

    r10099 r10399  
    44  double[,] x;
    55  double[] y;
    6   string[] variableNames;
     6  int[] variables;
    77  int[] rows;
    8   Dictionary<string,int> nameToCol;
    9  
    10   double GetValue(double[,] data, string varName, int row) {
    11     if(nameToCol == null) {
    12       /* init mapping */
    13       nameToCol = new Dictionary<string, int>();
    14       for(int i=0; i<variableNames.Length; i++) {
    15         nameToCol[variableNames[i]] = i;
    16       }
    17     }
    18     return x[row, nameToCol[varName]];
    19   }
    208
    219  double RSquared(IEnumerable<double> xs, IEnumerable<double> ys) {
     
    5543  // generate 500 cases of poly-10 benchmark function
    5644  int n = 500;
    57   variableNames = new string[] {"x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10" };
     45  variables = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    5846  var rand = new System.Random();
    5947  x = new double[n, 10];
     
    8674      val IN RANGE <<-10.0>> .. <<10.0>>
    8775  .
    88   Var<<out string varName, out double weight>> 
     76  Var<<out int variable, out double weight>> 
    8977    CONSTRAINTS
    90       varName IN SET <<variableNames>>
     78      variable IN SET <<variables>>
    9179      weight IN RANGE <<-10.0>> .. <<10.0>>
    9280  .
     
    9684    RPB<<row, out val>> .
    9785   
    98   RPB<<int row, out double val>> =                         LOCAL << string varName; double w; >>
     86  RPB<<int row, out double val>> =                         LOCAL << int variable; double w; >>
    9987    Addition<<row, out val>>
    10088    | Subtraction<<row, out val>>
    10189    | Division<<row, out val>>
    10290    | Multiplication<<row, out val>>                       
    103     | Var<<out varName, out w>>                            SEM << val = w * GetValue(x, varName, row); >>
     91    | Var<<out variable, out w>>                            SEM << val = w * x[row, variable]; >>
    10492    | Const<<out val>>
    10593  .
Note: See TracChangeset for help on using the changeset viewer.