Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 4539 was 4214, checked in by abeham, 12 years ago

#567

  • Added problem wizard
File size: 4.4 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.Encodings.PermutationEncoding;
31using HeuristicLab.Optimization;
32using HeuristicLab.Parameters;
33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
34using HeuristicLab.PluginInfrastructure;
35
36namespace HeuristicLab.Problems.TravelingSalesman {
37  [Item("$problemName$", "$problemDescription$")]
38  [Creatable("Problems")]
39  [StorableClass]
40  public sealed class $safeitemname$ : ParameterizedNamedItem, $problemTypeImplementation$ {
41    public override Image ItemImage {
42      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Type; }
43    }
44
45    #region Parameter Properties
46    $problemSpecificParameterProperties$
47    $parameterProperties$
48    #endregion
49
50    #region Properties
51    $problemSpecificProperties$
52    $properties$
53    public IEnumerable<IOperator> Operators {
54      get { return operators; }
55    }
56    #endregion
57
58    [Storable]
59    private List<IOperator> operators;
60
61    [StorableConstructor]
62    private $safeitemname$(bool deserializing) : base(deserializing) { }
63    public $safeitemname$()
64      : base() {
65      // TODO: Create a new instance of evaluator and solution creator
66
67      $problemSpecificParameterInitializers$
68      $parameterInitializers$
69
70      ParameterizeSolutionCreator();
71      ParameterizeEvaluator();
72
73      InitializeOperators();
74      AttachEventHandlers();
75    }
76
77    public override IDeepCloneable Clone(Cloner cloner) {
78      $safeitemname$ clone = ($safeitemname$)base.Clone(cloner);
79      clone.operators = operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
80      // TODO: Clone private fields here
81      clone.AttachEventHandlers();
82      return clone;
83    }
84
85    #region Events
86    public event EventHandler SolutionCreatorChanged;
87    private void OnSolutionCreatorChanged() {
88      EventHandler handler = SolutionCreatorChanged;
89      if (handler != null) handler(this, EventArgs.Empty);
90    }
91    public event EventHandler EvaluatorChanged;
92    private void OnEvaluatorChanged() {
93      EventHandler handler = EvaluatorChanged;
94      if (handler != null) handler(this, EventArgs.Empty);
95    }
96    public event EventHandler OperatorsChanged;
97    private void OnOperatorsChanged() {
98      EventHandler handler = OperatorsChanged;
99      if (handler != null) handler(this, EventArgs.Empty);
100    }
101    public event EventHandler Reset;
102    private void OnReset() {
103      EventHandler handler = Reset;
104      if (handler != null) handler(this, EventArgs.Empty);
105    }
106
107    // TODO: Add your event handlers here
108    #endregion
109
110    #region Helpers
111    [StorableHook(HookType.AfterDeserialization)]
112    private void AfterDeserializationHook() {
113      AttachEventHandlers();
114    }
115
116    private void AttachEventHandlers() {
117      // TODO: Add event handlers to the parameters here
118    }
119
120    private void InitializeOperators() {
121      operators = new List<IOperator>();
122      // TODO: Add custom problem analyzer to the list
123      // TODO: Add operators from the representation either by direct instantiation, or by using ApplicationManager.Manger.GetInstances<T>().Cast<IOperator>()
124    }
125    private void ParameterizeSolutionCreator() {
126      // TODO: Set the parameters of the solution creator
127    }
128    private void ParameterizeEvaluator() {
129      // TODO: Set the parameters of the evaluator
130    }
131    #endregion
132  }
133}
Note: See TracBrowser for help on using the repository browser.