Changeset 15360
- Timestamp:
- 09/13/17 08:14:29 (7 years ago)
- Location:
- branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4
-
Property
svn:ignore
set to
Plugin.cs
-
Property
svn:ignore
set to
-
branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis.MCTSSymbReg.csproj
r15359 r15360 10 10 <RootNamespace>HeuristicLab.Algorithms.DataAnalysis.MCTSSymbReg</RootNamespace> 11 11 <AssemblyName>HeuristicLab.Algorithms.DataAnalysis.MCTSSymbReg</AssemblyName> 12 <TargetFrameworkVersion>v4. 5.2</TargetFrameworkVersion>12 <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> 13 13 <FileAlignment>512</FileAlignment> 14 14 <TargetFrameworkProfile /> -
branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/MctsSymbolicRegressionAlgorithm.cs
r14523 r15360 33 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 34 34 using HeuristicLab.Problems.DataAnalysis; 35 using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression; 35 36 36 37 namespace HeuristicLab.Algorithms.DataAnalysis.MctsSymbolicRegression { … … 228 229 var gradEvals = new IntValue(); 229 230 Results.Add(new Result("Gradient evaluations", gradEvals)); 231 var paretoBestModelsResult = new Result("ParetoBestModels", typeof(ItemList<ISymbolicRegressionSolution>)); 232 Results.Add(paretoBestModelsResult); 230 233 231 234 … … 283 286 totalRollouts.Value = state.TotalRollouts; 284 287 288 paretoBestModelsResult.Value = new ItemList<ISymbolicRegressionSolution>(state.ParetoBestModels); 289 285 290 table.Rows["Best quality"].Values.Add(bestQuality.Value); 286 291 table.Rows["Current best quality"].Values.Add(curQuality.Value); -
branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/MctsSymbolicRegressionStatic.cs
r14185 r15360 27 27 using HeuristicLab.Core; 28 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 29 using HeuristicLab.Optimization; 29 30 using HeuristicLab.Problems.DataAnalysis; 30 31 using HeuristicLab.Problems.DataAnalysis.Symbolic; … … 44 45 double BestSolutionTrainingQuality { get; } 45 46 double BestSolutionTestQuality { get; } 47 IEnumerable<ISymbolicRegressionSolution> ParetoBestModels { get; } 46 48 int TotalRollouts { get; } 47 49 int EffectiveRollouts { get; } … … 76 78 private readonly int constOptIterations; 77 79 private readonly double lowerEstimationLimit, upperEstimationLimit; 80 private readonly List<ISymbolicRegressionSolution> paretoBestModels = new List<ISymbolicRegressionSolution>(); 81 private readonly List<double[]> paretoFront = new List<double[]>(); // matching the models 78 82 79 83 private readonly ExpressionEvaluator evaluator, testEvaluator; … … 182 186 } 183 187 } 188 public IEnumerable<ISymbolicRegressionSolution> ParetoBestModels { 189 get { return paretoBestModels; } 190 } 184 191 185 192 public int TotalRollouts { get { return totalRollouts; } } … … 195 202 Eval(code, nParams, out q, out optConsts); 196 203 204 // single objective best 197 205 if (q > bestRSq) { 198 206 bestRSq = q; … … 204 212 Array.Copy(optConsts, bestConsts, bestNParams); 205 213 } 214 // multi-objective best 215 var complexity = // SymbolicDataAnalysisModelComplexityCalculator.CalculateComplexity() TODO 216 Array.FindIndex(code, (opc)=>opc==(byte)OpCodes.Exit); 217 UpdateParetoFront(q, complexity, code, optConsts, nParams, scalingFactor, scalingOffset); 206 218 207 219 return q; 220 } 221 222 private void UpdateParetoFront(double q, int complexity, byte[] code, double[] param, int nParam, 223 double[] scalingFactor, double[] scalingOffset) { 224 double[] best = new double[2]; 225 double[] cur = new double[2] { q, complexity }; 226 bool[] max = new[] { true, false }; 227 var isNonDominated = true; 228 foreach (var e in paretoFront) { 229 var domRes = DominationCalculator<int>.Dominates(cur, e, max, true); 230 if (domRes == DominationResult.IsDominated) { 231 isNonDominated = false; 232 break; 233 } 234 } 235 if(isNonDominated) { 236 paretoFront.Add(cur); 237 238 // create model 239 var treeGen = new SymbolicExpressionTreeGenerator(problemData.AllowedInputVariables.ToArray()); 240 var interpreter = new SymbolicDataAnalysisExpressionTreeLinearInterpreter(); 241 242 var t = new SymbolicExpressionTree(treeGen.Exec(code, param, nParam, scalingFactor, scalingOffset)); 243 var model = new SymbolicRegressionModel(problemData.TargetVariable, t, interpreter, lowerEstimationLimit, upperEstimationLimit); 244 245 var sol = model.CreateRegressionSolution(this.problemData); 246 sol.Name = string.Format("{0:N5} {1}", q, complexity); 247 248 paretoBestModels.Add(sol); 249 } 250 for(int i=paretoFront.Count-2;i>=0;i--) { 251 var @ref = paretoFront[i]; 252 var domRes = DominationCalculator<int>.Dominates(cur, @ref, max, true); 253 if(domRes == DominationResult.Dominates) { 254 paretoFront.RemoveAt(i); 255 paretoBestModels.RemoveAt(i); 256 } 257 } 208 258 } 209 259
Note: See TracChangeset
for help on using the changeset viewer.