Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/tools/Templates/HeuristicLabProblemTemplate/DefaultProblem.cs @ 5804

Last change on this file since 5804 was 5704, checked in by abeham, 14 years ago

#567

  • Added item template
  • Adapted problem template
  • Enabled tab key to continue editing the next column in the grid
File size: 4.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-$year$ Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Drawing;
25using System.IO;
26using System.Linq;
27using HeuristicLab.Common;
28using HeuristicLab.Core;
29using HeuristicLab.Data;
30using HeuristicLab.Optimization;
31using HeuristicLab.Parameters;
32using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
33using HeuristicLab.PluginInfrastructure;
34
35namespace $rootnamespace$ {
36  [Item("$problemName$", "$problemDescription$")]
37  [Creatable("Problems")]
38  [StorableClass]
39  public sealed class $safeitemname$ : $problemTypeImplementation$ {
40    public override Image ItemImage {
41      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Type; }
42    }
43
44    #region Parameter Properties
45    $parameterProperties$
46    #endregion
47
48    #region Properties
49    $properties$
50    #endregion
51
52    [Storable]
53    private List<IOperator> operators;
54
55    [StorableConstructor]
56    private $safeitemname$(bool deserializing) : base(deserializing) { }
57    public $safeitemname$()
58      : base() {
59      // TODO: Create a new instance of evaluator and solution creator
60
61      $problemSpecificParameterInitializers$
62      $parameterInitializers$
63
64      ParameterizeSolutionCreator();
65      ParameterizeEvaluator();
66
67      InitializeOperators();
68      AttachEventHandlers();
69    }
70
71    public override IDeepCloneable Clone(Cloner cloner) {
72      $safeitemname$ clone = ($safeitemname$)base.Clone(cloner);
73      clone.operators = operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
74      // TODO: Clone private fields here
75      clone.AttachEventHandlers();
76      return clone;
77    }
78
79    #region Events
80    public event EventHandler SolutionCreatorChanged;
81    private void OnSolutionCreatorChanged() {
82      EventHandler handler = SolutionCreatorChanged;
83      if (handler != null) handler(this, EventArgs.Empty);
84    }
85    public event EventHandler EvaluatorChanged;
86    private void OnEvaluatorChanged() {
87      EventHandler handler = EvaluatorChanged;
88      if (handler != null) handler(this, EventArgs.Empty);
89    }
90    public event EventHandler OperatorsChanged;
91    private void OnOperatorsChanged() {
92      EventHandler handler = OperatorsChanged;
93      if (handler != null) handler(this, EventArgs.Empty);
94    }
95    public event EventHandler Reset;
96    private void OnReset() {
97      EventHandler handler = Reset;
98      if (handler != null) handler(this, EventArgs.Empty);
99    }
100
101    // TODO: Add your event handlers here
102    #endregion
103
104    #region Helpers
105    [StorableHook(HookType.AfterDeserialization)]
106    private void AfterDeserializationHook() {
107      AttachEventHandlers();
108    }
109
110    private void AttachEventHandlers() {
111      // TODO: Add event handlers to the parameters here
112    }
113
114    private void InitializeOperators() {
115      operators = new List<IOperator>();
116      // TODO: Add custom problem analyzer to the list
117      // TODO: Add operators from the representation either by direct instantiation, or by using ApplicationManager.Manger.GetInstances<T>().Cast<IOperator>()
118    }
119    private void ParameterizeSolutionCreator() {
120      // TODO: Set the parameters of the solution creator
121    }
122    private void ParameterizeEvaluator() {
123      // TODO: Set the parameters of the evaluator
124    }
125    #endregion
126  }
127}
Note: See TracBrowser for help on using the repository browser.