Changeset 13361
- Timestamp:
- 11/24/15 16:01:02 (9 years ago)
- Location:
- branches/ProblemRefactoring
- Files:
-
- 1 deleted
- 19 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemRefactoring/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAEvolutionStrategy.cs
r13173 r13361 63 63 64 64 #region Problem Properties 65 65 66 public override Type ProblemType { 66 get { return typeof(ISingleObjective HeuristicOptimizationProblem); }67 } 68 public new ISingleObjective HeuristicOptimizationProblemProblem {69 get { return (ISingleObjective HeuristicOptimizationProblem)base.Problem; }67 get { return typeof(ISingleObjectiveProblem<RealVectorEncoding, RealVector>); } 68 } 69 public new ISingleObjectiveProblem<RealVectorEncoding, RealVector> Problem { 70 get { return (ISingleObjectiveProblem<RealVectorEncoding, RealVector>)base.Problem; } 70 71 set { base.Problem = value; } 71 72 } … … 378 379 } 379 380 380 protected override void OnStarted() {381 if (!(Problem.SolutionCreator is IRealVectorCreator))382 throw new InvalidOperationException("Problems that do not use RealVectorEncoding cannot be solved by CMA-ES.");383 base.OnStarted();384 }385 386 381 #region Events 387 382 protected override void OnProblemChanged() { -
branches/ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/EvaluationTracker.cs
r13339 r13361 22 22 23 23 using System; 24 using HeuristicLab.Common;24 using System.Collections.Generic; 25 25 using HeuristicLab.Core; 26 using HeuristicLab.Data;27 26 using HeuristicLab.Encodings.BinaryVectorEncoding; 28 27 using HeuristicLab.Optimization; 29 using HeuristicLab.Parameters;30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;31 28 32 29 namespace HeuristicLab.Algorithms.ParameterlessPopulationPyramid { … … 34 31 // B. W. Goldman and W. F. Punch, "Parameter-less Population Pyramid," GECCO, pp. 785–792, 2014 35 32 // and the original source code in C++11 available from: https://github.com/brianwgoldman/Parameter-less_Population_Pyramid 36 internal sealed class EvaluationTracker : SingleObjectiveProblem<BinaryVectorEncoding, BinaryVector> {37 private readonly ISingleObjectiveProblem <BinaryVectorEncoding, BinaryVector> problem;33 internal sealed class EvaluationTracker : ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> { 34 private readonly ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> problem; 38 35 39 36 private int maxEvaluations; … … 60 57 } 61 58 62 public newBinaryVectorEncoding Encoding {59 public BinaryVectorEncoding Encoding { 63 60 get { return problem.Encoding; } 64 61 } 65 62 #endregion 66 63 67 [StorableConstructor] 68 private EvaluationTracker(bool deserializing) : base(deserializing) { } 69 private EvaluationTracker(EvaluationTracker original, Cloner cloner) 70 : base(original, cloner) { 71 problem = cloner.Clone(original.problem); 72 maxEvaluations = original.maxEvaluations; 73 BestQuality = original.BestQuality; 74 Evaluations = original.Evaluations; 75 BestFoundOnEvaluation = original.BestFoundOnEvaluation; 76 BestSolution = cloner.Clone(BestSolution); 77 } 78 public override IDeepCloneable Clone(Cloner cloner) { 79 return new EvaluationTracker(this, cloner); 80 } 81 public EvaluationTracker(ISingleObjectiveProblem<BinaryVectorEncoding, BinaryVector> problem, int maxEvaluations) { 64 public EvaluationTracker(ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> problem, int maxEvaluations) { 82 65 this.problem = problem; 83 66 this.maxEvaluations = maxEvaluations; … … 86 69 Evaluations = 0; 87 70 BestFoundOnEvaluation = 0; 88 89 if (Parameters.ContainsKey("Maximization")) Parameters.Remove("Maximization");90 Parameters.Add(new FixedValueParameter<BoolValue>("Maximization", "Set to false if the problem should be minimized.", (BoolValue)new BoolValue(Maximization).AsReadOnly()) { Hidden = true });91 71 } 92 72 93 public override double Evaluate(BinaryVector vector, IRandom random) { 73 74 75 public double Evaluate(BinaryVector vector, IRandom random) { 94 76 if (Evaluations >= maxEvaluations) throw new OperationCanceledException("Maximum Evaluation Limit Reached"); 95 77 Evaluations++; … … 103 85 } 104 86 105 public overridebool Maximization {87 public bool Maximization { 106 88 get { 107 89 if (problem == null) return false; … … 110 92 } 111 93 112 public overridebool IsBetter(double quality, double bestQuality) {94 public bool IsBetter(double quality, double bestQuality) { 113 95 return problem.IsBetter(quality, bestQuality); 114 96 } 115 97 98 public void Analyze(BinaryVector[] individuals, double[] qualities, ResultCollection results, IRandom random) { 99 problem.Analyze(individuals, qualities, results, random); 100 } 101 102 public IEnumerable<BinaryVector> GetNeighbors(BinaryVector individual, IRandom random) { 103 return problem.GetNeighbors(individual, random); 104 } 116 105 } 117 106 } -
branches/ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/HillClimber.cs
r13339 r13361 49 49 50 50 public override Type ProblemType { 51 get { return typeof(ISingleObjectiveProblem <BinaryVectorEncoding, BinaryVector>); }51 get { return typeof(ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector>); } 52 52 } 53 public new ISingleObjectiveProblem <BinaryVectorEncoding, BinaryVector> Problem {54 get { return (ISingleObjectiveProblem <BinaryVectorEncoding, BinaryVector>)base.Problem; }55 set { base.Problem = value; }53 public new ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> Problem { 54 get { return (ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector>)base.Problem; } 55 set { base.Problem = (IProblem)value; } 56 56 } 57 57 … … 97 97 } 98 98 // In the GECCO paper, Section 2.1 99 public static double ImproveToLocalOptimum(ISingleObjectiveProblem <BinaryVectorEncoding, BinaryVector> problem, BinaryVector solution, double fitness, IRandom rand) {99 public static double ImproveToLocalOptimum(ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> problem, BinaryVector solution, double fitness, IRandom rand) { 100 100 var tried = new HashSet<int>(); 101 101 do { -
branches/ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/LinkageCrossover.cs
r13339 r13361 33 33 public static class LinkageCrossover { 34 34 // In the GECCO paper, Figure 3 35 public static double ImproveUsingTree(LinkageTree tree, IList<BinaryVector> donors, BinaryVector solution, double fitness, ISingleObjectiveProblem <BinaryVectorEncoding, BinaryVector> problem, IRandom rand) {35 public static double ImproveUsingTree(LinkageTree tree, IList<BinaryVector> donors, BinaryVector solution, double fitness, ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> problem, IRandom rand) { 36 36 var options = Enumerable.Range(0, donors.Count).ToArray(); 37 37 foreach (var cluster in tree.Clusters) { … … 48 48 } 49 49 50 private static double Donate(BinaryVector solution, double fitness, BinaryVector source, IEnumerable<int> cluster, ISingleObjectiveProblem <BinaryVectorEncoding, BinaryVector> problem, IRandom rand, out bool changed) {50 private static double Donate(BinaryVector solution, double fitness, BinaryVector source, IEnumerable<int> cluster, ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> problem, IRandom rand, out bool changed) { 51 51 // keep track of which bits flipped to make the donation 52 52 List<int> flipped = new List<int>(); -
branches/ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/ParameterlessPopulationPyramid.cs
r13339 r13361 45 45 get { return typeof(ISingleObjectiveProblem<BinaryVectorEncoding, BinaryVector>); } 46 46 } 47 public new ISingleObjectiveProblem <BinaryVectorEncoding, BinaryVector> Problem {48 get { return (ISingleObjectiveProblem <BinaryVectorEncoding, BinaryVector>)base.Problem; }49 set { base.Problem = value; }47 public new ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> Problem { 48 get { return (ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector>)base.Problem; } 49 set { base.Problem = (IProblem)value; } 50 50 } 51 51 … … 182 182 if (seen.Contains(solution)) return; 183 183 if (level == pyramid.Count) { 184 pyramid.Add(new Population( tracker.Encoding.Length, random));184 pyramid.Add(new Population(Problem.Encoding.Length, random)); 185 185 } 186 186 var copied = (BinaryVector)solution.Clone(); … … 192 192 private double iterate() { 193 193 // Create a random solution 194 BinaryVector solution = new BinaryVector( tracker.Encoding.Length);194 BinaryVector solution = new BinaryVector(Problem.Encoding.Length); 195 195 for (int i = 0; i < solution.Length; i++) { 196 196 solution[i] = random.Next(2) == 1; -
branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorCreator.cs
r12012 r13361 28 28 /// An interface which represents an operator for creating vectors of real-valued data. 29 29 /// </summary> 30 public interface IRealVectorCreator : IRealVectorOperator, ISolutionCreator {30 public interface IRealVectorCreator : IRealVectorOperator, ISolutionCreator<RealVector> { 31 31 IValueLookupParameter<IntValue> LengthParameter { get; } 32 32 IValueLookupParameter<DoubleMatrix> BoundsParameter { get; } -
branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVector.cs
r12012 r13361 23 23 using HeuristicLab.Core; 24 24 using HeuristicLab.Data; 25 using HeuristicLab.Optimization; 25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 27 … … 28 29 [StorableClass] 29 30 [Item("RealVector", "Represents a vector of real values.")] 30 public class RealVector : DoubleArray {31 public class RealVector : DoubleArray, ISolution { 31 32 [StorableConstructor] 32 33 protected RealVector(bool deserializing) : base(deserializing) { } -
branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorEncoding.cs
r12837 r13361 34 34 [Item("RealVectorEncoding", "Describes a real vector encoding.")] 35 35 [StorableClass] 36 public sealed class RealVectorEncoding : Encoding< IRealVectorCreator> {36 public sealed class RealVectorEncoding : Encoding<RealVector> { 37 37 #region Encoding Parameters 38 38 [Storable] … … 95 95 public RealVectorEncoding(string name) : this(name, 10) { } 96 96 public RealVectorEncoding(int length) : this("RealVector", length) { } 97 public RealVectorEncoding(string name, int length, double min = double.MinValue, double max = double.MaxValue)97 public RealVectorEncoding(string name, int length, double min = -1000, double max = 1000) 98 98 : base(name) { 99 99 if (min >= max) throw new ArgumentException("min must be less than max", "min"); … … 318 318 #endregion 319 319 } 320 321 public static class IndividualExtensionMethods {322 public static RealVector RealVector(this Individual individual) {323 var encoding = individual.GetEncoding<RealVectorEncoding>();324 return individual.RealVector(encoding.Name);325 }326 public static RealVector RealVector(this Individual individual, string name) {327 return (RealVector)individual[name];328 }329 }330 320 } -
branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IProblemDefinition.cs
r13339 r13361 20 20 #endregion 21 21 22 22 23 namespace HeuristicLab.Optimization { 23 24 public interface IProblemDefinition<TEncoding, TSolution> -
branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveProblem.cs
r13339 r13361 24 24 25 25 namespace HeuristicLab.Optimization { 26 public interface ISingleObjectiveProblem<TEncoding, TSolution> : IProblem<TEncoding, TSolution>, ISingleObjective ProblemDefinition<TEncoding, TSolution>, ISingleObjectiveHeuristicOptimizationProblem26 public interface ISingleObjectiveProblem<TEncoding, TSolution> : IProblem<TEncoding, TSolution>, ISingleObjectiveHeuristicOptimizationProblem 27 27 where TEncoding : class, IEncoding<TSolution> 28 28 where TSolution : class, ISolution { 29 bool IsBetter(double quality, double bestQuality); 29 30 30 } 31 31 } -
branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveProblemDefinition.cs
r13339 r13361 31 31 void Analyze(TSolution[] individuals, double[] qualities, ResultCollection results, IRandom random); 32 32 IEnumerable<TSolution> GetNeighbors(TSolution individual, IRandom random); 33 bool IsBetter(double quality, double bestQuality); 33 34 } 34 35 } -
branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveProblem.cs
r13339 r13361 29 29 namespace HeuristicLab.Optimization { 30 30 [StorableClass] 31 public abstract class MultiObjectiveProblem<TEncoding, TSolution> : Problem<TEncoding, TSolution, MultiObjectiveEvaluator<TSolution>>, IMultiObjectiveHeuristicOptimizationProblem, IMultiObjectiveProblemDefinition<TEncoding, TSolution> 31 public abstract class MultiObjectiveProblem<TEncoding, TSolution> : 32 Problem<TEncoding, TSolution, MultiObjectiveEvaluator<TSolution>>, 33 IMultiObjectiveProblem<TEncoding, TSolution>, 34 IMultiObjectiveProblemDefinition<TEncoding, TSolution> 32 35 where TEncoding : class, IEncoding<TSolution> 33 36 where TSolution : class, ISolution { 37 34 38 [StorableConstructor] 35 39 protected MultiObjectiveProblem(bool deserializing) : base(deserializing) { } -
branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveProblem.cs
r13339 r13361 30 30 namespace HeuristicLab.Optimization { 31 31 [StorableClass] 32 public abstract class SingleObjectiveProblem<TEncoding, TSolution> : Problem<TEncoding, TSolution, SingleObjectiveEvaluator<TSolution>>, ISingleObjectiveProblem<TEncoding, TSolution> 32 public abstract class SingleObjectiveProblem<TEncoding, TSolution> : 33 Problem<TEncoding, TSolution, SingleObjectiveEvaluator<TSolution>>, 34 ISingleObjectiveProblem<TEncoding, TSolution>, 35 ISingleObjectiveProblemDefinition<TEncoding, TSolution> 33 36 where TEncoding : class, IEncoding<TSolution> 34 37 where TSolution : class, ISolution { -
branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
r13356 r13361 123 123 <Compile Include="BasicProblems\Individuals\MultiSolution.cs" /> 124 124 <Compile Include="BasicProblems\Interfaces\IMultiEncodingOperator.cs" /> 125 <Compile Include="BasicProblems\Interfaces\IMultiObjectiveProblem.cs" /> 125 126 <Compile Include="BasicProblems\Interfaces\ISingleObjectiveProblem.cs" /> 126 127 <Compile Include="BasicProblems\MultiEncoding.cs" /> -
branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/Interfaces/IProblem.cs
r13339 r13361 36 36 } 37 37 38 public interface IProblem<TEncoding, TSolution> : IHeuristicOptimizationProblem , IProblemDefinition<TEncoding, TSolution>38 public interface IProblem<TEncoding, TSolution> : IHeuristicOptimizationProblem 39 39 where TEncoding : class, IEncoding<TSolution> 40 40 where TSolution : class, ISolution { -
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 } -
branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs
r12504 r13361 39 39 [StorableClass] 40 40 [Creatable(CreatableAttribute.Categories.Problems, Priority = 90)] 41 public sealed class SingleObjectiveTestFunctionProblem : SingleObjectiveHeuristicOptimizationProblem<ISingleObjectiveTestFunctionProblemEvaluator, IRealVectorCreator>, IStorableContent, IProblemInstanceConsumer<SOTFData> { 41 public sealed class SingleObjectiveTestFunctionProblem : 42 SingleObjectiveHeuristicOptimizationProblem<ISingleObjectiveTestFunctionProblemEvaluator, IRealVectorCreator>, 43 ISingleObjectiveProblem<RealVectorEncoding, RealVector>, IStorableContent, IProblemInstanceConsumer<SOTFData> { 42 44 public string Filename { get; set; } 43 45
Note: See TracChangeset
for help on using the changeset viewer.