Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblems.cs @ 13351

Last change on this file since 13351 was 13351, checked in by abeham, 8 years ago

#2521: Adapted multi-encoding for new infrastructure

TODO: Evaluator, Analyzer, ... need to be copied

File size: 9.1 KB
Line 
1#region License Information
2
3/* HeuristicLab
4 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
5 *
6 * This file is part of HeuristicLab.
7 *
8 * HeuristicLab is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * HeuristicLab is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#endregion
23
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Encodings.BinaryVectorEncoding;
27using HeuristicLab.Optimization;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Problems.Programmable {
31  [Item("Binary Vector Programmable Problem (single-objective)", "Represents a binary vector single-objective problem that can be programmed with a script.")]
32  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
33  [StorableClass]
34  public sealed class SingleObjectiveBinaryVectorProgrammableProblem : SingleObjectiveProgrammableProblem<BinaryVectorEncoding, BinaryVector> {
35
36    [StorableConstructor]
37    private SingleObjectiveBinaryVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
38    private SingleObjectiveBinaryVectorProgrammableProblem(SingleObjectiveBinaryVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
39
40    public SingleObjectiveBinaryVectorProgrammableProblem()
41      : base() {
42      var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
43      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.BinaryVectorEncoding");
44      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "BinaryVectorEncoding");
45      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "BinaryVector");
46      ProblemScript.Code = codeTemplate;
47    }
48
49
50    public override IDeepCloneable Clone(Cloner cloner) {
51      return new SingleObjectiveBinaryVectorProgrammableProblem(this, cloner);
52    }
53  }
54
55  [Item("Multi Solution Programmable Problem (single-objective)", "Represents a multi solution single-objective problem that can be programmed with a script.")]
56  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
57  [StorableClass]
58  public sealed class SingleObjectiveMultiSolutionProgrammableProblem : SingleObjectiveProgrammableProblem<MultiEncoding, MultiSolution> {
59
60    [StorableConstructor]
61    private SingleObjectiveMultiSolutionProgrammableProblem(bool deserializing) : base(deserializing) { }
62    private SingleObjectiveMultiSolutionProgrammableProblem(SingleObjectiveMultiSolutionProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
63
64    public SingleObjectiveMultiSolutionProgrammableProblem()
65      : base() {
66      var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
67      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.BinaryVectorEncoding");
68      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "MultiEncoding");
69      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "MultiSolution");
70      ProblemScript.Code = codeTemplate;
71    }
72
73
74    public override IDeepCloneable Clone(Cloner cloner) {
75      return new SingleObjectiveMultiSolutionProgrammableProblem(this, cloner);
76    }
77  }
78  //TODO
79  /*
80  [Item("Integer Vector Programmable Problem (single-objective)", "Represents an integer vector single-objective problem that can be programmed with a script.")]
81  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
82  [StorableClass]
83  public sealed class SingleObjectiveIntegerVectorProgrammableProblem : SingleObjectiveProgrammableProblem<IntegerVectorEncoding, IntegerVector> {
84
85    [StorableConstructor]
86    private SingleObjectiveIntegerVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
87    private SingleObjectiveIntegerVectorProgrammableProblem(SingleObjectiveIntegerVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
88    public SingleObjectiveIntegerVectorProgrammableProblem()
89      : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.IntegerVectorEncoding", "IntegerVectorEncoding", "IntegerVector")) { }
90
91    public override IDeepCloneable Clone(Cloner cloner) {
92      return new SingleObjectiveIntegerVectorProgrammableProblem(this, cloner);
93    }
94  }
95
96  [Item("Real Vector Programmable Problem (single-objective)", "Represents a real vector single-objective problem that can be programmed with a script.")]
97  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
98  [StorableClass]
99  public sealed class SingleObjectiveRealVectorProgrammableProblem : SingleObjectiveProgrammableProblem<RealVectorEncoding, RealVector> {
100
101    [StorableConstructor]
102    private SingleObjectiveRealVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
103    private SingleObjectiveRealVectorProgrammableProblem(SingleObjectiveRealVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
104    public SingleObjectiveRealVectorProgrammableProblem()
105      : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.RealVectorEncoding", "RealVectorEncoding", "RealVector")) { }
106
107    public override IDeepCloneable Clone(Cloner cloner) {
108      return new SingleObjectiveRealVectorProgrammableProblem(this, cloner);
109    }
110  }
111
112  [Item("Permutation Programmable Problem (single-objective)", "Represents a permutation single-objective problem that can be programmed with a script.")]
113  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
114  [StorableClass]
115  public sealed class SingleObjectivePermutationProgrammableProblem : SingleObjectiveProgrammableProblem<PermutationEncoding, Permutation> {
116
117    [StorableConstructor]
118    private SingleObjectivePermutationProgrammableProblem(bool deserializing) : base(deserializing) { }
119    private SingleObjectivePermutationProgrammableProblem(SingleObjectivePermutationProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
120    public SingleObjectivePermutationProgrammableProblem()
121      : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.PermutationEncoding", "PermutationEncoding", "Permutation")) { }
122
123    public override IDeepCloneable Clone(Cloner cloner) {
124      return new SingleObjectivePermutationProgrammableProblem(this, cloner);
125    }
126  }
127
128  [Item("Symbolic Expression Tree Programmable Problem (single-objective)", "Represents a symbolic expression tree single-objective problem that can be programmed with a script.")]
129  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
130  [StorableClass]
131  public sealed class SingleObjectiveSymbolicExpressionTreeProgrammableProblem : SingleObjectiveProgrammableProblem<SymbolicExpressionTreeEncoding, SymbolicExpressionTree> {
132
133    [StorableConstructor]
134    private SingleObjectiveSymbolicExpressionTreeProgrammableProblem(bool deserializing) : base(deserializing) { }
135    private SingleObjectiveSymbolicExpressionTreeProgrammableProblem(SingleObjectiveSymbolicExpressionTreeProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
136    public SingleObjectiveSymbolicExpressionTreeProgrammableProblem()
137      : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "SymbolicExpressionTreeEncoding", "SymbolicExpressionTree")) { }
138
139    public override IDeepCloneable Clone(Cloner cloner) {
140      return new SingleObjectiveSymbolicExpressionTreeProgrammableProblem(this, cloner);
141    }
142  }
143
144  [Item("Linear Linkage Programmable Problem (single-objective)", "Represents a linear linkage single-objective problem that can be programmed with a script.")]
145  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
146  [StorableClass]
147  public sealed class SingleObjectiveLinearLinkageProgrammableProblem : SingleObjectiveProgrammableProblem<LinearLinkageEncoding, LinearLinkage> {
148
149    [StorableConstructor]
150    private SingleObjectiveLinearLinkageProgrammableProblem(bool deserializing) : base(deserializing) { }
151    private SingleObjectiveLinearLinkageProgrammableProblem(SingleObjectiveLinearLinkageProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
152    public SingleObjectiveLinearLinkageProgrammableProblem()
153      : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.LinearLinkageEncoding", "LinearLinkageEncoding", "LinearLinkage")) { }
154
155    public override IDeepCloneable Clone(Cloner cloner) {
156      return new SingleObjectiveLinearLinkageProgrammableProblem(this, cloner);
157    }
158  }*/
159}
Note: See TracBrowser for help on using the repository browser.