Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/28/20 16:26:46 (5 years ago)
Author:
abeham
Message:

#2521: adapted knapsack, added base call to symbolic expression tree encoding, changed parameterization operators in base classes

Location:
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Encoding.cs

    r17567 r17570  
    118118    public virtual void ConfigureOperators(IEnumerable<IItem> operators) {
    119119      ConfigureSingleObjectiveImprovementOperators(operators.OfType<ISingleObjectiveImprovementOperator>());
     120      ConfigureSingleObjectivePathRelinker(operators.OfType<ISingleObjectivePathRelinker>());
    120121    }
    121122
     
    123124      foreach (var op in operators) {
    124125        op.SolutionParameter.ActualName = Name;
     126        op.SolutionParameter.Hidden = true;
     127      }
     128    }
     129
     130    protected virtual void ConfigureSingleObjectivePathRelinker(IEnumerable<ISingleObjectivePathRelinker> operators) {
     131      foreach (var op in operators.OfType<ISingleObjectivePathRelinker>()) {
     132        op.ParentsParameter.ActualName = Name;
     133        op.ParentsParameter.Hidden = true;
    125134      }
    126135    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Problem.cs

    r17513 r17570  
    138138
    139139    private void RegisterEvents() {
    140       EncodingParameter.ValueChanged += (o, e) => OnEncodingChanged();
    141       EvaluatorParameter.ValueChanged += (o, e) => OnEvaluatorChanged();
     140      EncodingParameter.ValueChanged += (o, e) => { ParameterizeOperators(); OnEncodingChanged(); };
     141      EvaluatorParameter.ValueChanged += (o, e) => { ParameterizeOperators(); OnEvaluatorChanged(); };
    142142      //var multiEncoding = Encoding as MultiEncoding;
    143143      //if (multiEncoding != null) multiEncoding.EncodingsChanged += MultiEncodingOnEncodingsChanged;
    144144    }
    145145
     146    protected override void ParameterizeOperators() {
     147      base.ParameterizeOperators();
     148      Parameterize();
     149    }
     150
    146151    protected virtual void OnEncodingChanged() {
    147       Parameterize();
    148 
    149152      OnOperatorsChanged();
    150153      OnReset();
     
    163166        op.EncodingParameter.ActualName = EncodingParameter.Name;
    164167
     168      Encoding.ConfigureOperators(Operators);
    165169      //var multiEncoding = Encoding as MultiEncoding;
    166170      //if (multiEncoding != null) multiEncoding.EncodingsChanged += MultiEncodingOnEncodingsChanged;
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveProblem.cs

    r17567 r17570  
    7272      BestKnownQualityParameter = cloner.Clone(original.BestKnownQualityParameter);
    7373      MaximizationParameter = cloner.Clone(original.MaximizationParameter);
    74       ParameterizeOperators();
     74      Parameterize();
    7575      RegisterEventHandlers();
    7676    }
     
    9090      Operators.Add(new SingleObjectiveMoveMaker<TEncodedSolution>());
    9191
    92       ParameterizeOperators();
     92      Parameterize();
    9393      RegisterEventHandlers();
    9494    }
     
    105105      Operators.Add(new SingleObjectiveMoveMaker<TEncodedSolution>());
    106106
    107       ParameterizeOperators();
     107      Parameterize();
    108108      RegisterEventHandlers();
    109109    }
     
    111111    [StorableHook(HookType.AfterDeserialization)]
    112112    private void AfterDeserialization() {
    113       ParameterizeOperators();
     113      Parameterize();
    114114      RegisterEventHandlers();
    115115    }
     
    190190    protected override void OnEvaluatorChanged() {
    191191      base.OnEvaluatorChanged();
     192      Evaluator.QualityParameter.ActualNameChanged += QualityParameterOnActualNameChanged;
     193    }
     194
     195    protected virtual void QualityParameterOnActualNameChanged(object sender, EventArgs e) {
    192196      ParameterizeOperators();
    193197    }
    194198
    195     private void ParameterizeOperators() {
     199    protected override void ParameterizeOperators() {
     200      base.ParameterizeOperators();
     201      Parameterize();
     202    }
     203
     204    private void Parameterize() {
    196205      foreach (var op in Operators.OfType<ISingleObjectiveEvaluationOperator<TEncodedSolution>>())
    197206        op.Evaluate = Evaluate;
     
    200209      foreach (var op in Operators.OfType<INeighborBasedOperator<TEncodedSolution>>())
    201210        op.GetNeighbors = GetNeighbors;
     211      foreach (var op in Operators.OfType<ISolutionSimilarityCalculator>()) {
     212        op.SolutionVariableName = Encoding.Name;
     213        op.QualityVariableName = Evaluator.QualityParameter.ActualName;
     214      }
    202215    }
    203216
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Problems/Problem.cs

    r17513 r17570  
    157157
    158158
     159    protected virtual void ParameterizeOperators() {
     160
     161    }
     162
    159163
    160164    #region events
    161165    private void Operators_Changed(object sender, EventArgs e) {
    162166      OnOperatorsChanged();
     167      ParameterizeOperators();
    163168    }
    164169    public event EventHandler OperatorsChanged;
Note: See TracChangeset for help on using the changeset viewer.