- Timestamp:
- 11/24/15 17:44:26 (9 years ago)
- Location:
- branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems
- Files:
-
- 1 deleted
- 3 edited
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/CombinedEncoding.cs
r13372 r13376 29 29 30 30 namespace HeuristicLab.Optimization { 31 [Item(" MultiEncoding", "Describes a combined encoding consisting of multiple simpler encodings.")]31 [Item("CombinedEncoding", "Describes a combined encoding consisting of multiple simpler encodings.")] 32 32 [StorableClass] 33 public sealed class MultiEncoding : Encoding<CombinedSolution> {33 public sealed class CombinedEncoding : Encoding<CombinedSolution> { 34 34 35 35 private ItemCollection<IEncoding> encodings; … … 46 46 47 47 [StorableConstructor] 48 private MultiEncoding(bool deserializing) : base(deserializing) { }49 public override IDeepCloneable Clone(Cloner cloner) { return new MultiEncoding(this, cloner); }50 private MultiEncoding(MultiEncoding original, Cloner cloner)48 private CombinedEncoding(bool deserializing) : base(deserializing) { } 49 public override IDeepCloneable Clone(Cloner cloner) { return new CombinedEncoding(this, cloner); } 50 private CombinedEncoding(CombinedEncoding original, Cloner cloner) 51 51 : base(original, cloner) { 52 52 encodings = new ItemCollection<IEncoding>(original.Encodings.Select(cloner.Clone)); 53 53 } 54 public MultiEncoding()55 : base(" MultiEncoding") {54 public CombinedEncoding() 55 : base("CombinedEncoding") { 56 56 encodings = new ItemCollection<IEncoding>(); 57 57 SolutionCreator = new MultiEncodingCreator() { SolutionParameter = { ActualName = Name } }; … … 62 62 } 63 63 64 public MultiEncoding Add(IEncoding encoding) {65 if (encoding is MultiEncoding) throw new InvalidOperationException("Nesting of MultiEncodings is not supported.");64 public CombinedEncoding Add(IEncoding encoding) { 65 if (encoding is CombinedEncoding) throw new InvalidOperationException("Nesting of CombinedEncodings is not supported."); 66 66 if (Encodings.Any(e => e.Name == encoding.Name)) throw new ArgumentException("Encoding name must be unique", "encoding.Name"); 67 67 encodings.Add(encoding); -
branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/CombinedSolution.cs
r13372 r13376 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Linq; 25 24 using HeuristicLab.Common; … … 32 31 public sealed class CombinedSolution : Item, ISolution { 33 32 34 private MultiEncoding Encoding { get; set; }35 pr otected IScope Scope { get; privateset; }33 private CombinedEncoding Encoding { get; set; } 34 private IScope Scope { get; set; } 36 35 37 36 [StorableConstructor] 38 37 private CombinedSolution(bool deserializing) : base(deserializing) { } 39 40 38 private CombinedSolution(CombinedSolution original, Cloner cloner) 41 39 : base(original, cloner) { … … 43 41 Scope = cloner.Clone(original.Scope); 44 42 } 45 public CombinedSolution(IScope scope, MultiEncoding encoding) {43 public CombinedSolution(IScope scope, CombinedEncoding encoding) { 46 44 Encoding = encoding; 47 45 Scope = scope; -
branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiEncodingCreator.cs
r13359 r13376 65 65 66 66 public override IOperation InstrumentedApply() { 67 SolutionParameter.ActualValue = new CombinedSolution(ExecutionContext.Scope, ( MultiEncoding)EncodingParameter.ActualValue);67 SolutionParameter.ActualValue = new CombinedSolution(ExecutionContext.Scope, (CombinedEncoding)EncodingParameter.ActualValue); 68 68 return base.InstrumentedApply(); 69 69 } -
branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiEncodingCrossover.cs
r13359 r13376 38 38 39 39 public override IOperation InstrumentedApply() { 40 SolutionParameter.ActualValue = new CombinedSolution(ExecutionContext.Scope, ( MultiEncoding)EncodingParameter.ActualValue);40 SolutionParameter.ActualValue = new CombinedSolution(ExecutionContext.Scope, (CombinedEncoding)EncodingParameter.ActualValue); 41 41 return base.InstrumentedApply(); 42 42 } -
branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Problem.cs
r13365 r13376 127 127 if (oldEncoding.GetType() != newEncoding.GetType()) return; 128 128 129 if (oldEncoding.GetType() == typeof( MultiEncoding)) {130 var oldMultiEncoding = ( MultiEncoding)oldEncoding;131 var newMultiEncoding = ( MultiEncoding)newEncoding;129 if (oldEncoding.GetType() == typeof(CombinedEncoding)) { 130 var oldMultiEncoding = (CombinedEncoding)oldEncoding; 131 var newMultiEncoding = (CombinedEncoding)newEncoding; 132 132 if (!oldMultiEncoding.Encodings.SequenceEqual(newMultiEncoding.Encodings, new TypeEqualityComparer<IEncoding>())) return; 133 133
Note: See TracChangeset
for help on using the changeset viewer.