Changeset 14249 for branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression
- Timestamp:
- 08/09/16 15:34:33 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionConstantOptimizationEvaluator.cs
r14243 r14249 205 205 ConstantTreeNode constantTreeNode = node as ConstantTreeNode; 206 206 VariableTreeNode variableTreeNode = node as VariableTreeNode; 207 BinaryFactorVariableTreeNode factorVariableTreeNode = node as BinaryFactorVariableTreeNode; 207 BinaryFactorVariableTreeNode binFactorVarTreeNode = node as BinaryFactorVariableTreeNode; 208 FactorVariableTreeNode factorVarTreeNode = node as FactorVariableTreeNode; 208 209 if (constantTreeNode != null) 209 210 c[i++] = constantTreeNode.Value; 210 211 else if (updateVariableWeights && variableTreeNode != null) 211 212 c[i++] = variableTreeNode.Weight; 212 else if (updateVariableWeights && factorVariableTreeNode != null) 213 c[i++] = factorVariableTreeNode.Weight; 213 else if (updateVariableWeights && binFactorVarTreeNode != null) 214 c[i++] = binFactorVarTreeNode.Weight; 215 else if (factorVarTreeNode != null) { 216 foreach (var w in factorVarTreeNode.Weights) c[i++] = w; 217 } 214 218 } 215 219 } … … 248 252 alglib.lsfitfit(state, function_cx_1_func, function_cx_1_grad, null, null); 249 253 alglib.lsfitresults(state, out info, out c, out rep); 250 } 251 catch (ArithmeticException) { 254 } catch (ArithmeticException) { 252 255 return originalQuality; 253 } 254 catch (alglib.alglibexception) { 256 } catch (alglib.alglibexception) { 255 257 return originalQuality; 256 258 } … … 273 275 ConstantTreeNode constantTreeNode = node as ConstantTreeNode; 274 276 VariableTreeNode variableTreeNode = node as VariableTreeNode; 275 BinaryFactorVariableTreeNode factorVarTreeNode = node as BinaryFactorVariableTreeNode; 277 BinaryFactorVariableTreeNode binFactorVarTreeNode = node as BinaryFactorVariableTreeNode; 278 FactorVariableTreeNode factorVarTreeNode = node as FactorVariableTreeNode; 276 279 if (constantTreeNode != null) 277 280 constantTreeNode.Value = constants[i++]; 278 281 else if (updateVariableWeights && variableTreeNode != null) 279 282 variableTreeNode.Weight = constants[i++]; 280 else if (updateVariableWeights && factorVarTreeNode != null) 281 factorVarTreeNode.Weight = constants[i++]; 283 else if (updateVariableWeights && binFactorVarTreeNode != null) 284 binFactorVarTreeNode.Weight = constants[i++]; 285 else if (factorVarTreeNode != null) { 286 foreach (var w in factorVarTreeNode.Weights) constants[i++] = w; 287 } 282 288 } 283 289 } … … 321 327 term = par; 322 328 } 329 return true; 330 } 331 if (node.Symbol is FactorVariable) { 332 var factorVarNode = node as FactorVariableTreeNode; 333 var products = new List<Term>(); 334 foreach (var variableValue in factorVarNode.Symbol.GetVariableValues(factorVarNode.VariableName)) { 335 var par = new AutoDiff.Variable(); 336 parameters.Add(par); 337 variableNames.Add(factorVarNode.VariableName); 338 categoricalVariableValues.Add(variableValue); 339 340 var wVar = new AutoDiff.Variable(); 341 variables.Add(wVar); 342 343 products.Add(AutoDiff.TermBuilder.Product(wVar, par)); 344 } 345 term = AutoDiff.TermBuilder.Sum(products); 323 346 return true; 324 347 } … … 494 517 !(n.Symbol is Variable) && 495 518 !(n.Symbol is BinaryFactorVariable) && 519 !(n.Symbol is FactorVariable) && 496 520 !(n.Symbol is Constant) && 497 521 !(n.Symbol is Addition) &&
Note: See TracChangeset
for help on using the changeset viewer.