Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/25/14 23:20:15 (11 years ago)
Author:
gkronber
Message:

#2026 performance improvement for symbolic regression example

File:
1 edited

Legend:

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

    r10394 r10395  
    44  double[] y;
    55  int[] rows;
    6   string[] variableNames;
     6  int[] variables;
    77  double[] randomConsts;
    8  
    9   Dictionary<string,int> nameToCol;
    10  
    11   double GetValue(double[,] data, string varName, int row) {
    12     if(nameToCol == null) {
    13       /* init mapping */
    14       nameToCol = new Dictionary<string, int>();
    15       for(int i=0; i<variableNames.Length; i++) {
    16         nameToCol[variableNames[i]] = i;
    17       }
    18     }
    19     return x[row, nameToCol[varName]];
    20   }
    218
    229  double RSquared(IEnumerable<double> xs, IEnumerable<double> ys) {
     
    5643  // generate 500 cases of poly-10 benchmark function
    5744  int n = 500;
    58   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};
    5946  var rand = new System.Random(31415);
    6047  x = new double[n, 10];
     
    9178  .
    9279
    93   Var<<out string varName>>
     80  Var<<out int variable>>
    9481    CONSTRAINTS
    95       varName IN SET << variableNames >>
     82      variable IN SET << variables >>
    9683  .
    9784
     
    10087    RPB<<row, out val>> .
    10188
    102   RPB<<int row, out double val>> =                         LOCAL << string varName; >>
     89  RPB<<int row, out double val>> =                         LOCAL << int variable; >>
    10390    Addition<<row, out val>>
    10491    | Subtraction<<row, out val>>
    10592    | Division<<row, out val>>
    10693    | Multiplication<<row, out val>>
    107     | Var<<out varName>>                                   SEM << val = GetValue(x, varName, row); >>
     94    | Var<<out variable>>                                  SEM << val = x[row, variable]; >>
    10895    /* | ERC<<out val>>  */
    10996  .
Note: See TracChangeset for help on using the changeset viewer.