[4188] | 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Drawing;
|
---|
| 25 | using System.IO;
|
---|
| 26 | using System.Linq;
|
---|
| 27 | using HeuristicLab.Common;
|
---|
| 28 | using HeuristicLab.Core;
|
---|
| 29 | using HeuristicLab.Data;
|
---|
| 30 | using HeuristicLab.Encodings.PermutationEncoding;
|
---|
| 31 | using HeuristicLab.Optimization;
|
---|
| 32 | using HeuristicLab.Parameters;
|
---|
| 33 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 34 | using HeuristicLab.PluginInfrastructure;
|
---|
| 35 |
|
---|
| 36 | namespace HeuristicLab.Problems.TravelingSalesman {
|
---|
| 37 | [Item("$problemName$", "$problemDescription$")]
|
---|
| 38 | [Creatable("Problems")]
|
---|
| 39 | [StorableClass]
|
---|
[4214] | 40 | public sealed class $safeitemname$ : ParameterizedNamedItem, $problemTypeImplementation$ {
|
---|
[4188] | 41 | public override Image ItemImage {
|
---|
| 42 | get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Type; }
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | #region Parameter Properties
|
---|
[4214] | 46 | $problemSpecificParameterProperties$
|
---|
[4188] | 47 | $parameterProperties$
|
---|
| 48 | #endregion
|
---|
| 49 |
|
---|
| 50 | #region Properties
|
---|
[4214] | 51 | $problemSpecificProperties$
|
---|
[4188] | 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 |
|
---|
[4214] | 67 | $problemSpecificParameterInitializers$
|
---|
[4188] | 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 | }
|
---|
[4214] | 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 | }
|
---|
[4188] | 131 | #endregion
|
---|
| 132 | }
|
---|
| 133 | }
|
---|