Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3739 for trunk/sources


Ignore:
Timestamp:
05/10/10 14:18:22 (15 years ago)
Author:
swagner
Message:

Added Reset event to IProblem (#1006)

Location:
trunk/sources
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization/3.3/Algorithm.cs

    r3716 r3739  
    265265      problem.EvaluatorChanged -= new EventHandler(Problem_EvaluatorChanged);
    266266      problem.OperatorsChanged -= new EventHandler(Problem_OperatorsChanged);
     267      problem.Reset -= new EventHandler(Problem_Reset);
    267268    }
    268269    protected virtual void RegisterProblemEvents() {
     
    270271      problem.EvaluatorChanged += new EventHandler(Problem_EvaluatorChanged);
    271272      problem.OperatorsChanged += new EventHandler(Problem_OperatorsChanged);
     273      problem.Reset += new EventHandler(Problem_Reset);
    272274    }
    273275    protected virtual void Problem_SolutionCreatorChanged(object sender, EventArgs e) { }
    274276    protected virtual void Problem_EvaluatorChanged(object sender, EventArgs e) { }
    275277    protected virtual void Problem_OperatorsChanged(object sender, EventArgs e) { }
     278    protected virtual void Problem_Reset(object sender, EventArgs e) {
     279      Prepare();
     280    }
    276281
    277282    protected virtual void DeregisterRunsEvents() {
  • trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IProblem.cs

    r3616 r3739  
    3939    event EventHandler EvaluatorChanged;
    4040    event EventHandler OperatorsChanged;
     41    event EventHandler Reset;
    4142  }
    4243}
  • trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3/ArtificialAntProblem.cs

    r3681 r3739  
    230230    public event EventHandler SolutionCreatorChanged;
    231231    private void OnSolutionCreatorChanged() {
    232       var changed = SolutionCreatorChanged;
    233       if (changed != null)
    234         changed(this, EventArgs.Empty);
     232      EventHandler handler = SolutionCreatorChanged;
     233      if (handler != null) handler(this, EventArgs.Empty);
    235234    }
    236235    public event EventHandler EvaluatorChanged;
    237236    private void OnEvaluatorChanged() {
    238       var changed = EvaluatorChanged;
    239       if (changed != null)
    240         changed(this, EventArgs.Empty);
    241     }
    242 
     237      EventHandler handler = EvaluatorChanged;
     238      if (handler != null) handler(this, EventArgs.Empty);
     239    }
    243240    public event EventHandler OperatorsChanged;
    244241    private void OnOperatorsChanged() {
    245       var changed = OperatorsChanged;
    246       if (changed != null)
    247         changed(this, EventArgs.Empty);
     242      EventHandler handler = OperatorsChanged;
     243      if (handler != null) handler(this, EventArgs.Empty);
     244    }
     245    public event EventHandler Reset;
     246    private void OnReset() {
     247      EventHandler handler = Reset;
     248      if (handler != null) handler(this, EventArgs.Empty);
    248249    }
    249250
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionProblem.cs

    r3681 r3739  
    319319    private void RaiseOperatorsChanged(EventArgs e) {
    320320      var changed = OperatorsChanged;
     321      if (changed != null)
     322        changed(this, e);
     323    }
     324    public event EventHandler Reset;
     325    private void RaiseReset(EventArgs e) {
     326      var changed = Reset;
    321327      if (changed != null)
    322328        changed(this, e);
  • trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs

    r3667 r3739  
    187187    public event EventHandler SolutionCreatorChanged;
    188188    private void OnSolutionCreatorChanged() {
    189       if (SolutionCreatorChanged != null)
    190         SolutionCreatorChanged(this, EventArgs.Empty);
     189      EventHandler handler = SolutionCreatorChanged;
     190      if (handler != null) handler(this, EventArgs.Empty);
    191191    }
    192192    public event EventHandler EvaluatorChanged;
    193193    private void OnEvaluatorChanged() {
    194       if (EvaluatorChanged != null)
    195         EvaluatorChanged(this, EventArgs.Empty);
    196     }
    197 
     194      EventHandler handler = EvaluatorChanged;
     195      if (handler != null) handler(this, EventArgs.Empty);
     196    }
    198197    public event EventHandler OperatorsChanged;
    199198    private void OnOperatorsChanged() {
    200       if (OperatorsChanged != null)
    201         OperatorsChanged(this, EventArgs.Empty);
     199      EventHandler handler = OperatorsChanged;
     200      if (handler != null) handler(this, EventArgs.Empty);
     201    }
     202    public event EventHandler Reset;
     203    private void OnReset() {
     204      EventHandler handler = Reset;
     205      if (handler != null) handler(this, EventArgs.Empty);
    202206    }
    203207
  • trunk/sources/HeuristicLab.Problems.OneMax/3.3/OnemaxProblem.cs

    r3667 r3739  
    138138    public event EventHandler SolutionCreatorChanged;
    139139    private void OnSolutionCreatorChanged() {
    140       if (SolutionCreatorChanged != null)
    141         SolutionCreatorChanged(this, EventArgs.Empty);
     140      EventHandler handler = SolutionCreatorChanged;
     141      if (handler != null) handler(this, EventArgs.Empty);
    142142    }
    143143    public event EventHandler EvaluatorChanged;
    144144    private void OnEvaluatorChanged() {
    145       if (EvaluatorChanged != null)
    146         EvaluatorChanged(this, EventArgs.Empty);
    147     }
    148 
     145      EventHandler handler = EvaluatorChanged;
     146      if (handler != null) handler(this, EventArgs.Empty);
     147    }
    149148    public event EventHandler OperatorsChanged;
    150149    private void OnOperatorsChanged() {
    151       if (OperatorsChanged != null)
    152         OperatorsChanged(this, EventArgs.Empty);
     150      EventHandler handler = OperatorsChanged;
     151      if (handler != null) handler(this, EventArgs.Empty);
     152    }
     153    public event EventHandler Reset;
     154    private void OnReset() {
     155      EventHandler handler = Reset;
     156      if (handler != null) handler(this, EventArgs.Empty);
    153157    }
    154158
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs

    r3719 r3739  
    165165    public event EventHandler SolutionCreatorChanged;
    166166    private void OnSolutionCreatorChanged() {
    167       if (SolutionCreatorChanged != null)
    168         SolutionCreatorChanged(this, EventArgs.Empty);
     167      EventHandler handler = SolutionCreatorChanged;
     168      if (handler != null) handler(this, EventArgs.Empty);
    169169    }
    170170    public event EventHandler EvaluatorChanged;
    171171    private void OnEvaluatorChanged() {
    172       if (EvaluatorChanged != null)
    173         EvaluatorChanged(this, EventArgs.Empty);
     172      EventHandler handler = EvaluatorChanged;
     173      if (handler != null) handler(this, EventArgs.Empty);
    174174    }
    175175    public event EventHandler OperatorsChanged;
    176176    private void OnOperatorsChanged() {
    177       if (OperatorsChanged != null)
    178         OperatorsChanged(this, EventArgs.Empty);
    179     }
     177      EventHandler handler = OperatorsChanged;
     178      if (handler != null) handler(this, EventArgs.Empty);
     179    }
     180    public event EventHandler Reset;
     181    private void OnReset() {
     182      EventHandler handler = Reset;
     183      if (handler != null) handler(this, EventArgs.Empty);
     184    }
     185
    180186    private void ProblemSizeParameter_ValueChanged(object sender, EventArgs e) {
    181187      ProblemSize.ValueChanged += new EventHandler(ProblemSize_ValueChanged);
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs

    r3663 r3739  
    191191        BestKnownSolution = new Permutation(PermutationTypes.RelativeUndirected, tourParser.Tour);
    192192      }
     193      OnReset();
    193194    }
    194195    public void ImportFromTSPLIB(string tspFileName, string optimalTourFileName, double bestKnownQuality) {
     
    200201    public event EventHandler SolutionCreatorChanged;
    201202    private void OnSolutionCreatorChanged() {
    202       if (SolutionCreatorChanged != null)
    203         SolutionCreatorChanged(this, EventArgs.Empty);
     203      EventHandler handler = SolutionCreatorChanged;
     204      if (handler != null) handler(this, EventArgs.Empty);
    204205    }
    205206    public event EventHandler EvaluatorChanged;
    206207    private void OnEvaluatorChanged() {
    207       if (EvaluatorChanged != null)
    208         EvaluatorChanged(this, EventArgs.Empty);
     208      EventHandler handler = EvaluatorChanged;
     209      if (handler != null) handler(this, EventArgs.Empty);
    209210    }
    210211    public event EventHandler OperatorsChanged;
    211212    private void OnOperatorsChanged() {
    212       if (OperatorsChanged != null)
    213         OperatorsChanged(this, EventArgs.Empty);
     213      EventHandler handler = OperatorsChanged;
     214      if (handler != null) handler(this, EventArgs.Empty);
     215    }
     216    public event EventHandler Reset;
     217    private void OnReset() {
     218      EventHandler handler = Reset;
     219      if (handler != null) handler(this, EventArgs.Empty);
    214220    }
    215221
Note: See TracChangeset for help on using the changeset viewer.