Changeset 17381 for branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SolutionContextScope.cs
- Timestamp:
- 12/18/19 15:06:18 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SolutionContextScope.cs
r17363 r17381 27 27 //TODO: don't derive from NamedItem, this has been done to have a fast working prototype 28 28 namespace HeuristicLab.Optimization { 29 internal class SolutionContextScope<TEncodedSolution> : SolutionContext<TEncodedSolution>, ISolutionScope29 internal abstract class SolutionContextScope<TEncodedSolution> : SolutionContext<TEncodedSolution>, ISolutionScope 30 30 where TEncodedSolution : class, IEncodedSolution { 31 private readonly IScope scope; 31 protected static string EVALUATION_RESULT_VARIABLE_NAME = "Evaluation Result"; 32 33 protected IScope Scope { get; } 32 34 33 35 public SolutionContextScope(IScope scope, TEncodedSolution solution) : base(solution) { 34 this.scope = scope;36 Scope = scope; 35 37 } 36 38 … … 40 42 41 43 IScope IScope.Parent { 42 get { return scope.Parent; }44 get { return Scope.Parent; } 43 45 set { throw new NotSupportedException(); } 44 46 } 45 47 46 VariableCollection IScope.Variables => scope.Variables;47 ScopeList IScope.SubScopes => scope.SubScopes;48 VariableCollection IScope.Variables => Scope.Variables; 49 ScopeList IScope.SubScopes => Scope.SubScopes; 48 50 49 51 void IScope.Clear() { throw new NotImplementedException(); } 50 52 51 52 53 53 #region INamedItem members 54 string INamedItem.Name { get { return scope.Name; } set => throw new NotImplementedException(); }54 string INamedItem.Name { get { return Scope.Name; } set => throw new NotImplementedException(); } 55 55 bool INamedItem.CanChangeName => false; 56 56 57 string INamedItem.Description { get { return scope.Description; } set => throw new NotImplementedException(); }57 string INamedItem.Description { get { return Scope.Description; } set => throw new NotImplementedException(); } 58 58 bool INamedItem.CanChangeDescription => false; 59 59 … … 78 78 where TEncodedSolution : class, IEncodedSolution { 79 79 80 public new ISingleObjectiveEvaluationResult EvaluationResult { get; set; } 80 public new ISingleObjectiveEvaluationResult EvaluationResult { 81 get { 82 return (ISingleObjectiveEvaluationResult)Scope.Variables[EVALUATION_RESULT_VARIABLE_NAME].Value; 83 } 84 set { 85 Scope.Variables.Remove(EVALUATION_RESULT_VARIABLE_NAME); 86 Scope.Variables.Add(new Variable(EVALUATION_RESULT_VARIABLE_NAME, value)); 87 } 88 } 89 81 90 public SingleObjectiveSolutionContextScope(IScope scope, TEncodedSolution solution) : base(scope, solution) { 82 91 } … … 86 95 where TEncodedSolution : class, IEncodedSolution { 87 96 88 public new IMultiObjectiveEvaluationResult EvaluationResult { get; set; } 97 public new IMultiObjectiveEvaluationResult EvaluationResult { 98 get { 99 return (IMultiObjectiveEvaluationResult)Scope.Variables[EVALUATION_RESULT_VARIABLE_NAME].Value; 100 } 101 set { 102 Scope.Variables.Remove(EVALUATION_RESULT_VARIABLE_NAME); 103 Scope.Variables.Add(new Variable(EVALUATION_RESULT_VARIABLE_NAME, value)); 104 } 105 } 89 106 public MultiObjectiveSolutionContextScope(IScope scope, TEncodedSolution solution) : base(scope, solution) { 90 107 }
Note: See TracChangeset
for help on using the changeset viewer.