Changeset 10395 for branches/HeuristicLab.Problems.GPDL/Examples
- Timestamp:
- 01/25/14 23:20:15 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GPDL/Examples/symbreg Koza.txt
r10394 r10395 4 4 double[] y; 5 5 int[] rows; 6 string[] variableNames;6 int[] variables; 7 7 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 }21 8 22 9 double RSquared(IEnumerable<double> xs, IEnumerable<double> ys) { … … 56 43 // generate 500 cases of poly-10 benchmark function 57 44 int n = 500; 58 variable Names = 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}; 59 46 var rand = new System.Random(31415); 60 47 x = new double[n, 10]; … … 91 78 . 92 79 93 Var<<out string varName>>80 Var<<out int variable>> 94 81 CONSTRAINTS 95 var Name IN SET << variableNames >>82 variable IN SET << variables >> 96 83 . 97 84 … … 100 87 RPB<<row, out val>> . 101 88 102 RPB<<int row, out double val>> = LOCAL << string varName; >>89 RPB<<int row, out double val>> = LOCAL << int variable; >> 103 90 Addition<<row, out val>> 104 91 | Subtraction<<row, out val>> 105 92 | Division<<row, out val>> 106 93 | Multiplication<<row, out val>> 107 | Var<<out var Name>> SEM << val = GetValue(x, varName, row); >>94 | Var<<out variable>> SEM << val = x[row, variable]; >> 108 95 /* | ERC<<out val>> */ 109 96 .
Note: See TracChangeset
for help on using the changeset viewer.