- Timestamp:
- 11/24/15 16:01:02 (9 years ago)
- Location:
- branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3
- Files:
-
- 1 deleted
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/CompiledProblemDefinition.cs
r13348 r13361 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Threading;25 24 using HeuristicLab.Core; 26 25 using HeuristicLab.Optimization; … … 63 62 public abstract void Analyze(TSolution[] individuals, double[] qualities, ResultCollection results, IRandom random); 64 63 public abstract IEnumerable<TSolution> GetNeighbors(TSolution individual, IRandom random); 64 65 public bool IsBetter(double quality, double bestQuality) { 66 return Maximization ? quality > bestQuality : quality < bestQuality; 67 } 65 68 #endregion 66 69 } -
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/HeuristicLab.Problems.Programmable-3.3.csproj
r13350 r13361 96 96 </Compile> 97 97 <Compile Include="ProblemDefinitionScriptException.cs" /> 98 <Compile Include="MultiObjectiveProgrammableProblems.cs" /> 99 <Compile Include="SingleObjectiveProgrammableProblems.cs" /> 98 <Compile Include="ProgrammableProblemInstances.cs" /> 100 99 <Content Include="Templates\CompiledSingleObjectiveProblemDefinition_Template.cs" /> 101 100 <Content Include="Templates\CompiledMultiObjectiveProblemDefinition_Template.cs"> … … 155 154 <Name>HeuristicLab.Encodings.BinaryVectorEncoding-3.3</Name> 156 155 </ProjectReference> 156 <ProjectReference Include="..\..\HeuristicLab.Encodings.RealVectorEncoding\3.3\HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj"> 157 <Project>{bb6d334a-4bb6-4674-9883-31a6ebb32cab}</Project> 158 <Name>HeuristicLab.Encodings.RealVectorEncoding-3.3</Name> 159 </ProjectReference> 157 160 <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj"> 158 161 <Project>{23da7ff4-d5b8-41b6-aa96-f0561d24f3ee}</Project> -
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/ProgrammableProblemInstances.cs
r13360 r13361 25 25 using HeuristicLab.Core; 26 26 using HeuristicLab.Encodings.BinaryVectorEncoding; 27 using HeuristicLab.Encodings.RealVectorEncoding; 27 28 using HeuristicLab.Optimization; 28 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 30 30 31 namespace HeuristicLab.Problems.Programmable { 32 #region single-objective 31 33 [Item("Binary Vector Programmable Problem (single-objective)", "Represents a binary vector single-objective problem that can be programmed with a script.")] 32 34 [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)] … … 76 78 } 77 79 } 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 } 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 //} 95 96 96 97 [Item("Real Vector Programmable Problem (single-objective)", "Represents a real vector single-objective problem that can be programmed with a script.")] … … 102 103 private SingleObjectiveRealVectorProgrammableProblem(bool deserializing) : base(deserializing) { } 103 104 private SingleObjectiveRealVectorProgrammableProblem(SingleObjectiveRealVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { } 105 104 106 public SingleObjectiveRealVectorProgrammableProblem() 105 : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.RealVectorEncoding", "RealVectorEncoding", "RealVector")) { } 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 } 106 114 107 115 public override IDeepCloneable Clone(Cloner cloner) { … … 110 118 } 111 119 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 }*/ 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 159 305 } -
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProblemDefinitionScript.cs
r13350 r13361 62 62 return CompiledProblemDefinition.GetNeighbors(individual, random); 63 63 } 64 65 bool ISingleObjectiveProblemDefinition<TEncoding, TSolution>.IsBetter(double quality, double bestQuality) { 66 return CompiledProblemDefinition.IsBetter(quality, bestQuality); 67 } 64 68 } 65 69 }
Note: See TracChangeset
for help on using the changeset viewer.