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

Last change on this file since 13361 was 13361, checked in by mkommend, 4 years ago

#2521: Adapted real vector encoding, test function problems, P3, CMA-ES and optimization.

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