Changeset 15353 for branches/SimplifierViewsProgress/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4
- Timestamp:
- 09/07/17 15:32:26 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SimplifierViewsProgress/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs
r15321 r15353 21 21 22 22 using System; 23 using System.Threading.Tasks;24 23 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 24 using HeuristicLab.MainForm; 25 25 using HeuristicLab.Problems.DataAnalysis.Symbolic.Views; 26 26 27 27 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views { 28 28 public partial class InteractiveSymbolicRegressionSolutionSimplifierView : InteractiveSymbolicDataAnalysisSolutionSimplifierView { 29 private readonly SymbolicRegressionSolutionImpactValuesCalculator calculator;30 31 29 public new SymbolicRegressionSolution Content { 32 30 get { return (SymbolicRegressionSolution)base.Content; } … … 34 32 } 35 33 36 protected override ISymbolicDataAnalysisSolutionImpactValuesCalculator ImpactCalculator {37 get { return calculator; }38 }39 40 34 public InteractiveSymbolicRegressionSolutionSimplifierView() 41 : base( ) {35 : base(new SymbolicRegressionSolutionImpactValuesCalculator()) { 42 36 InitializeComponent(); 43 37 this.Caption = "Interactive Regression Solution Simplifier"; 44 calculator = new SymbolicRegressionSolutionImpactValuesCalculator();45 38 } 46 39 … … 51 44 } 52 45 53 protected override async void btnOptimizeConstants_Click(object sender, EventArgs e) {46 protected override ISymbolicExpressionTree OptimizeConstants(ISymbolicDataAnalysisModel model, IDataAnalysisProblemData problemData, IProgress progress) { 54 47 const int constOptIterations = 50; 55 var model = Content.Model; 56 Progress.Start("Optimizing Constants ...", 0); 57 await Task.Run(() => { 58 SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(model.Interpreter, model.SymbolicExpressionTree, Content.ProblemData, Content.ProblemData.TrainingIndices, 59 applyLinearScaling: true, maxIterations: constOptIterations, updateVariableWeights: true, lowerEstimationLimit: model.LowerEstimationLimit, upperEstimationLimit: model.UpperEstimationLimit, 60 iterationReport: (args, func, iter) => { 61 Progress.ProgressValue = (double)iter / (constOptIterations + 1); // (maxIterations + 1) iterations are reported 62 }); 63 }); 64 UpdateModel(Content.Model.SymbolicExpressionTree); // UpdateModel calls Progress.Finish 48 var regressionModelModel = (ISymbolicDataAnalysisModel)model.Clone(); 49 var regressionProblemData = (IRegressionProblemData)problemData; 50 SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(regressionModelModel.Interpreter, regressionModelModel.SymbolicExpressionTree, regressionProblemData, regressionProblemData.TrainingIndices, 51 applyLinearScaling: true, maxIterations: constOptIterations, updateVariableWeights: true, lowerEstimationLimit: regressionModelModel.LowerEstimationLimit, upperEstimationLimit: regressionModelModel.UpperEstimationLimit, 52 iterationCallback: (args, func, obj) => { 53 // (maxIterations + 2) iterations are reported; Math.Min neccecary because of floating-point inaccuracies 54 progress.ProgressValue = Math.Min(progress.ProgressValue + 1.0 / (constOptIterations + 2), 1); 55 }); 56 return model.SymbolicExpressionTree; 65 57 } 66 58 }
Note: See TracChangeset
for help on using the changeset viewer.