Changeset 17363 for branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SolutionContext.cs
- Timestamp:
- 11/21/19 17:58:32 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SolutionContext.cs
r17358 r17363 30 30 namespace HeuristicLab.Optimization { 31 31 [StorableType("72638F28-11DD-440D-B7A2-79E16E0EFB83")] 32 public abstract class SolutionContext : Item { 32 public abstract class SolutionContext<TEncodedSolution> : Item, ISolutionContext 33 where TEncodedSolution : class, IEncodedSolution { 33 34 34 35 [Storable] 35 36 private readonly Dictionary<string, object> data = new Dictionary<string, object>(); 36 37 38 IEncodedSolution ISolutionContext.EncodedSolution { get { return EncodedSolution; } } 39 37 40 [Storable] 38 public IEncodedSolution EncodedSolution { get; private set; }41 public TEncodedSolution EncodedSolution { get; private set; } 39 42 40 43 [Storable] … … 43 46 public bool IsEvaluated => EvaluationResult != null; 44 47 45 protected SolutionContext( IEncodedSolution encodedSolution) : base() {48 protected SolutionContext(TEncodedSolution encodedSolution) : base() { 46 49 EncodedSolution = encodedSolution ?? throw new ArgumentNullException("encodedSolution"); 47 50 } 48 51 49 protected SolutionContext( IEncodedSolution encodedSolution, IEvaluationResult evaluationResult) : this(encodedSolution) {52 protected SolutionContext(TEncodedSolution encodedSolution, IEvaluationResult evaluationResult) : this(encodedSolution) { 50 53 EvaluationResult = evaluationResult ?? throw new ArgumentNullException("evaluationResult"); 51 54 } … … 54 57 protected SolutionContext(StorableConstructorFlag _) : base(_) { } 55 58 56 public SolutionContext(SolutionContext original, Cloner cloner) : base(original, cloner) {59 public SolutionContext(SolutionContext<TEncodedSolution> original, Cloner cloner) : base(original, cloner) { 57 60 //TODO clone data dictionary 58 61 EncodedSolution = cloner.Clone(original.EncodedSolution); … … 69 72 70 73 [StorableType("DF6DA9C9-7EF4-4DC3-9855-6C43BDEDD735")] 71 public class SingleObjectiveSolutionContext : SolutionContext, ISingleObjectiveSolutionContext { 74 public class SingleObjectiveSolutionContext<TEncodedSolution> : SolutionContext<TEncodedSolution>, ISingleObjectiveSolutionContext<TEncodedSolution> 75 where TEncodedSolution : class, IEncodedSolution { 72 76 public new ISingleObjectiveEvaluationResult EvaluationResult { get; set; } 73 77 74 public SingleObjectiveSolutionContext( IEncodedSolution encodedSolution) : base(encodedSolution) { }78 public SingleObjectiveSolutionContext(TEncodedSolution encodedSolution) : base(encodedSolution) { } 75 79 76 80 77 public SingleObjectiveSolutionContext( IEncodedSolution encodedSolution, IEvaluationResult evaluationResult) : base(encodedSolution, evaluationResult) { }81 public SingleObjectiveSolutionContext(TEncodedSolution encodedSolution, IEvaluationResult evaluationResult) : base(encodedSolution, evaluationResult) { } 78 82 79 83 [StorableConstructor] 80 public SingleObjectiveSolutionContext(StorableConstructorFlag _) : base(_) { 84 public SingleObjectiveSolutionContext(StorableConstructorFlag _) : base(_) { } 81 85 82 public SingleObjectiveSolutionContext(SingleObjectiveSolutionContext original, Cloner cloner) : base(original, cloner) { }86 public SingleObjectiveSolutionContext(SingleObjectiveSolutionContext<TEncodedSolution> original, Cloner cloner) : base(original, cloner) { } 83 87 84 88 85 89 public override IDeepCloneable Clone(Cloner cloner) { 86 return new SingleObjectiveSolutionContext (this, cloner);90 return new SingleObjectiveSolutionContext<TEncodedSolution>(this, cloner); 87 91 } 88 92 } 89 93 90 94 [StorableType("929868B3-8994-4D75-B363-CCF9C51410F9")] 91 public class MultiObjectiveSolutionContext : SolutionContext, IMultiObjectiveSolutionContext { 95 public class MultiObjectiveSolutionContext<TEncodedSolution> : SolutionContext<TEncodedSolution>, IMultiObjectiveSolutionContext<TEncodedSolution> 96 where TEncodedSolution : class, IEncodedSolution { 92 97 public new IMultiObjectiveEvaluationResult EvaluationResult { get; set; } 93 98 94 public MultiObjectiveSolutionContext( IEncodedSolution encodedSolution) : base(encodedSolution) { }99 public MultiObjectiveSolutionContext(TEncodedSolution encodedSolution) : base(encodedSolution) { } 95 100 96 101 97 public MultiObjectiveSolutionContext( IEncodedSolution encodedSolution, IEvaluationResult evaluationResult) : base(encodedSolution, evaluationResult) { }102 public MultiObjectiveSolutionContext(TEncodedSolution encodedSolution, IEvaluationResult evaluationResult) : base(encodedSolution, evaluationResult) { } 98 103 99 104 [StorableConstructor] 100 105 public MultiObjectiveSolutionContext(StorableConstructorFlag _) : base(_) { } 101 106 102 public MultiObjectiveSolutionContext(MultiObjectiveSolutionContext original, Cloner cloner) : base(original, cloner) { }107 public MultiObjectiveSolutionContext(MultiObjectiveSolutionContext<TEncodedSolution> original, Cloner cloner) : base(original, cloner) { } 103 108 104 109 105 110 public override IDeepCloneable Clone(Cloner cloner) { 106 return new MultiObjectiveSolutionContext (this, cloner);111 return new MultiObjectiveSolutionContext<TEncodedSolution>(this, cloner); 107 112 } 108 113 }
Note: See TracChangeset
for help on using the changeset viewer.