Changeset 13390 for branches/ProblemRefactoring
- Timestamp:
- 11/24/15 19:15:23 (9 years ago)
- Location:
- branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProgrammableProblem.cs
r13385 r13390 34 34 [Creatable(CreatableAttribute.Categories.Problems, Priority = 120)] 35 35 [StorableClass] 36 public class MultiObjectiveProgrammableProblem<TEncoding, TSolution> : MultiObjectiveProblem<TEncoding, TSolution>, IProgrammableItem, IProgrammableProblem36 public abstract class MultiObjectiveProgrammableProblem<TEncoding, TSolution> : MultiObjectiveProblem<TEncoding, TSolution>, IProgrammableItem, IProgrammableProblem 37 37 where TEncoding : class, IEncoding<TSolution> 38 38 where TSolution : class, ISolution { … … 60 60 } 61 61 62 [StorableConstructor] 63 protected MultiObjectiveProgrammableProblem(bool deserializing) : base(deserializing) { } 62 64 protected MultiObjectiveProgrammableProblem(MultiObjectiveProgrammableProblem<TEncoding, TSolution> original, Cloner cloner) 63 65 : base(original, cloner) { 64 66 RegisterEvents(); 65 67 } 66 public override IDeepCloneable Clone(Cloner cloner) { return new MultiObjectiveProgrammableProblem<TEncoding, TSolution>(this, cloner); }67 68 [StorableConstructor]69 protected MultiObjectiveProgrammableProblem(bool deserializing) : base(deserializing) { }70 68 public MultiObjectiveProgrammableProblem() 71 69 : base() { … … 88 86 Parameters.Remove("Maximization"); 89 87 Parameters.Add(new ValueParameter<BoolArray>("Maximization", "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly()) { Hidden = true }); 90 var multiEnc = ProblemScript.Encoding as CombinedEncoding;91 if (multiEnc != null) multiEnc.Clear();92 88 Encoding = (TEncoding)ProblemScript.Encoding.Clone(); 93 89 -
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblem.cs
r13385 r13390 35 35 [Item("Programmable Problem (single-objective)", "Represents a single-objective problem that can be programmed with a script.")] 36 36 [StorableClass] 37 public class SingleObjectiveProgrammableProblem<TEncoding, TSolution> : SingleObjectiveProblem<TEncoding, TSolution>, IProgrammableItem, IProgrammableProblem37 public abstract class SingleObjectiveProgrammableProblem<TEncoding, TSolution> : SingleObjectiveProblem<TEncoding, TSolution>, IProgrammableItem, IProgrammableProblem 38 38 where TEncoding : class, IEncoding<TSolution> 39 39 where TSolution : class, ISolution { … … 50 50 } 51 51 52 53 52 Script IProgrammableProblem.ProblemScript { 54 53 get { return ProblemScript; } … … 62 61 } 63 62 63 [StorableConstructor] 64 protected SingleObjectiveProgrammableProblem(bool deserializing) : base(deserializing) { } 64 65 protected SingleObjectiveProgrammableProblem(SingleObjectiveProgrammableProblem<TEncoding, TSolution> original, Cloner cloner) 65 66 : base(original, cloner) { 66 67 RegisterEvents(); 67 68 } 68 public override IDeepCloneable Clone(Cloner cloner) { return new SingleObjectiveProgrammableProblem<TEncoding, TSolution>(this, cloner); }69 70 [StorableConstructor]71 protected SingleObjectiveProgrammableProblem(bool deserializing) : base(deserializing) { }72 69 public SingleObjectiveProgrammableProblem() 73 70 : base() { … … 91 88 Parameters.Remove("Maximization"); 92 89 Parameters.Add(new FixedValueParameter<BoolValue>("Maximization", "Set to false if the problem should be minimized.", (BoolValue)new BoolValue(Maximization).AsReadOnly()) { Hidden = true }); 93 var multiEnc = ProblemScript.Encoding as CombinedEncoding;94 if (multiEnc != null) multiEnc.Clear();95 90 Encoding = (TEncoding)ProblemScript.Encoding.Clone(); 96 91 -
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/MultiObjectiveCombinedEncodingProblem_Template.cs
r13380 r13390 22 22 // Add additional initialization code e.g. private variables that you need for evaluating 23 23 //Encoding.Add(new BinaryVectorEncoding("b") { Length = 10 }); 24 //Encoding.Add(new IntegerVectorEncoding("i") { Length = 10, Bounds = new int[,] { { -100, 100 } }});25 //Encoding.Add(new RealVectorEncoding("r") { Length = 10, Bounds = new double[,] { { -100, 100 } }});26 //Encoding.Add(new PermutationEncoding("p") { Length = 20, PermutationType = PermutationTypes.Absolute });24 //Encoding.Add(new IntegerVectorEncoding("i") { Length = 10, Bounds = new IntMatrix(new int[,] { { -100, 100 } }) }); 25 //Encoding.Add(new RealVectorEncoding("r") { Length = 10, Bounds = new DoubleMatrix(new double[,] { { -100, 100 } }) }); 26 //Encoding.Add(new PermutationEncoding("p") { Length = 20, Type = PermutationTypes.Absolute }); 27 27 //Encoding.Add(new LinearLinkageEncoding("lle") { Length = 30 }); 28 28 } … … 31 31 // Use vars.yourVariable to access variables in the variable store i.e. yourVariable 32 32 var quality = new[] { 0.0, 0.0 }; 33 // 34 // 35 // 36 // 33 //var b = solution.GetSolution<BinaryVector>("b"); 34 //quality[0] = b.Count(x => x); // one max! 35 //var r = solution.GetSolution<RealVector>("r"); 36 //quality[1] = r.Select((i, v) => new { Idx = i, Val = v }).Sum(x => b[x.Idx] ? x.Val * x.Val : 0.0); // sphere 37 37 38 38 // NOTE: Check the Maximization property above (true or false)! -
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/SingleObjectiveCombinedEncodingProblem_Template.cs
r13380 r13390 22 22 // Add additional initialization code e.g. private variables that you need for evaluating 23 23 //Encoding.Add(new BinaryVectorEncoding("b") { Length = 10 }); 24 //Encoding.Add(new IntegerVectorEncoding("i") { Length = 10, Bounds = new int[,] { { -100, 100 } }});25 //Encoding.Add(new RealVectorEncoding("r") { Length = 10, Bounds = new double[,] { { -100, 100 } }});26 //Encoding.Add(new PermutationEncoding("p") { Length = 20, PermutationType = PermutationTypes.Absolute });24 //Encoding.Add(new IntegerVectorEncoding("i") { Length = 10, Bounds = new IntMatrix(new int[,] { { -100, 100 } }) }); 25 //Encoding.Add(new RealVectorEncoding("r") { Length = 10, Bounds = new DoubleMatrix(new double[,] { { -100, 100 } }) }); 26 //Encoding.Add(new PermutationEncoding("p") { Length = 20, Type = PermutationTypes.Absolute }); 27 27 //Encoding.Add(new LinearLinkageEncoding("lle") { Length = 30 }); 28 28 } … … 31 31 // Use vars.yourVariable to access variables in the variable store i.e. yourVariable 32 32 var quality = 0.0; 33 // 34 // 35 // 36 // 33 //var b = solution.GetSolution<BinaryVector>("b"); 34 //quality = b.Count(x => x); // one max! 35 //var r = solution.GetSolution<RealVector>("r"); 36 //quality += r.Sum(x => -x * x); // sphere 37 37 38 38 // NOTE: Check the Maximization property above (true or false)!
Note: See TracChangeset
for help on using the changeset viewer.