Changeset 13652
- Timestamp:
- 03/05/16 19:41:24 (9 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/ExpressionEvaluator.cs
r13651 r13652 183 183 184 184 var f = 1.0 / (maxFx * consts[curParamIdx]); 185 // adjust c so that maxFx*c = 1 TODO: this is not ideal as enforce positive argumentto exp()185 // adjust c so that maxFx*c = 1 TODO: this is not ideal as it enforces positive arguments to exp() 186 186 consts[curParamIdx] *= f; 187 187 -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/MctsSymbolicRegressionAlgorithm.cs
r13651 r13652 70 70 get { return (IFixedValueParameter<IntValue>)Parameters[IterationsParameterName]; } 71 71 } 72 public IFixedValueParameter<IntValue> Max SizeParameter {72 public IFixedValueParameter<IntValue> MaxVariableReferencesParameter { 73 73 get { return (IFixedValueParameter<IntValue>)Parameters[MaxVariablesParameterName]; } 74 74 } … … 115 115 set { SetSeedRandomlyParameter.Value.Value = value; } 116 116 } 117 public int Max Size{118 get { return Max SizeParameter.Value.Value; }119 set { Max SizeParameter.Value.Value = value; }117 public int MaxVariableReferences { 118 get { return MaxVariableReferencesParameter.Value.Value; } 119 set { MaxVariableReferencesParameter.Value.Value = value; } 120 120 } 121 121 public double C { … … 244 244 var problemData = (IRegressionProblemData)Problem.ProblemData.Clone(); 245 245 if (!AllowedFactors.CheckedItems.Any()) throw new ArgumentException("At least on type of factor must be allowed"); 246 var state = MctsSymbolicRegressionStatic.CreateState(problemData, (uint)Seed, Max Size, C, ScaleVariables, ConstantOptimizationIterations,246 var state = MctsSymbolicRegressionStatic.CreateState(problemData, (uint)Seed, MaxVariableReferences, C, ScaleVariables, ConstantOptimizationIterations, 247 247 lowerLimit, upperLimit, 248 248 allowProdOfVars: AllowedFactors.CheckedItems.Any(s => s.Value.Value == VariableProductFactorName), -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/MctsSymbolicRegressionStatic.cs
r13651 r13652 175 175 var treeGen = new SymbolicExpressionTreeGenerator(problemData.AllowedInputVariables.ToArray()); 176 176 var interpreter = new SymbolicDataAnalysisExpressionTreeLinearInterpreter(); 177 var simplifier = new SymbolicDataAnalysisExpressionTreeSimplifier();178 177 179 178 var t = new SymbolicExpressionTree(treeGen.Exec(bestCode, bestConsts, bestNParams, scalingFactor, scalingOffset)); 180 var simpleT = simplifier.Simplify(t); 181 var model = new SymbolicRegressionModel(simpleT, interpreter, lowerEstimationLimit, upperEstimationLimit); 179 var model = new SymbolicRegressionModel(t, interpreter, lowerEstimationLimit, upperEstimationLimit); 182 180 183 181 // model has already been scaled linearly in Eval … … 264 262 alglib.minlmstate state; 265 263 alglib.minlmreport rep = null; 266 alglib.minlmcreatevj(y.Length, optConsts, out state); 264 alglib.minlmcreatevj(y.Length, optConsts, out state); 267 265 alglib.minlmsetcond(state, 0.0, epsF, 0.0, nIters); 268 266 //alglib.minlmsetgradientcheck(state, 0.000001); … … 281 279 282 280 private void Func(double[] arg, double[] fi, object obj) { 283 // 0.5 * MSE and gradient284 281 var code = (byte[])obj; 285 282 evaluator.Exec(code, x, arg, predBuf); // gradients are nParams x vLen … … 376 373 tree.done = true; 377 374 tree.children = null; 375 tree.visits = 1; 378 376 return false; 379 377 } … … 436 434 } 437 435 } 438 return bestChildrenBuf .Count > 0 ? bestChildrenBuf[rand.Next(bestChildrenBuf.Count)] : bestChildrenBuf[0];436 return bestChildrenBuf[rand.Next(bestChildrenBuf.Count)]; 439 437 } 440 438 -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/SymbolicExpressionGenerator.cs
r13650 r13652 113 113 break; 114 114 case OpCodes.Add: { 115 var t1 = stack[topOfStack ];116 var t2 = stack[topOfStack - 1];115 var t1 = stack[topOfStack - 1]; 116 var t2 = stack[topOfStack]; 117 117 topOfStack--; 118 if (t 2.Symbol is Addition) {119 t 2.AddSubtree(t1);118 if (t1.Symbol is Addition) { 119 t1.AddSubtree(t2); 120 120 } else { 121 121 var addNode = addSy.CreateTreeNode(); … … 127 127 } 128 128 case OpCodes.Mul: { 129 var t1 = stack[topOfStack ];130 var t2 = stack[topOfStack - 1];129 var t1 = stack[topOfStack - 1]; 130 var t2 = stack[topOfStack]; 131 131 topOfStack--; 132 if (t 2.Symbol is Multiplication) {133 t 2.AddSubtree(t1);132 if (t1.Symbol is Multiplication) { 133 t1.AddSubtree(t2); 134 134 } else { 135 135 var mulNode = mulSy.CreateTreeNode();
Note: See TracChangeset
for help on using the changeset viewer.