Changeset 17699


Ignore:
Timestamp:
07/25/20 01:23:08 (3 weeks ago)
Author:
abeham
Message:

#2521: Made encodings non-generic classes (the TEncodedSolution type parameter is not actually used), this will make it considerably easier to port the VRP to the new architecture

Location:
branches/2521_ProblemRefactoring
Files:
48 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorEncoding.cs

    r17614 r17699  
    3232  [Item("BinaryVectorEncoding", "Describes a binary vector encoding.")]
    3333  [StorableType("889C5E1A-3FBF-4AB3-AB2E-199A781503B5")]
    34   public sealed class BinaryVectorEncoding : VectorEncoding<BinaryVector> {
     34  public sealed class BinaryVectorEncoding : VectorEncoding {
    3535
    3636    [StorableConstructor]
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorEncoding.cs

    r17620 r17699  
    3434  [Item("IntegerVectorEncoding", "Describes an integer vector encoding.")]
    3535  [StorableType("15D6E55E-C39F-4784-8350-14A0FD47CF0E")]
    36   public sealed class IntegerVectorEncoding : VectorEncoding<IntegerVector> {
     36  public sealed class IntegerVectorEncoding : VectorEncoding {
    3737    [Storable] public IValueParameter<IntMatrix> BoundsParameter { get; private set; }
    3838
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageEncoding.cs

    r17614 r17699  
    3232  [Item("Linear Linkage Encoding", "Describes a linear linkage (LLE) encoding.")]
    3333  [StorableType("7AE11F39-E6BD-4FC7-8112-0A5EDCBFBDB6")]
    34   public sealed class LinearLinkageEncoding : VectorEncoding<LinearLinkage> {
     34  public sealed class LinearLinkageEncoding : VectorEncoding {
    3535
    3636    [StorableConstructor]
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationEncoding.cs

    r17614 r17699  
    3434  [Item("PermutationEncoding", "Describes a permutation encoding.")]
    3535  [StorableType("E30E7507-44BA-4021-8F56-C3FC5569A6FE")]
    36   public sealed class PermutationEncoding : VectorEncoding<Permutation> {
     36  public sealed class PermutationEncoding : VectorEncoding {
    3737    #region encoding parameters
    3838    [Storable] public IValueParameter<EnumValue<PermutationTypes>> PermutationTypeParameter { get; private set; }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorEncoding.cs

    r17614 r17699  
    3434  [Item("RealVectorEncoding", "Describes a real vector encoding.")]
    3535  [StorableType("155FFE02-931F-457D-AC95-A0389B0BFECD")]
    36   public sealed class RealVectorEncoding : VectorEncoding<RealVector> {
     36  public sealed class RealVectorEncoding : VectorEncoding {
    3737    [Storable] public IValueParameter<DoubleMatrix> BoundsParameter { get; private set; }
    3838
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleEncoding.cs

    r17680 r17699  
    2929namespace HeuristicLab.Encodings.ScheduleEncoding {
    3030  [StorableType("09b9d24c-2576-495a-b06c-338d095cba0d")]
    31   public interface IScheduleEncoding : IEncoding<IScheduleSolution> {
     31  public interface IScheduleEncoding : IEncoding {
    3232    IValueParameter<ItemList<Job>> JobDataParameter { get; }
    3333    IFixedValueParameter<IntValue> JobsParameter { get; }
     
    4141    Schedule Decode(IScheduleSolution schedule, ItemList<Job> jobData);
    4242  }
    43 
    44   public interface IScheduleEncoding<TSchedule> : IEncoding<TSchedule>
    45     where TSchedule : class, IScheduleSolution {
    46 
    47   }
    4843}
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding.cs

    r17680 r17699  
    3232namespace HeuristicLab.Encodings.ScheduleEncoding {
    3333  [StorableType("D2FB1AF9-EF13-4ED2-B3E9-D5BE4E5772EA")]
    34   public abstract class ScheduleEncoding<TSchedule> : Encoding<TSchedule>, IScheduleEncoding
     34  public abstract class ScheduleEncoding<TSchedule> : Encoding, IScheduleEncoding
    3535  where TSchedule : class, IScheduleSolution {
    3636    [Storable] public IValueParameter<ItemList<Job>> JobDataParameter { get; private set; }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeEncoding.cs

    r17614 r17699  
    3636  [Item("SymbolicExpressionTreeEncoding", "Describes a symbolic expression tree encoding.")]
    3737  [StorableType("3FDE530B-771F-4280-921F-20DA50A139BA")]
    38   public sealed class SymbolicExpressionTreeEncoding : Encoding<ISymbolicExpressionTree> {
     38  public sealed class SymbolicExpressionTreeEncoding : Encoding {
    3939    #region Encoding Parameters
    4040    [Storable]
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/CombinedEncoding.cs

    r17614 r17699  
    3131  [Item("CombinedEncoding", "Describes a combined encoding consisting of multiple simpler encodings.")]
    3232  [StorableType("359E2173-4D0C-40E5-A2F3-E42E59840345")]
    33   public sealed class CombinedEncoding : Encoding<CombinedSolution> {
     33  public sealed class CombinedEncoding : Encoding {
    3434
    3535    private ItemCollection<IEncoding> encodings;
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Encoding.cs

    r17614 r17699  
    3131  [Item("Encoding", "Base class for describing different encodings.")]
    3232  [StorableType("395B1372-FA54-4649-9EBE-5402A0AA9494")]
    33   public abstract class Encoding<TEncodedSolution> : ParameterizedNamedItem, IEncoding<TEncodedSolution>
    34     where TEncodedSolution : class, IEncodedSolution {
     33  public abstract class Encoding : ParameterizedNamedItem, IEncoding {
    3534    public sealed override bool CanChangeName {
    3635      get { return false; }
     
    4847      get { return encodingOperators; }
    4948      set {
    50         if (!value.OfType<ISolutionCreator<TEncodedSolution>>().Any())
    51           throw new ArgumentException("The provided operators contain no suitable solution creator");
     49        // SolutionCreator is now a parameter of the algorithm, we don't care!
     50        //if (!value.OfType<ISolutionCreator<TEncodedSolution>>().Any())
     51        //  throw new ArgumentException("The provided operators contain no suitable solution creator");
    5252        encodingOperators.Clear();
    5353        foreach (var op in value) encodingOperators.Add(op);
     
    6262    private void AfterDeserialization() { }
    6363
    64     protected Encoding(Encoding<TEncodedSolution> original, Cloner cloner)
     64    protected Encoding(Encoding original, Cloner cloner)
    6565      : base(original, cloner) {
    6666      encodingOperators = cloner.Clone(original.encodingOperators);
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IEncoding.cs

    r17614 r17699  
    3535    event EventHandler OperatorsChanged;
    3636  }
    37 
    38   [StorableType("DB23907F-BE6E-44E4-9596-3D3BF1532631")]
    39   public interface IEncoding<TEncodedSolution> : IEncoding
    40       where TEncodedSolution : class, IEncodedSolution {
    41     //new ISolutionCreator<TEncodedSolution> SolutionCreator { get; }
    42   }
    4337}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IEncodingOperator.cs

    r17226 r17699  
    2525namespace HeuristicLab.Optimization {
    2626  [StorableType("20faaf8b-dd4f-4f0e-a772-4c4dec7fcccb")]
    27   public interface IEncodingOperator<TEncodedSolution> : IOperator where TEncodedSolution : class, IEncodedSolution {
    28     ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter { get; }
     27  public interface IEncodingOperator : IOperator {
     28    ILookupParameter<IEncoding> EncodingParameter { get; }
    2929  }
    3030}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IMultiObjectiveProblem.cs

    r17320 r17699  
    3131  [StorableType("806fb361-1469-4903-9f54-f8678b0717b9")]
    3232  public interface IMultiObjectiveProblem<TEncoding, TEncodedSolution> : IMultiObjectiveProblem, IProblem<TEncoding, TEncodedSolution>
    33     where TEncoding : class, IEncoding<TEncodedSolution>
     33    where TEncoding : class, IEncoding
    3434    where TEncodedSolution : class, IEncodedSolution { }
    3535
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IMultiObjectiveProblemDefinition.cs

    r17320 r17699  
    3636  [StorableType("39eacdb5-80a0-425d-902a-00eb3e1d6610")]
    3737  public interface IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution> : IMultiObjectiveProblemDefinition, IProblemDefinition<TEncoding, TEncodedSolution>
    38     where TEncoding : class, IEncoding<TEncodedSolution>
     38    where TEncoding : class, IEncoding
    3939    where TEncodedSolution : class, IEncodedSolution {
    4040    double[] Evaluate(TEncodedSolution solution, IRandom random);
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IProblem.cs

    r17696 r17699  
    5252  [StorableType("1b4af8b9-bdf5-4ffd-86e6-35b481bfbf45")]
    5353  public interface IProblem<TEncoding, TEncodedSolution> : IHeuristicOptimizationProblem
    54     where TEncoding : class, IEncoding<TEncodedSolution>
     54    where TEncoding : class, IEncoding
    5555    where TEncodedSolution : class, IEncodedSolution {
    5656  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IProblemDefinition.cs

    r17612 r17699  
    3131  [StorableType("747a3cea-b9ba-4322-a5c2-050cd7e16e2a")]
    3232  public interface IProblemDefinition<TEncoding, TEncodedSolution> : IProblemDefinition
    33     where TEncoding : class, IEncoding<TEncodedSolution>
     33    where TEncoding : class, IEncoding
    3434    where TEncodedSolution : class, IEncodedSolution {
    3535    TEncoding Encoding { get; }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveProblem.cs

    r17320 r17699  
    3131  [StorableType("9cc9422f-0bb5-41e8-9d9e-6e0b66a66449")]
    3232  public interface ISingleObjectiveProblem<TEncoding, TEncodedSolution> : ISingleObjectiveProblem, IProblem<TEncoding, TEncodedSolution>
    33     where TEncoding : class, IEncoding<TEncodedSolution>
     33    where TEncoding : class, IEncoding
    3434    where TEncodedSolution : class, IEncodedSolution { }
    3535  //TODO derive ISingleObjectiveProblem from ISingleObjectiveProblemDefinition?
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveProblemDefinition.cs

    r17513 r17699  
    3434  [StorableType("7ec7bf7e-aaa7-4681-828b-3401cf67e2b3")]
    3535  public interface ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution> : ISingleObjectiveProblemDefinition, IProblemDefinition<TEncoding, TEncodedSolution>
    36     where TEncoding : class, IEncoding<TEncodedSolution>
     36    where TEncoding : class, IEncoding
    3737    where TEncodedSolution : class, IEncodedSolution {
    3838
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/IMultiObjectiveAnalysisOperator.cs

    r17226 r17699  
    2626namespace HeuristicLab.Optimization {
    2727  [StorableType("c9325602-3262-48a4-8985-03657fb0b34f")]
    28   internal interface IMultiObjectiveAnalysisOperator<TEncodedSolution> : IEncodingOperator<TEncodedSolution>, IAnalyzer, IMultiObjectiveOperator
     28  internal interface IMultiObjectiveAnalysisOperator<TEncodedSolution> : IEncodingOperator, IAnalyzer, IMultiObjectiveOperator
    2929  where TEncodedSolution : class, IEncodedSolution {
    3030    Action<TEncodedSolution[], double[][], ResultCollection, IRandom> AnalyzeAction { get; set; }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/IMultiObjectiveEvaluationOperator.cs

    r17226 r17699  
    2626namespace HeuristicLab.Optimization {
    2727  [StorableType("89da568c-70a2-48fb-8e6b-ea078bb6fc3f")]
    28   internal interface IMultiObjectiveEvaluationOperator<TEncodedSolution> : IMultiObjectiveEvaluator, IEncodingOperator<TEncodedSolution>
     28  internal interface IMultiObjectiveEvaluationOperator<TEncodedSolution> : IMultiObjectiveEvaluator, IEncodingOperator
    2929  where TEncodedSolution : class, IEncodedSolution {
    3030    Func<TEncodedSolution, IRandom, double[]> EvaluateFunc { get; set; }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/INeighborBasedOperator.cs

    r17363 r17699  
    2727namespace HeuristicLab.Optimization {
    2828  [StorableType("fda56e0b-9392-4711-9af1-55211bfa24ac")]
    29   internal interface INeighborBasedOperator<TEncodedSolution> : IEncodingOperator<TEncodedSolution>
     29  internal interface INeighborBasedOperator<TEncodedSolution> : IEncodingOperator
    3030  where TEncodedSolution : class, IEncodedSolution {
    3131    Func<ISingleObjectiveSolutionContext<TEncodedSolution>, IRandom, IEnumerable<ISingleObjectiveSolutionContext<TEncodedSolution>>> GetNeighbors { get; set; }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/ISingleObjectiveAnalysisOperator.cs

    r17363 r17699  
    2626namespace HeuristicLab.Optimization {
    2727  [StorableType("9731981c-10c6-4850-9308-a4720ac07da7")]
    28   internal interface ISingleObjectiveAnalysisOperator<TEncodedSolution> : IEncodingOperator<TEncodedSolution>, ISingleObjectiveOperator
     28  internal interface ISingleObjectiveAnalysisOperator<TEncodedSolution> : IEncodingOperator, ISingleObjectiveOperator
    2929  where TEncodedSolution : class, IEncodedSolution {
    3030    Action<ISingleObjectiveSolutionContext<TEncodedSolution>[], ResultCollection, IRandom> Analyze { get; set; }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/ISingleObjectiveEvaluationOperator.cs

    r17366 r17699  
    2727namespace HeuristicLab.Optimization {
    2828  [StorableType("5a9cf334-4815-4f0e-a2f8-f3d4edfcc829")]
    29   internal interface ISingleObjectiveEvaluationOperator<TEncodedSolution> : ISingleObjectiveEvaluator, IEncodingOperator<TEncodedSolution>
     29  internal interface ISingleObjectiveEvaluationOperator<TEncodedSolution> : ISingleObjectiveEvaluator, IEncodingOperator
    3030  where TEncodedSolution : class, IEncodedSolution {
    3131    Action<ISingleObjectiveSolutionContext<TEncodedSolution>, IRandom, CancellationToken> Evaluate { get; set; }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveProblem.cs

    r17690 r17699  
    3636    IMultiObjectiveProblem<TEncoding, TEncodedSolution>,
    3737    IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>
    38     where TEncoding : class, IEncoding<TEncodedSolution>
     38    where TEncoding : class, IEncoding
    3939    where TEncodedSolution : class, IEncodedSolution {
    4040
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiEncodingOperator.cs

    r17226 r17699  
    3030namespace HeuristicLab.Optimization {
    3131  [StorableType("43619638-9D00-4951-8138-8CCD0786E784")]
    32   internal abstract class MultiEncodingOperator<T> : InstrumentedOperator, IEncodingOperator<CombinedSolution>, IMultiEncodingOperator where T : class, IOperator {
     32  internal abstract class MultiEncodingOperator<T> : InstrumentedOperator, IEncodingOperator, IMultiEncodingOperator where T : class, IOperator {
    3333    public ILookupParameter<CombinedSolution> SolutionParameter {
    3434      get { return (ILookupParameter<CombinedSolution>)Parameters["Solution"]; }
    3535    }
    3636
    37     public ILookupParameter<IEncoding<CombinedSolution>> EncodingParameter {
    38       get { return (ILookupParameter<IEncoding<CombinedSolution>>)Parameters["Encoding"]; }
     37    public ILookupParameter<IEncoding> EncodingParameter {
     38      get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; }
    3939    }
    4040
     
    4747      : base() {
    4848      Parameters.Add(new LookupParameter<CombinedSolution>("Solution", "The solution that gets created."));
    49       Parameters.Add(new LookupParameter<IEncoding<CombinedSolution>>("Encoding", "The encoding."));
     49      Parameters.Add(new LookupParameter<IEncoding>("Encoding", "The encoding."));
    5050    }
    5151
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiObjectiveAnalyzer.cs

    r17226 r17699  
    3737    public bool EnabledByDefault { get { return true; } }
    3838
    39     public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter {
    40       get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; }
     39    public ILookupParameter<IEncoding> EncodingParameter {
     40      get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; }
    4141    }
    4242
     
    6060    public MultiObjectiveAnalyzer() {
    6161      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    62       Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));
     62      Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding."));
    6363      Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>("Qualities", "The qualities of the parameter vector."));
    6464      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The results collection to write to."));
     
    7878        scopes = scopes.Select(x => (IEnumerable<IScope>)x.SubScopes).Aggregate((a, b) => a.Concat(b));
    7979
    80       var individuals = scopes.Select(s => ScopeUtil.GetEncodedSolution(s, encoding)).ToArray();
     80      var individuals = scopes.Select(s => (TEncodedSolution)ScopeUtil.GetEncodedSolution(s, encoding)).ToArray();
    8181      AnalyzeAction(individuals, QualitiesParameter.ActualValue.Select(x => x.ToArray()).ToArray(), results, random);
    8282      return base.Apply();
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiObjectiveEvaluator.cs

    r17226 r17699  
    3838    }
    3939
    40     public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter {
    41       get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; }
     40    public ILookupParameter<IEncoding> EncodingParameter {
     41      get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; }
    4242    }
    4343
     
    5353    public MultiObjectiveEvaluator() {
    5454      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    55       Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));
     55      Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding."));
    5656      Parameters.Add(new LookupParameter<DoubleArray>("Qualities", "The qualities of the parameter vector."));
    5757    }
     
    6464      var random = RandomParameter.ActualValue;
    6565      var encoding = EncodingParameter.ActualValue;
    66       var solution = ScopeUtil.GetEncodedSolution(ExecutionContext.Scope, encoding);
     66      var solution = (TEncodedSolution)ScopeUtil.GetEncodedSolution(ExecutionContext.Scope, encoding);
    6767      QualitiesParameter.ActualValue = new DoubleArray(EvaluateFunc(solution, random));
    6868      return base.InstrumentedApply();
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/ScopeUtil.cs

    r17577 r17699  
    3131
    3232    // TODO: Create SolutionContexts that derive from IScope to have a unified datastructure (e.g. #1614)
    33     public static TEncodedSolution CopyEncodedSolutionToScope<TEncodedSolution>(IScope scope, IEncoding<TEncodedSolution> encoding, TEncodedSolution solution)
     33    public static TEncodedSolution CopyEncodedSolutionToScope<TEncodedSolution>(IScope scope, IEncoding encoding, TEncodedSolution solution)
    3434      where TEncodedSolution : class, IEncodedSolution {
    3535      return CopyEncodedSolutionToScope(scope, encoding.Name, solution);
     
    4444    }
    4545
    46     public static TEncodedSolution GetEncodedSolution<TEncodedSolution>(IScope scope, IEncoding<TEncodedSolution> encoding)
    47       where TEncodedSolution : class, IEncodedSolution {
     46    public static IEncodedSolution GetEncodedSolution(IScope scope, IEncoding encoding) {
    4847      var name = encoding.Name;
    4948      if (!scope.Variables.ContainsKey(name)) throw new ArgumentException(string.Format(" {0} cannot be found in the provided scope.", name));
    50       var value = scope.Variables[name].Value as TEncodedSolution;
    51       if (value == null) throw new InvalidOperationException(string.Format("Value of {0} is null or not of type {1}.", name, typeof(TEncodedSolution).GetPrettyName()));
    52       return value;
    53     }
    54 
    55     public static IEncodedSolution GetEncodedSolution(IScope scope, IEncoding encoding) {
    56       return GetEncodedSolution(scope, encoding.Name);
     49      if (scope.Variables[name].Value is IEncodedSolution value)
     50        return value;
     51      throw new InvalidOperationException(string.Format("Value of {0} is null or not of type {1}.", name, typeof(IEncodedSolution).GetPrettyName()));
    5752    }
    5853
     
    6560    }
    6661
    67     public static ISingleObjectiveSolutionContext<TEncodedSolution> CreateSolutionContext<TEncodedSolution>(IScope scope, IEncoding<TEncodedSolution> encoding)
     62    public static ISingleObjectiveSolutionContext<TEncodedSolution> CreateSolutionContext<TEncodedSolution>(IScope scope, IEncoding encoding)
    6863      where TEncodedSolution : class, IEncodedSolution {
    69       var solution = GetEncodedSolution(scope, encoding);
     64      var solution = (TEncodedSolution)GetEncodedSolution(scope, encoding);
    7065      var context = new SingleObjectiveSolutionContext<TEncodedSolution>(solution);
    7166      foreach (var variable in scope.Variables) {
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveAnalyzer.cs

    r17577 r17699  
    3737    public bool EnabledByDefault { get { return true; } }
    3838
    39     public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter {
    40       get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; }
     39    public ILookupParameter<IEncoding> EncodingParameter {
     40      get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; }
    4141    }
    4242
     
    5959    private SingleObjectiveAnalyzer(SingleObjectiveAnalyzer<TEncodedSolution> original, Cloner cloner) : base(original, cloner) { }
    6060    public SingleObjectiveAnalyzer() {
    61       Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));
     61      Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding."));
    6262      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The quality of the parameter vector."));
    6363      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The results collection to write to."));
     
    7979
    8080      var solutionContexts = scopes.Select(scope => {
    81         return ScopeUtil.CreateSolutionContext(scope, encoding);
     81        return ScopeUtil.CreateSolutionContext<TEncodedSolution>(scope, encoding);
    8282      }).ToArray();
    8383
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveEvaluator.cs

    r17592 r17699  
    3939    }
    4040
    41     public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter {
    42       get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; }
     41    public ILookupParameter<IEncoding> EncodingParameter {
     42      get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; }
    4343    }
    4444
     
    5454    public SingleObjectiveEvaluator() {
    5555      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    56       Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));
     56      Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding."));
    5757      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the parameter vector."));
    5858    }
     
    6363      var random = RandomParameter.ActualValue;
    6464      var encoding = EncodingParameter.ActualValue;
    65       var solutionContext = ScopeUtil.CreateSolutionContext(ExecutionContext.Scope, encoding);
     65      var solutionContext = ScopeUtil.CreateSolutionContext<TEncodedSolution>(ExecutionContext.Scope, encoding);
    6666
    6767      Evaluate(solutionContext, random, CancellationToken.None);
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveImprover.cs

    r17592 r17699  
    4040    }
    4141
    42     public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter {
    43       get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; }
     42    public ILookupParameter<IEncoding> EncodingParameter {
     43      get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; }
    4444    }
    4545
     
    7272    public SingleObjectiveImprover() {
    7373      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    74       Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));
     74      Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding."));
    7575      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the parameter vector."));
    7676      Parameters.Add(new LookupParameter<BoolValue>("Maximization", "Whether the problem should be minimized or maximized."));
     
    9090      var maxAttempts = ImprovementAttemptsParameter.ActualValue.Value;
    9191      var sampleSize = SampleSizeParameter.ActualValue.Value;
    92       var solutionContext = ScopeUtil.CreateSolutionContext(ExecutionContext.Scope, encoding);
     92      var solutionContext = ScopeUtil.CreateSolutionContext<TEncodedSolution>(ExecutionContext.Scope, encoding);
    9393
    9494      double quality;
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveMoveEvaluator.cs

    r17592 r17699  
    3939    }
    4040
    41     public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter {
    42       get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; }
     41    public ILookupParameter<IEncoding> EncodingParameter {
     42      get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; }
    4343    }
    4444
     
    5858    public SingleObjectiveMoveEvaluator() {
    5959      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    60       Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));
     60      Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding."));
    6161      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the parameter vector."));
    6262      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The quality of the move."));
     
    7070      var random = RandomParameter.ActualValue;
    7171      var encoding = EncodingParameter.ActualValue;
    72       var solutionContext = ScopeUtil.CreateSolutionContext(ExecutionContext.Scope, encoding);
     72      var solutionContext = ScopeUtil.CreateSolutionContext<TEncodedSolution>(ExecutionContext.Scope, encoding);
    7373
    7474      if (!solutionContext.IsEvaluated)
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveMoveGenerator.cs

    r17577 r17699  
    4444    }
    4545
    46     public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter {
    47       get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; }
     46    public ILookupParameter<IEncoding> EncodingParameter {
     47      get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; }
    4848    }
    4949
     
    5757      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    5858      Parameters.Add(new ValueLookupParameter<IntValue>("SampleSize", "The number of moves to sample."));
    59       Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));
     59      Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding."));
    6060    }
    6161
     
    6868      var sampleSize = SampleSizeParameter.ActualValue.Value;
    6969      var encoding = EncodingParameter.ActualValue;
    70       var solutionContext = ScopeUtil.CreateSolutionContext(ExecutionContext.Scope, encoding);
     70      var solutionContext = ScopeUtil.CreateSolutionContext<TEncodedSolution>(ExecutionContext.Scope, encoding);
    7171
    7272      var nbhood = GetNeighbors(solutionContext, random).Take(sampleSize).ToList();
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveMoveMaker.cs

    r17226 r17699  
    3131  [Item("Single-objective MoveMaker", "Applies a move.")]
    3232  [StorableType("C0ABF392-C825-4B98-8FB9-5749A9091FD6")]
    33   internal sealed class SingleObjectiveMoveMaker<TEncodedSolution> : InstrumentedOperator, IMoveMaker, ISingleObjectiveMoveOperator
    34   where TEncodedSolution : class, IEncodedSolution {
    35     public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter {
    36       get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; }
     33  internal sealed class SingleObjectiveMoveMaker : InstrumentedOperator, IMoveMaker, ISingleObjectiveMoveOperator {
     34    public ILookupParameter<IEncoding> EncodingParameter {
     35      get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; }
    3736    }
    3837
     
    4746    [StorableConstructor]
    4847    private SingleObjectiveMoveMaker(StorableConstructorFlag _) : base(_) { }
    49     private SingleObjectiveMoveMaker(SingleObjectiveMoveMaker<TEncodedSolution> original, Cloner cloner) : base(original, cloner) { }
     48    private SingleObjectiveMoveMaker(SingleObjectiveMoveMaker original, Cloner cloner) : base(original, cloner) { }
    5049    public SingleObjectiveMoveMaker() {
    51       Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));
     50      Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding."));
    5251      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the parameter vector."));
    5352      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The quality of the move."));
     
    5554
    5655    public override IDeepCloneable Clone(Cloner cloner) {
    57       return new SingleObjectiveMoveMaker<TEncodedSolution>(this, cloner);
     56      return new SingleObjectiveMoveMaker(this, cloner);
    5857    }
    5958
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Problem.cs

    r17695 r17699  
    3333  public abstract class Problem<TEncoding, TEncodedSolution, TEvaluator> : EncodedProblem,
    3434    IHeuristicOptimizationProblem, IProblemDefinition<TEncoding, TEncodedSolution>, IStorableContent
    35     where TEncoding : class, IEncoding<TEncodedSolution>
     35    where TEncoding : class, IEncoding
    3636    where TEncodedSolution : class, IEncodedSolution
    3737    where TEvaluator : class, IEvaluator {
     
    136136      oldEncoding = Encoding;
    137137
    138       foreach (var op in Operators.OfType<IEncodingOperator<TEncodedSolution>>())
     138      foreach (var op in Operators.OfType<IEncodingOperator>())
    139139        op.EncodingParameter.ActualName = EncodingParameter.Name;
    140140
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveProblem.cs

    r17697 r17699  
    3636    ISingleObjectiveProblem<TEncoding, TEncodedSolution>,
    3737    ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>
    38     where TEncoding : class, IEncoding<TEncodedSolution>
     38    where TEncoding : class, IEncoding
    3939    where TEncodedSolution : class, IEncodedSolution {
    4040
     
    8585      Operators.Add(new SingleObjectiveMoveEvaluator<TEncodedSolution>());
    8686      Operators.Add(new SingleObjectiveMoveGenerator<TEncodedSolution>());
    87       Operators.Add(new SingleObjectiveMoveMaker<TEncodedSolution>());
     87      Operators.Add(new SingleObjectiveMoveMaker());
    8888
    8989      Parameterize();
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/VectorEncoding.cs

    r17587 r17699  
    3030  [Item("VectorEncoding", "Represents a vector-based encoding.")]
    3131  [StorableType("fed1e058-6e47-4e0f-af0a-ff646a9a778b")]
    32   public abstract class VectorEncoding<TEncodedSolution> : Encoding<TEncodedSolution>
    33     where TEncodedSolution : class, IEncodedSolution {
     32  public abstract class VectorEncoding : Encoding {
    3433    [Storable] public IFixedValueParameter<IntValue> LengthParameter { get; private set; }
    3534
     
    4948      RegisterEventHandlers();
    5049    }
    51     protected VectorEncoding(VectorEncoding<TEncodedSolution> original, Cloner cloner)
     50    protected VectorEncoding(VectorEncoding original, Cloner cloner)
    5251      : base(original, cloner) {
    5352      LengthParameter = cloner.Clone(original.LengthParameter);
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/MultiObjectiveExternalEvaluationProblem.cs

    r17320 r17699  
    3838  [StorableType("CCA50199-A6AB-4C84-B4FA-0262CAF416EC")]
    3939  public class MultiObjectiveExternalEvaluationProblem<TEncoding, TEncodedSolution> : MultiObjectiveProblem<TEncoding, TEncodedSolution>, IExternalEvaluationProblem
    40     where TEncoding : class, IEncoding<TEncodedSolution>
     40    where TEncoding : class, IEncoding
    4141    where TEncodedSolution : class, IEncodedSolution {
    4242
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/SingleObjectiveExternalEvaluationProblem.cs

    r17567 r17699  
    4141  // Rename class to SingleObjectiveExternalEvaluationProblem
    4242  public class ExternalEvaluationProblem<TEncoding, TEncodedSolution> : SingleObjectiveProblem<TEncoding, TEncodedSolution>, IExternalEvaluationProblem
    43     where TEncoding : class, IEncoding<TEncodedSolution>
     43    where TEncoding : class, IEncoding
    4444    where TEncodedSolution : class, IEncodedSolution {
    4545
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/CompiledProblemDefinition.cs

    r17382 r17699  
    2929namespace HeuristicLab.Problems.Programmable {
    3030  public abstract class CompiledProblemDefinition<TEncoding, TEncodedSolution> : IProblemDefinition<TEncoding, TEncodedSolution>
    31     where TEncoding : class, IEncoding<TEncodedSolution>
     31    where TEncoding : class, IEncoding
    3232    where TEncodedSolution : class, IEncodedSolution {
    3333    private TEncoding encoding;
     
    5151
    5252  public abstract class CompiledSingleObjectiveProblemDefinition<TEncoding, TEncodedSolution> : CompiledProblemDefinition<TEncoding, TEncodedSolution>, ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>
    53     where TEncoding : class, IEncoding<TEncodedSolution>
     53    where TEncoding : class, IEncoding
    5454    where TEncodedSolution : class, IEncodedSolution {
    5555    protected CompiledSingleObjectiveProblemDefinition() : base() { }
     
    9595
    9696  public abstract class CompiledMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution> : CompiledProblemDefinition<TEncoding, TEncodedSolution>, IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>
    97     where TEncoding : class, IEncoding<TEncodedSolution>
     97    where TEncoding : class, IEncoding
    9898    where TEncodedSolution : class, IEncodedSolution {
    9999    protected CompiledMultiObjectiveProblemDefinition() : base() { }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProblemDefinitionScript.cs

    r17320 r17699  
    3131  [StorableType("17741D64-CF9D-4CCF-9892-0590C325D4E6")]
    3232  public sealed class MultiObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution> : ProblemDefinitionScript<TEncoding, TEncodedSolution>, IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>, IStorableContent
    33     where TEncoding : class, IEncoding<TEncodedSolution>
     33    where TEncoding : class, IEncoding
    3434    where TEncodedSolution : class, IEncodedSolution {
    3535    public string Filename { get; set; }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProgrammableProblem.cs

    r17320 r17699  
    3535  [StorableType("1AA24077-4E1E-4FAE-8EC8-B6008DFD30B9")]
    3636  public abstract class MultiObjectiveProgrammableProblem<TEncoding, TEncodedSolution> : MultiObjectiveProblem<TEncoding, TEncodedSolution>, IProgrammableItem, IProgrammableProblem
    37     where TEncoding : class, IEncoding<TEncodedSolution>
     37    where TEncoding : class, IEncoding
    3838    where TEncodedSolution : class, IEncodedSolution {
    3939    protected static readonly string ENCODING_NAMESPACE = "ENCODING_NAMESPACE";
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/ProblemDefinitionScript.cs

    r17226 r17699  
    5757  [StorableType("0B3AF22C-4744-4860-BBCF-A92046000847")]
    5858  public abstract class ProblemDefinitionScript<TEncoding, TEncodedSolution> : ProblemDefinitionScript, IProblemDefinition<TEncoding, TEncodedSolution>
    59     where TEncoding : class, IEncoding<TEncodedSolution>
     59    where TEncoding : class, IEncoding
    6060    where TEncodedSolution : class, IEncodedSolution {
    6161
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProblemDefinitionScript.cs

    r17383 r17699  
    3131  [StorableType("D0B2A649-EDDE-4A6E-A3B5-F40F5FD1B2C0")]
    3232  public sealed class SingleObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution> : ProblemDefinitionScript<TEncoding, TEncodedSolution>, ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>, IStorableContent
    33     where TEncoding : class, IEncoding<TEncodedSolution>
     33    where TEncoding : class, IEncoding
    3434    where TEncodedSolution : class, IEncodedSolution {
    3535    public string Filename { get; set; }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblem.cs

    r17383 r17699  
    3636  [StorableType("44944E6B-E95E-4805-8F0A-0C0F7D761DB9")]
    3737  public abstract class SingleObjectiveProgrammableProblem<TEncoding, TEncodedSolution> : SingleObjectiveProblem<TEncoding, TEncodedSolution>, IProgrammableItem, IProgrammableProblem
    38     where TEncoding : class, IEncoding<TEncodedSolution>
     38    where TEncoding : class, IEncoding
    3939    where TEncodedSolution : class, IEncodedSolution {
    4040    protected static readonly string ENCODING_NAMESPACE = "ENCODING_NAMESPACE";
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/AlbaEncoding.cs

    r17698 r17699  
    3232  [Item("AlbaEncoding", "Represents the encoding for Alba encoded solutions.")]
    3333  [StorableType("9ff9f959-31d2-44e5-8a5e-b122220535c2")]
    34   public class AlbaEncoding : Encoding<AlbaEncodedSolution>, IVRPEncoding<AlbaEncodedSolution> {
     34  public class AlbaEncoding : Encoding, IVRPEncoding {
    3535
    3636    [StorableConstructor]
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPEncoding.cs

    r17698 r17699  
    2222using HEAL.Attic;
    2323using HeuristicLab.Optimization;
    24 using HeuristicLab.Problems.VehicleRouting.Interfaces;
    2524
    2625namespace HeuristicLab.Problems.VehicleRouting {
     
    2827  [StorableType("b6674651-cc95-48d8-a2c3-83ee9325def3")]
    2928  public interface IVRPEncoding : IEncoding { }
    30 
    31   [StorableType("7d010ab3-2e01-4383-bb6c-7c47ef9d803f")]
    32   public interface IVRPEncoding<T> : IVRPEncoding, IEncoding<T> where T : class, IVRPEncodedSolution { }
    3329}
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs

    r17698 r17699  
    4545  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 110)]
    4646  [StorableType("95137523-AE3B-4638-958C-E86829D54CE3")]
    47   public sealed class VehicleRoutingProblem : SingleObjectiveProblem<AlbaEncoding, AlbaEncodedSolution>, IProblemInstanceConsumer<IVRPData> {
     47  public sealed class VehicleRoutingProblem : SingleObjectiveProblem<IVRPEncoding, IVRPEncodedSolution>, IProblemInstanceConsumer<IVRPData> {
    4848
    4949    public static new Image StaticItemImage {
     
    9797    }
    9898
    99     public override ISingleObjectiveEvaluationResult Evaluate(AlbaEncodedSolution solution, IRandom random, CancellationToken cancellationToken) {
     99    public override ISingleObjectiveEvaluationResult Evaluate(IVRPEncodedSolution solution, IRandom random, CancellationToken cancellationToken) {
    100100      return new SingleObjectiveEvaluationResult(ProblemInstance.Evaluate(solution).Quality);
    101101    }
Note: See TracChangeset for help on using the changeset viewer.