Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/03/19 15:37:38 (5 years ago)
Author:
mkommend
Message:

#2521: Renamed Solution to EncodedSolution.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/ScopeUtil.cs

    r13359 r16751  
    2929  public static class ScopeUtil {
    3030
    31     public static TSolution CopySolutionToScope<TSolution>(IScope scope, IEncoding<TSolution> encoding, TSolution solution)
    32       where TSolution : class,ISolution {
    33       return CopySolutionToScope(scope, encoding.Name, solution);
     31    public static TEncodedSolution CopyEncodedSolutionToScope<TEncodedSolution>(IScope scope, IEncoding<TEncodedSolution> encoding, TEncodedSolution solution)
     32      where TEncodedSolution : class, IEncodedSolution {
     33      return CopyEncodedSolutionToScope(scope, encoding.Name, solution);
    3434    }
    3535
    36     public static TSolution CopySolutionToScope<TSolution>(IScope scope, string name, TSolution solution)
    37       where TSolution : class,ISolution {
    38       var copy = (TSolution)solution.Clone();
     36    public static TEncodedSolution CopyEncodedSolutionToScope<TEncodedSolution>(IScope scope, string name, TEncodedSolution solution)
     37      where TEncodedSolution : class, IEncodedSolution {
     38      var copy = (TEncodedSolution)solution.Clone();
    3939      if (!scope.Variables.ContainsKey(name)) scope.Variables.Add(new Variable(name, copy));
    4040      else scope.Variables[name].Value = copy;
     
    4242    }
    4343
    44     public static TSolution GetSolution<TSolution>(IScope scope, IEncoding<TSolution> encoding)
    45       where TSolution : class,ISolution {
     44    public static TEncodedSolution GetEncodedSolution<TEncodedSolution>(IScope scope, IEncoding<TEncodedSolution> encoding)
     45      where TEncodedSolution : class, IEncodedSolution {
    4646      var name = encoding.Name;
    4747      if (!scope.Variables.ContainsKey(name)) throw new ArgumentException(string.Format(" {0} cannot be found in the provided scope.", name));
    48       var value = scope.Variables[name].Value as TSolution;
    49       if (value == null) throw new InvalidOperationException(string.Format("Value of {0} is null or not of type {1}.", name, typeof(TSolution).GetPrettyName()));
     48      var value = scope.Variables[name].Value as TEncodedSolution;
     49      if (value == null) throw new InvalidOperationException(string.Format("Value of {0} is null or not of type {1}.", name, typeof(TEncodedSolution).GetPrettyName()));
    5050      return value;
    5151    }
    5252
    53     public static ISolution GetSolution(IScope scope, IEncoding encoding) {
    54       return GetSolution(scope, encoding.Name);
     53    public static IEncodedSolution GetEncodedSolution(IScope scope, IEncoding encoding) {
     54      return GetEncodedSolution(scope, encoding.Name);
    5555    }
    5656
    57     public static ISolution GetSolution(IScope scope, string name) {
     57    public static IEncodedSolution GetEncodedSolution(IScope scope, string name) {
    5858      IVariable variable;
    5959      if (!scope.Variables.TryGetValue(name, out variable)) throw new ArgumentException(string.Format("{0} cannot be found in the provided scope.", name));
    60       var solution = variable.Value as ISolution;
     60      var solution = variable.Value as IEncodedSolution;
    6161      if (solution == null) throw new InvalidOperationException(string.Format("{0} is null or not of type ISolution.", name));
    6262      return solution;
Note: See TracChangeset for help on using the changeset viewer.