Opened 8 years ago
#2840 new defect
Avoid side-effects in constructors of data analysis solutions
| Reported by: | abeham | Owned by: | |
|---|---|---|---|
| Priority: | medium | Milestone: | HeuristicLab 3.3.x Backlog |
| Component: | Problems.DataAnalysis.Symbolic | Version: | |
| Keywords: | Cc: |
Description
In #2238 it was decided to strip the grammar off the symbolic expression tree when creating a new solution due to memory optimization reasons.
The changes however lead to a side-effect in the constructor of e.g. SymbolicRegressionSolution. A modification of the tree is not expected or apparent. It would be more friendly to the user of the API if such a kind of optimization is offered via a separate method than the default way through the constructor. Other possibilities would be to use a clone of the model and of the tree in the solution.
Consider the evaluation function of the following programmable problem
public double Evaluate(Individual individual, IRandom random) {
var model = individual.SymbolicExpressionTree();
var model = new SymbolicRegressionModel("Target", model, new SymbolicDataAnalysisExpressionTreeInterpreter());
var solution = new SymbolicRegressionSolution(model, problemData);
return solution.TrainingMeanAbsoluteError;
}
Optimizing this e.g. in a GA results in a NullReferenceException in the SubtreeSwapingCrossover.


