Changeset 10268 for branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic
- Timestamp:
- 12/22/13 13:12:22 (11 years ago)
- Location:
- branches/GrammaticalEvolution
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GrammaticalEvolution
-
Property
svn:ignore
set to
_ReSharper.HeuristicLab.Problems.GrammaticalEvolution
*.suo
-
Property
svn:ignore
set to
-
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicDataAnalysisProblem.cs
r10226 r10268 84 84 get { return (IValueParameter<T>)Parameters[ProblemDataParameterName]; } 85 85 } 86 public IValueParameter< ISymbolicDataAnalysisGrammar> SymbolicExpressionTreeGrammarParameter {87 get { return (IValueParameter< ISymbolicDataAnalysisGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; }86 public IValueParameter<GESymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter { 87 get { return (IValueParameter<GESymbolicExpressionGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; } 88 88 } 89 89 public IValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter { … … 134 134 } 135 135 136 public ISymbolicDataAnalysisGrammar SymbolicExpressionTreeGrammar {136 public GESymbolicExpressionGrammar SymbolicExpressionTreeGrammar { 137 137 get { return SymbolicExpressionTreeGrammarParameter.Value; } 138 138 set { SymbolicExpressionTreeGrammarParameter.Value = value; } … … 174 174 [StorableHook(HookType.AfterDeserialization)] 175 175 private void AfterDeserialization() { 176 if (!Parameters.ContainsKey(ApplyLinearScalingParameterName)) {177 Parameters.Add(new FixedValueParameter<BoolValue>(ApplyLinearScalingParameterName, ApplyLinearScalingParameterDescription, new BoolValue(false)));178 ApplyLinearScalingParameter.Hidden = true;179 180 //it is assumed that for all symbolic regression algorithms linear scaling was set to true181 //there is no possibility to determine the previous value of the parameter as it was stored in the evaluator182 if (GetType().Name.Contains("SymbolicRegression"))183 ApplyLinearScaling.Value = true;184 }185 186 176 RegisterEventHandlers(); 187 177 } … … 194 184 : base(evaluator, solutionCreator) { 195 185 Parameters.Add(new ValueParameter<T>(ProblemDataParameterName, ProblemDataParameterDescription, problemData)); 196 Parameters.Add(new ValueParameter< ISymbolicDataAnalysisGrammar>(SymbolicExpressionTreeGrammarParameterName, SymbolicExpressionTreeGrammarParameterDescription));186 Parameters.Add(new ValueParameter<GESymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName, SymbolicExpressionTreeGrammarParameterDescription)); 197 187 Parameters.Add(new ValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, SymoblicExpressionTreeInterpreterParameterDescription)); 198 188 //Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, MaximumSymbolicExpressionTreeDepthParameterDescription)); … … 213 203 ApplyLinearScalingParameter.Hidden = true; 214 204 215 SymbolicExpressionTreeGrammar = new TypeCoherentExpressionGrammar();205 SymbolicExpressionTreeGrammar = new GESymbolicExpressionGrammar(problemData.AllowedInputVariables, problemData.AllowedInputVariables.Count() * 3); 216 206 SymbolicExpressionTreeInterpreter = new SymbolicDataAnalysisExpressionTreeLinearInterpreter(); 217 207 … … 225 215 } 226 216 217 private void DeregisterGrammarHandler() { 218 SymbolicExpressionTreeGrammarParameter.ValueChanged -= SymbolicExpressionTreeGrammarParameter_ValueChanged; 219 } 220 private void RegisterGrammarHandler() { 221 SymbolicExpressionTreeGrammarParameter.ValueChanged += SymbolicExpressionTreeGrammarParameter_ValueChanged; 222 } 223 227 224 protected virtual void UpdateGrammar() { 228 //SymbolicExpressionTreeGrammar.MaximumFunctionArguments = MaximumFunctionArguments.Value; 229 //SymbolicExpressionTreeGrammar.MaximumFunctionDefinitions = MaximumFunctionDefinitions.Value; 230 foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Variable>()) { 231 if (!varSymbol.Fixed) { 232 varSymbol.AllVariableNames = ProblemData.InputVariables.Select(x => x.Value); 233 varSymbol.VariableNames = ProblemData.AllowedInputVariables; 234 } 235 } 236 foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.VariableCondition>()) { 237 if (!varSymbol.Fixed) { 238 varSymbol.AllVariableNames = ProblemData.InputVariables.Select(x => x.Value); 239 varSymbol.VariableNames = ProblemData.AllowedInputVariables; 240 } 241 } 225 DeregisterGrammarHandler(); 226 // create a new grammar instance with the correct allowed input variables 227 SymbolicExpressionTreeGrammarParameter.Value = 228 new GESymbolicExpressionGrammar(ProblemData.AllowedInputVariables, ProblemData.AllowedInputVariables.Count() * 3); 229 RegisterGrammarHandler(); 242 230 } 243 231 … … 257 245 ProblemDataParameter.Value.Changed += (object sender, EventArgs e) => OnProblemDataChanged(); 258 246 259 SymbolicExpressionTreeGrammarParameter.ValueChanged += new EventHandler(SymbolicExpressionTreeGrammarParameter_ValueChanged);247 RegisterGrammarHandler(); 260 248 261 249 //MaximumFunctionArguments.ValueChanged += new EventHandler(ArchitectureParameterValue_ValueChanged); … … 272 260 273 261 private void SymbolicExpressionTreeGrammarParameter_ValueChanged(object sender, EventArgs e) { 274 UpdateGrammar();275 }276 277 private void ArchitectureParameterValue_ValueChanged(object sender, EventArgs e) {278 262 UpdateGrammar(); 279 263 } -
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicRegressionSingleObjectiveProblem.cs
r10263 r10268 73 73 74 74 RegisterEventHandlers(); 75 ConfigureGrammarSymbols();76 75 InitializeOperators(); 77 76 UpdateEstimationLimits(); … … 84 83 85 84 private void RegisterEventHandlers() { 86 SymbolicExpressionTreeGrammarParameter.ValueChanged += (o, e) => ConfigureGrammarSymbols();85 // nothing to do 87 86 } 88 87 89 private void ConfigureGrammarSymbols() {90 var grammar = SymbolicExpressionTreeGrammar as TypeCoherentExpressionGrammar;91 if (grammar != null) grammar.ConfigureAsDefaultRegressionGrammar();92 }93 88 94 89 private void InitializeOperators() { -
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/IGESymbolicDataAnalysisProblem.cs
r10226 r10268 23 23 using HeuristicLab.Data; 24 24 using HeuristicLab.Optimization; 25 using HeuristicLab.Problems.DataAnalysis; 26 using HeuristicLab.Problems.DataAnalysis.Symbolic; 27 using HeuristicLab.Problems.GrammaticalEvolution; 25 28 26 namespace HeuristicLab.Problems. DataAnalysis.Symbolic{29 namespace HeuristicLab.Problems.GrammaticalEvolution { 27 30 public interface IGESymbolicDataAnalysisProblem : IDataAnalysisProblem, IHeuristicOptimizationProblem { 28 IValueParameter< ISymbolicDataAnalysisGrammar> SymbolicExpressionTreeGrammarParameter { get; }31 IValueParameter<GESymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter { get; } 29 32 IValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter { get; } 30 33 //IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter { get; } … … 36 39 IFixedValueParameter<IntRange> ValidationPartitionParameter { get; } 37 40 38 ISymbolicDataAnalysisGrammar SymbolicExpressionTreeGrammar { get; set; }41 GESymbolicExpressionGrammar SymbolicExpressionTreeGrammar { get; set; } 39 42 ISymbolicDataAnalysisExpressionTreeInterpreter SymbolicExpressionTreeInterpreter { get; set; } 40 43 //IntValue MaximumSymbolicExpressionTreeDepth { get; }
Note: See TracChangeset
for help on using the changeset viewer.