Changeset 10399 for branches/HeuristicLab.Problems.GPDL/Examples
- Timestamp:
- 01/26/14 12:50:13 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GPDL/Examples/symbreg HEAL.txt
r10099 r10399 4 4 double[,] x; 5 5 double[] y; 6 string[] variableNames;6 int[] variables; 7 7 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 }20 8 21 9 double RSquared(IEnumerable<double> xs, IEnumerable<double> ys) { … … 55 43 // generate 500 cases of poly-10 benchmark function 56 44 int n = 500; 57 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 }; 58 46 var rand = new System.Random(); 59 47 x = new double[n, 10]; … … 86 74 val IN RANGE <<-10.0>> .. <<10.0>> 87 75 . 88 Var<<out string varName, out double weight>>76 Var<<out int variable, out double weight>> 89 77 CONSTRAINTS 90 var Name IN SET <<variableNames>>78 variable IN SET <<variables>> 91 79 weight IN RANGE <<-10.0>> .. <<10.0>> 92 80 . … … 96 84 RPB<<row, out val>> . 97 85 98 RPB<<int row, out double val>> = LOCAL << string varName; double w; >>86 RPB<<int row, out double val>> = LOCAL << int variable; double w; >> 99 87 Addition<<row, out val>> 100 88 | Subtraction<<row, out val>> 101 89 | Division<<row, out val>> 102 90 | Multiplication<<row, out val>> 103 | Var<<out var Name, out w>> SEM << val = w * GetValue(x, varName, row); >>91 | Var<<out variable, out w>> SEM << val = w * x[row, variable]; >> 104 92 | Const<<out val>> 105 93 .
Note: See TracChangeset
for help on using the changeset viewer.