source: branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/ProgrammableProblemInstances.cs @ 13364

Last change on this file since 13364 was 13364, checked in by mkommend, 7 years ago

#2521: Refactored IntegerVectorEncoding, KnapsackProblem, and P3.

File size: 18.4 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.Encodings.IntegerVectorEncoding;
28using HeuristicLab.Encodings.RealVectorEncoding;
29using HeuristicLab.Optimization;
30using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
31
32namespace HeuristicLab.Problems.Programmable {
33  #region single-objective
34  [Item("Binary Vector Programmable Problem (single-objective)", "Represents a binary vector single-objective problem that can be programmed with a script.")]
35  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
36  [StorableClass]
37  public sealed class SingleObjectiveBinaryVectorProgrammableProblem : SingleObjectiveProgrammableProblem<BinaryVectorEncoding, BinaryVector> {
38
39    [StorableConstructor]
40    private SingleObjectiveBinaryVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
41    private SingleObjectiveBinaryVectorProgrammableProblem(SingleObjectiveBinaryVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
42
43    public SingleObjectiveBinaryVectorProgrammableProblem()
44      : base() {
45      var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
46      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.BinaryVectorEncoding");
47      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "BinaryVectorEncoding");
48      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "BinaryVector");
49      ProblemScript.Code = codeTemplate;
50    }
51
52
53    public override IDeepCloneable Clone(Cloner cloner) {
54      return new SingleObjectiveBinaryVectorProgrammableProblem(this, cloner);
55    }
56  }
57
58  [Item("Multi Solution Programmable Problem (single-objective)", "Represents a multi solution single-objective problem that can be programmed with a script.")]
59  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
60  [StorableClass]
61  public sealed class SingleObjectiveMultiSolutionProgrammableProblem : SingleObjectiveProgrammableProblem<MultiEncoding, CombinedSolution> {
62
63    [StorableConstructor]
64    private SingleObjectiveMultiSolutionProgrammableProblem(bool deserializing) : base(deserializing) { }
65    private SingleObjectiveMultiSolutionProgrammableProblem(SingleObjectiveMultiSolutionProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
66
67    public SingleObjectiveMultiSolutionProgrammableProblem()
68      : base() {
69      var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
70      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.BinaryVectorEncoding");
71      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "MultiEncoding");
72      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "CombinedSolution");
73      ProblemScript.Code = codeTemplate;
74    }
75
76
77    public override IDeepCloneable Clone(Cloner cloner) {
78      return new SingleObjectiveMultiSolutionProgrammableProblem(this, cloner);
79    }
80  }
81
82  [Item("Integer Vector Programmable Problem (single-objective)", "Represents an integer vector single-objective problem that can be programmed with a script.")]
83  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
84  [StorableClass]
85  public sealed class SingleObjectiveIntegerVectorProgrammableProblem : SingleObjectiveProgrammableProblem<IntegerVectorEncoding, IntegerVector> {
86
87    [StorableConstructor]
88    private SingleObjectiveIntegerVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
89    private SingleObjectiveIntegerVectorProgrammableProblem(SingleObjectiveIntegerVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
90
91    public SingleObjectiveIntegerVectorProgrammableProblem()
92      : base() {
93      var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
94      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.IntegerVectorEncoding");
95      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "IntegerVectorEncoding");
96      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "IntegerVector");
97      ProblemScript.Code = codeTemplate;
98    }
99
100    public override IDeepCloneable Clone(Cloner cloner) {
101      return new SingleObjectiveIntegerVectorProgrammableProblem(this, cloner);
102    }
103  }
104
105  [Item("Real Vector Programmable Problem (single-objective)", "Represents a real vector single-objective problem that can be programmed with a script.")]
106  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
107  [StorableClass]
108  public sealed class SingleObjectiveRealVectorProgrammableProblem : SingleObjectiveProgrammableProblem<RealVectorEncoding, RealVector> {
109
110    [StorableConstructor]
111    private SingleObjectiveRealVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
112    private SingleObjectiveRealVectorProgrammableProblem(SingleObjectiveRealVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
113
114    public SingleObjectiveRealVectorProgrammableProblem()
115      : base() {
116      var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
117      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.RealVectorEncoding");
118      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "RealVectorEncoding");
119      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "RealVector");
120      ProblemScript.Code = codeTemplate;
121    }
122
123    public override IDeepCloneable Clone(Cloner cloner) {
124      return new SingleObjectiveRealVectorProgrammableProblem(this, cloner);
125    }
126  }
127
128  //[Item("Permutation Programmable Problem (single-objective)", "Represents a permutation single-objective problem that can be programmed with a script.")]
129  //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
130  //[StorableClass]
131  //public sealed class SingleObjectivePermutationProgrammableProblem : SingleObjectiveProgrammableProblem<PermutationEncoding, Permutation> {
132
133  //  [StorableConstructor]
134  //  private SingleObjectivePermutationProgrammableProblem(bool deserializing) : base(deserializing) { }
135  //  private SingleObjectivePermutationProgrammableProblem(SingleObjectivePermutationProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
136  //  public SingleObjectivePermutationProgrammableProblem()
137  //    : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.PermutationEncoding", "PermutationEncoding", "Permutation")) { }
138
139  //  public override IDeepCloneable Clone(Cloner cloner) {
140  //    return new SingleObjectivePermutationProgrammableProblem(this, cloner);
141  //  }
142  //}
143
144  //[Item("Symbolic Expression Tree Programmable Problem (single-objective)", "Represents a symbolic expression tree single-objective problem that can be programmed with a script.")]
145  //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
146  //[StorableClass]
147  //public sealed class SingleObjectiveSymbolicExpressionTreeProgrammableProblem : SingleObjectiveProgrammableProblem<SymbolicExpressionTreeEncoding, SymbolicExpressionTree> {
148
149  //  [StorableConstructor]
150  //  private SingleObjectiveSymbolicExpressionTreeProgrammableProblem(bool deserializing) : base(deserializing) { }
151  //  private SingleObjectiveSymbolicExpressionTreeProgrammableProblem(SingleObjectiveSymbolicExpressionTreeProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
152  //  public SingleObjectiveSymbolicExpressionTreeProgrammableProblem()
153  //    : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "SymbolicExpressionTreeEncoding", "SymbolicExpressionTree")) { }
154
155  //  public override IDeepCloneable Clone(Cloner cloner) {
156  //    return new SingleObjectiveSymbolicExpressionTreeProgrammableProblem(this, cloner);
157  //  }
158  //}
159
160  //[Item("Linear Linkage Programmable Problem (single-objective)", "Represents a linear linkage single-objective problem that can be programmed with a script.")]
161  //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
162  //[StorableClass]
163  //public sealed class SingleObjectiveLinearLinkageProgrammableProblem : SingleObjectiveProgrammableProblem<LinearLinkageEncoding, LinearLinkage> {
164
165  //  [StorableConstructor]
166  //  private SingleObjectiveLinearLinkageProgrammableProblem(bool deserializing) : base(deserializing) { }
167  //  private SingleObjectiveLinearLinkageProgrammableProblem(SingleObjectiveLinearLinkageProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
168  //  public SingleObjectiveLinearLinkageProgrammableProblem()
169  //    : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.LinearLinkageEncoding", "LinearLinkageEncoding", "LinearLinkage")) { }
170
171  //  public override IDeepCloneable Clone(Cloner cloner) {
172  //    return new SingleObjectiveLinearLinkageProgrammableProblem(this, cloner);
173  //  }
174  //}
175  #endregion
176
177  #region multi-objective
178  [Item("Binary Vector Programmable Problem (multi-objective)", "Represents a binary vector multi-objective problem that can be programmed with a script.")]
179  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
180  [StorableClass]
181  public sealed class MultiObjectiveBinaryVectorProgrammableProblem : MultiObjectiveProgrammableProblem<BinaryVectorEncoding, BinaryVector> {
182
183    [StorableConstructor]
184    private MultiObjectiveBinaryVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
185    private MultiObjectiveBinaryVectorProgrammableProblem(MultiObjectiveBinaryVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
186
187    public MultiObjectiveBinaryVectorProgrammableProblem()
188      : base() {
189      var codeTemplate = ScriptTemplates.CompiledMultiObjectiveProblemDefinition_Template;
190      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.BinaryVectorEncoding");
191      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "BinaryVectorEncoding");
192      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "BinaryVector");
193      ProblemScript.Code = codeTemplate;
194    }
195
196
197    public override IDeepCloneable Clone(Cloner cloner) {
198      return new MultiObjectiveBinaryVectorProgrammableProblem(this, cloner);
199    }
200  }
201
202  [Item("Multi Solution Programmable Problem (multi-objective)", "Represents a multi solution multi-objective problem that can be programmed with a script.")]
203  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
204  [StorableClass]
205  public sealed class MultiObjectiveMultiSolutionProgrammableProblem : MultiObjectiveProgrammableProblem<MultiEncoding, CombinedSolution> {
206
207    [StorableConstructor]
208    private MultiObjectiveMultiSolutionProgrammableProblem(bool deserializing) : base(deserializing) { }
209    private MultiObjectiveMultiSolutionProgrammableProblem(MultiObjectiveMultiSolutionProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
210
211    public MultiObjectiveMultiSolutionProgrammableProblem()
212      : base() {
213      var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
214      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.BinaryVectorEncoding");
215      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "MultiEncoding");
216      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "CombinedSolution");
217      ProblemScript.Code = codeTemplate;
218    }
219
220
221    public override IDeepCloneable Clone(Cloner cloner) {
222      return new MultiObjectiveMultiSolutionProgrammableProblem(this, cloner);
223    }
224  }
225
226  [Item("Integer Vector Programmable Problem (multi-objective)", "Represents an integer vector multi-objective problem that can be programmed with a script.")]
227  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
228  [StorableClass]
229  public sealed class MultiObjectiveIntegerVectorProgrammableProblem : MultiObjectiveProgrammableProblem<IntegerVectorEncoding, IntegerVector> {
230
231    [StorableConstructor]
232    private MultiObjectiveIntegerVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
233    private MultiObjectiveIntegerVectorProgrammableProblem(MultiObjectiveIntegerVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
234
235    public MultiObjectiveIntegerVectorProgrammableProblem()
236      : base() {
237      var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
238      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.IntegerVectorEncoding");
239      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "IntegerVectorEncoding");
240      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "IntegerVector");
241      ProblemScript.Code = codeTemplate;
242    }
243
244    public override IDeepCloneable Clone(Cloner cloner) {
245      return new MultiObjectiveIntegerVectorProgrammableProblem(this, cloner);
246    }
247  }
248
249  [Item("Real Vector Programmable Problem (multi-objective)", "Represents a real vector multi-objective problem that can be programmed with a script.")]
250  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
251  [StorableClass]
252  public sealed class MultiObjectiveRealVectorProgrammableProblem : MultiObjectiveProgrammableProblem<RealVectorEncoding, RealVector> {
253
254    [StorableConstructor]
255    private MultiObjectiveRealVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
256    private MultiObjectiveRealVectorProgrammableProblem(MultiObjectiveRealVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
257
258    public MultiObjectiveRealVectorProgrammableProblem()
259      : base() {
260      var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
261      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.RealVectorEncoding");
262      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "RealVectorEncoding");
263      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "RealVector");
264      ProblemScript.Code = codeTemplate;
265    }
266
267    public override IDeepCloneable Clone(Cloner cloner) {
268      return new MultiObjectiveRealVectorProgrammableProblem(this, cloner);
269    }
270  }
271
272  //[Item("Permutation Programmable Problem (multi-objective)", "Represents a permutation multi-objective problem that can be programmed with a script.")]
273  //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
274  //[StorableClass]
275  //public sealed class MultiObjectivePermutationProgrammableProblem : MultiObjectiveProgrammableProblem<PermutationEncoding, Permutation> {
276
277  //  [StorableConstructor]
278  //  private MultiObjectivePermutationProgrammableProblem(bool deserializing) : base(deserializing) { }
279  //  private MultiObjectivePermutationProgrammableProblem(MultiObjectivePermutationProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
280  //  public MultiObjectivePermutationProgrammableProblem()
281  //    : base(string.Format(ScriptTemplates.CompiledMultiObjectiveProblemDefinition, "HeuristicLab.Encodings.PermutationEncoding", "PermutationEncoding", "Permutation")) { }
282
283  //  public override IDeepCloneable Clone(Cloner cloner) {
284  //    return new MultiObjectivePermutationProgrammableProblem(this, cloner);
285  //  }
286  //}
287
288  //[Item("Symbolic Expression Tree Programmable Problem (multi-objective)", "Represents a symbolic expression tree multi-objective problem that can be programmed with a script.")]
289  //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
290  //[StorableClass]
291  //public sealed class MultiObjectiveSymbolicExpressionTreeProgrammableProblem : MultiObjectiveProgrammableProblem<SymbolicExpressionTreeEncoding, SymbolicExpressionTree> {
292
293  //  [StorableConstructor]
294  //  private MultiObjectiveSymbolicExpressionTreeProgrammableProblem(bool deserializing) : base(deserializing) { }
295  //  private MultiObjectiveSymbolicExpressionTreeProgrammableProblem(MultiObjectiveSymbolicExpressionTreeProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
296  //  public MultiObjectiveSymbolicExpressionTreeProgrammableProblem()
297  //    : base(string.Format(ScriptTemplates.CompiledMultiObjectiveProblemDefinition, "HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "SymbolicExpressionTreeEncoding", "SymbolicExpressionTree")) { }
298
299  //  public override IDeepCloneable Clone(Cloner cloner) {
300  //    return new MultiObjectiveSymbolicExpressionTreeProgrammableProblem(this, cloner);
301  //  }
302  //}
303
304  //[Item("Linear Linkage Programmable Problem (multi-objective)", "Represents a linear linkage multi-objective problem that can be programmed with a script.")]
305  //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
306  //[StorableClass]
307  //public sealed class MultiObjectiveLinearLinkageProgrammableProblem : MultiObjectiveProgrammableProblem<LinearLinkageEncoding, LinearLinkage> {
308
309  //  [StorableConstructor]
310  //  private MultiObjectiveLinearLinkageProgrammableProblem(bool deserializing) : base(deserializing) { }
311  //  private MultiObjectiveLinearLinkageProgrammableProblem(MultiObjectiveLinearLinkageProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
312  //  public MultiObjectiveLinearLinkageProgrammableProblem()
313  //    : base(string.Format(ScriptTemplates.CompiledMultiObjectiveProblemDefinition, "HeuristicLab.Encodings.LinearLinkageEncoding", "LinearLinkageEncoding", "LinearLinkage")) { }
314
315  //  public override IDeepCloneable Clone(Cloner cloner) {
316  //    return new MultiObjectiveLinearLinkageProgrammableProblem(this, cloner);
317  //  }
318  //}
319  #endregion
320}
Note: See TracBrowser for help on using the repository browser.