Free cookie consent management tool by TermsFeed Policy Generator

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

#2521: Renamed Solution to EncodedSolution.

Location:
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems
Files:
26 edited
1 moved

Legend:

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

    r16724 r16751  
    2222using System;
    2323using System.Linq;
     24using HEAL.Attic;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    26 using HEAL.Attic;
    2727
    2828namespace HeuristicLab.Optimization {
    2929  [Item("CombinedSolution", "A solution that consists of other solutions.")]
    3030  [StorableType("B5ED00CB-E533-4ED6-AB2D-95BF7A654AAD")]
    31   public sealed class CombinedSolution : Item, ISolution {
     31  public sealed class CombinedSolution : Item, IEncodedSolution {
    3232
    3333    private CombinedEncoding Encoding { get; set; }
     
    5050    }
    5151
    52     public ISolution this[string name] {
    53       get { return ScopeUtil.GetSolution(Scope, name); }
    54       set { ScopeUtil.CopySolutionToScope(Scope, name, value); }
     52    public IEncodedSolution this[string name] {
     53      get { return ScopeUtil.GetEncodedSolution(Scope, name); }
     54      set { ScopeUtil.CopyEncodedSolutionToScope(Scope, name, value); }
    5555    }
    5656
     
    6666    }
    6767
    68     public TSolution GetSolution<TSolution>(string name) where TSolution : class, ISolution {
    69       return (TSolution)ScopeUtil.GetSolution(Scope, name);
     68    public TEncodedSolution GetEncodedSolution<TEncodedSolution>(string name) where TEncodedSolution : class, IEncodedSolution {
     69      return (TEncodedSolution)ScopeUtil.GetEncodedSolution(Scope, name);
    7070    }
    7171  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Encoding.cs

    r16723 r16751  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Parameters;
    28 using HEAL.Attic;
    2929
    3030namespace HeuristicLab.Optimization {
    3131  [Item("Encoding", "Base class for describing different encodings.")]
    3232  [StorableType("395B1372-FA54-4649-9EBE-5402A0AA9494")]
    33   public abstract class Encoding<TSolution> : ParameterizedNamedItem, IEncoding<TSolution>
    34     where TSolution : class,ISolution {
    35     public override sealed bool CanChangeName {
     33  public abstract class Encoding<TEncodedSolution> : ParameterizedNamedItem, IEncoding<TEncodedSolution>
     34    where TEncodedSolution : class, IEncodedSolution {
     35    public sealed override bool CanChangeName {
    3636      get { return false; }
    3737    }
     
    4848      get { return encodingOperators; }
    4949      set {
    50         if (!value.OfType<ISolutionCreator<TSolution>>().Any())
     50        if (!value.OfType<ISolutionCreator<TEncodedSolution>>().Any())
    5151          throw new ArgumentException("The provided operators contain no suitable solution creator");
    5252        encodingOperators.Clear();
    5353        foreach (var op in value) encodingOperators.Add(op);
    5454
    55         ISolutionCreator<TSolution> newSolutionCreator = (ISolutionCreator<TSolution>)encodingOperators.FirstOrDefault(o => o.GetType() == SolutionCreator.GetType()) ??
    56                                encodingOperators.OfType<ISolutionCreator<TSolution>>().First();
     55        ISolutionCreator<TEncodedSolution> newSolutionCreator = (ISolutionCreator<TEncodedSolution>)encodingOperators.FirstOrDefault(o => o.GetType() == SolutionCreator.GetType()) ??
     56                               encodingOperators.OfType<ISolutionCreator<TEncodedSolution>>().First();
    5757        SolutionCreator = newSolutionCreator;
    5858        OnOperatorsChanged();
     
    6767      get { return SolutionCreator; }
    6868    }
    69     public ISolutionCreator<TSolution> SolutionCreator {
    70       get { return (ISolutionCreator<TSolution>)SolutionCreatorParameter.Value; }
     69    public ISolutionCreator<TEncodedSolution> SolutionCreator {
     70      get { return (ISolutionCreator<TEncodedSolution>)SolutionCreatorParameter.Value; }
    7171      set {
    7272        if (value == null) throw new ArgumentNullException("SolutionCreator must not be null.");
     
    8686    }
    8787
    88     protected Encoding(Encoding<TSolution> original, Cloner cloner)
     88    protected Encoding(Encoding<TEncodedSolution> original, Cloner cloner)
    8989      : base(original, cloner) {
    9090      encodingOperators = cloner.Clone(original.encodingOperators);
     
    9595    protected Encoding(string name)
    9696      : base(name) {
    97       Parameters.Add(new ValueParameter<ISolutionCreator<TSolution>>(name + ".SolutionCreator", "The operator to create a solution."));
     97      Parameters.Add(new ValueParameter<ISolutionCreator<TEncodedSolution>>(name + ".SolutionCreator", "The operator to create a solution."));
    9898      Parameters.Add(new FixedValueParameter<ReadOnlyItemSet<IOperator>>(name + ".Operators", "The operators that the encoding specifies.", encodingOperators.AsReadOnly()));
    9999
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IEncodedSolution.cs

    r16750 r16751  
    2222#endregion
    2323
    24 using System;
    25 using System.Collections.Generic;
    26 using System.Linq;
    27 using System.Text;
    28 using System.Threading.Tasks;
    2924using HeuristicLab.Core;
    3025
    3126namespace HeuristicLab.Optimization {
    32   public interface ISolution : IItem { }
     27  public interface IEncodedSolution : IItem { }
    3328}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IEncoding.cs

    r16723 r16751  
    2222using System;
    2323using System.Collections.Generic;
     24using HEAL.Attic;
    2425using HeuristicLab.Core;
    25 using HEAL.Attic;
    2626
    2727namespace HeuristicLab.Optimization {
     
    4040  }
    4141
    42   public interface IEncoding<TSolution> : IEncoding
    43     where TSolution : class, ISolution {
    44     //new ISolutionCreator<TSolution> SolutionCreator { get; }
     42  public interface IEncoding<TEncodedSolution> : IEncoding
     43    where TEncodedSolution : class, IEncodedSolution {
     44    //new ISolutionCreator<TEncodedSolution> SolutionCreator { get; }
    4545  }
    4646}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IEncodingOperator.cs

    r16723 r16751  
    2020#endregion
    2121
     22using HEAL.Attic;
    2223using HeuristicLab.Core;
    23 using HEAL.Attic;
    2424
    2525namespace HeuristicLab.Optimization {
    2626  [StorableType("20faaf8b-dd4f-4f0e-a772-4c4dec7fcccb")]
    27   public interface IEncodingOperator<TSolution> : IOperator where TSolution : class, ISolution {
    28     ILookupParameter<IEncoding<TSolution>> EncodingParameter { get; }
     27  public interface IEncodingOperator<TEncodedSolution> : IOperator where TEncodedSolution : class, IEncodedSolution {
     28    ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter { get; }
    2929  }
    3030}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IMultiObjectiveProblem.cs

    r13362 r16751  
    2323
    2424namespace HeuristicLab.Optimization {
    25   public interface IMultiObjectiveProblem<TEncoding, TSolution> : IProblem<TEncoding, TSolution>, IMultiObjectiveHeuristicOptimizationProblem
    26     where TEncoding : class, IEncoding<TSolution>
    27     where TSolution : class, ISolution {
     25  public interface IMultiObjectiveProblem<TEncoding, TEncodedSolution> : IProblem<TEncoding, TEncodedSolution>, IMultiObjectiveHeuristicOptimizationProblem
     26    where TEncoding : class, IEncoding<TEncodedSolution>
     27    where TEncodedSolution : class, IEncodedSolution {
    2828
    2929  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IMultiObjectiveProblemDefinition.cs

    r16723 r16751  
    2020#endregion
    2121
     22using HEAL.Attic;
    2223using HeuristicLab.Core;
    23 using HEAL.Attic;
    2424
    2525namespace HeuristicLab.Optimization {
    2626  [StorableType("39eacdb5-80a0-425d-902a-00eb3e1d6610")]
    27   public interface IMultiObjectiveProblemDefinition<TEncoding, TSolution> : IProblemDefinition<TEncoding, TSolution>
    28     where TEncoding : class, IEncoding<TSolution>
    29     where TSolution : class, ISolution {
     27  public interface IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution> : IProblemDefinition<TEncoding, TEncodedSolution>
     28    where TEncoding : class, IEncoding<TEncodedSolution>
     29    where TEncodedSolution : class, IEncodedSolution {
    3030    bool[] Maximization { get; }
    31     double[] Evaluate(TSolution individual, IRandom random);
    32     void Analyze(TSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random);
     31    double[] Evaluate(TEncodedSolution individual, IRandom random);
     32    void Analyze(TEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random);
    3333  }
    3434}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IProblemDefinition.cs

    r16723 r16751  
    2424namespace HeuristicLab.Optimization {
    2525  [StorableType("747a3cea-b9ba-4322-a5c2-050cd7e16e2a")]
    26   public interface IProblemDefinition<TEncoding, TSolution>
    27     where TEncoding : class, IEncoding<TSolution>
    28     where TSolution : class, ISolution {
     26  public interface IProblemDefinition<TEncoding, TEncodedSolution>
     27    where TEncoding : class, IEncoding<TEncodedSolution>
     28    where TEncodedSolution : class, IEncodedSolution {
    2929    TEncoding Encoding { get; }
    3030  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveProblem.cs

    r13361 r16751  
    2424
    2525namespace HeuristicLab.Optimization {
    26   public interface ISingleObjectiveProblem<TEncoding, TSolution> : IProblem<TEncoding, TSolution>, ISingleObjectiveHeuristicOptimizationProblem
    27     where TEncoding : class, IEncoding<TSolution>
    28     where TSolution : class, ISolution {
     26  public interface ISingleObjectiveProblem<TEncoding, TEncodedSolution> : IProblem<TEncoding, TEncodedSolution>, ISingleObjectiveHeuristicOptimizationProblem
     27    where TEncoding : class, IEncoding<TEncodedSolution>
     28    where TEncodedSolution : class, IEncodedSolution {
    2929
    3030  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveProblemDefinition.cs

    r16723 r16751  
    2121
    2222using System.Collections.Generic;
     23using HEAL.Attic;
    2324using HeuristicLab.Core;
    24 using HEAL.Attic;
    2525
    2626namespace HeuristicLab.Optimization {
    2727  [StorableType("7ec7bf7e-aaa7-4681-828b-3401cf67e2b3")]
    28   public interface ISingleObjectiveProblemDefinition<TEncoding, TSolution> : IProblemDefinition<TEncoding, TSolution>
    29     where TEncoding : class, IEncoding<TSolution>
    30     where TSolution : class, ISolution {
     28  public interface ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution> : IProblemDefinition<TEncoding, TEncodedSolution>
     29    where TEncoding : class, IEncoding<TEncodedSolution>
     30    where TEncodedSolution : class, IEncodedSolution {
    3131    bool Maximization { get; }
    32     double Evaluate(TSolution solution, IRandom random);
    33     void Analyze(TSolution[] solutions, double[] qualities, ResultCollection results, IRandom random);
    34     IEnumerable<TSolution> GetNeighbors(TSolution solution, IRandom random);
     32    double Evaluate(TEncodedSolution solution, IRandom random);
     33    void Analyze(TEncodedSolution[] solutions, double[] qualities, ResultCollection results, IRandom random);
     34    IEnumerable<TEncodedSolution> GetNeighbors(TEncodedSolution solution, IRandom random);
    3535    bool IsBetter(double quality, double bestQuality);
    3636  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/IMultiObjectiveAnalysisOperator.cs

    r16723 r16751  
    2121
    2222using System;
     23using HEAL.Attic;
    2324using HeuristicLab.Core;
    24 using HEAL.Attic;
    2525
    2626namespace HeuristicLab.Optimization {
    2727  [StorableType("c9325602-3262-48a4-8985-03657fb0b34f")]
    28   internal interface IMultiObjectiveAnalysisOperator<TSolution> : IEncodingOperator<TSolution>, IAnalyzer, IMultiObjectiveOperator
    29   where TSolution : class, ISolution {
    30     Action<TSolution[], double[][], ResultCollection, IRandom> AnalyzeAction { get; set; }
     28  internal interface IMultiObjectiveAnalysisOperator<TEncodedSolution> : IEncodingOperator<TEncodedSolution>, IAnalyzer, IMultiObjectiveOperator
     29  where TEncodedSolution : class, IEncodedSolution {
     30    Action<TEncodedSolution[], double[][], ResultCollection, IRandom> AnalyzeAction { get; set; }
    3131  }
    3232}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/IMultiObjectiveEvaluationOperator.cs

    r16723 r16751  
    2121
    2222using System;
     23using HEAL.Attic;
    2324using HeuristicLab.Core;
    24 using HEAL.Attic;
    2525
    2626namespace HeuristicLab.Optimization {
    2727  [StorableType("89da568c-70a2-48fb-8e6b-ea078bb6fc3f")]
    28   internal interface IMultiObjectiveEvaluationOperator<TSolution> : IMultiObjectiveEvaluator, IEncodingOperator<TSolution>
    29   where TSolution : class, ISolution {
    30     Func<TSolution, IRandom, double[]> EvaluateFunc { get; set; }
     28  internal interface IMultiObjectiveEvaluationOperator<TEncodedSolution> : IMultiObjectiveEvaluator, IEncodingOperator<TEncodedSolution>
     29  where TEncodedSolution : class, IEncodedSolution {
     30    Func<TEncodedSolution, IRandom, double[]> EvaluateFunc { get; set; }
    3131  }
    3232}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/INeighborBasedOperator.cs

    r16723 r16751  
    2222using System;
    2323using System.Collections.Generic;
     24using HEAL.Attic;
    2425using HeuristicLab.Core;
    25 using HEAL.Attic;
    2626
    2727namespace HeuristicLab.Optimization {
    2828  [StorableType("fda56e0b-9392-4711-9af1-55211bfa24ac")]
    29   internal interface INeighborBasedOperator<TSolution> : IEncodingOperator<TSolution>
    30   where TSolution : class, ISolution {
    31     Func<TSolution, IRandom, IEnumerable<TSolution>> GetNeighborsFunc { get; set; }
     29  internal interface INeighborBasedOperator<TEncodedSolution> : IEncodingOperator<TEncodedSolution>
     30  where TEncodedSolution : class, IEncodedSolution {
     31    Func<TEncodedSolution, IRandom, IEnumerable<TEncodedSolution>> GetNeighborsFunc { get; set; }
    3232  }
    3333}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/ISingleObjectiveAnalysisOperator.cs

    r16723 r16751  
    2626namespace HeuristicLab.Optimization {
    2727  [StorableType("9731981c-10c6-4850-9308-a4720ac07da7")]
    28   internal interface ISingleObjectiveAnalysisOperator<TSolution> : IEncodingOperator<TSolution>, ISingleObjectiveOperator
    29   where TSolution : class, ISolution {
    30     Action<TSolution[], double[], ResultCollection, IRandom> AnalyzeAction { get; set; }
     28  internal interface ISingleObjectiveAnalysisOperator<TEncodedSolution> : IEncodingOperator<TEncodedSolution>, ISingleObjectiveOperator
     29  where TEncodedSolution : class, IEncodedSolution {
     30    Action<TEncodedSolution[], double[], ResultCollection, IRandom> AnalyzeAction { get; set; }
    3131  }
    3232}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/ISingleObjectiveEvaluationOperator.cs

    r16723 r16751  
    2626namespace HeuristicLab.Optimization {
    2727  [StorableType("5a9cf334-4815-4f0e-a2f8-f3d4edfcc829")]
    28   internal interface ISingleObjectiveEvaluationOperator<TSolution> : ISingleObjectiveEvaluator, IEncodingOperator<TSolution>
    29   where TSolution : class, ISolution {
    30     Func<TSolution, IRandom, double> EvaluateFunc { get; set; }
     28  internal interface ISingleObjectiveEvaluationOperator<TEncodedSolution> : ISingleObjectiveEvaluator, IEncodingOperator<TEncodedSolution>
     29  where TEncodedSolution : class, IEncodedSolution {
     30    Func<TEncodedSolution, IRandom, double> EvaluateFunc { get; set; }
    3131  }
    3232}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveProblem.cs

    r16723 r16751  
    2121
    2222using System.Linq;
     23using HEAL.Attic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Data;
    2627using HeuristicLab.Parameters;
    27 using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Optimization {
    3030  [StorableType("6F2EC371-0309-4848-B7B1-C9B9C7E3436F")]
    31   public abstract class MultiObjectiveProblem<TEncoding, TSolution> :
    32     Problem<TEncoding, TSolution, MultiObjectiveEvaluator<TSolution>>,
    33     IMultiObjectiveProblem<TEncoding, TSolution>,
    34     IMultiObjectiveProblemDefinition<TEncoding, TSolution>
    35     where TEncoding : class, IEncoding<TSolution>
    36     where TSolution : class, ISolution {
     31  public abstract class MultiObjectiveProblem<TEncoding, TEncodedSolution> :
     32    Problem<TEncoding, TEncodedSolution, MultiObjectiveEvaluator<TEncodedSolution>>,
     33    IMultiObjectiveProblem<TEncoding, TEncodedSolution>,
     34    IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>
     35    where TEncoding : class, IEncoding<TEncodedSolution>
     36    where TEncodedSolution : class, IEncodedSolution {
    3737
    3838    [StorableConstructor]
    3939    protected MultiObjectiveProblem(StorableConstructorFlag _) : base(_) { }
    4040
    41     protected MultiObjectiveProblem(MultiObjectiveProblem<TEncoding, TSolution> original, Cloner cloner)
     41    protected MultiObjectiveProblem(MultiObjectiveProblem<TEncoding, TEncodedSolution> original, Cloner cloner)
    4242      : base(original, cloner) {
    4343      ParameterizeOperators();
     
    4949
    5050      Operators.Add(Evaluator);
    51       Operators.Add(new MultiObjectiveAnalyzer<TSolution>());
     51      Operators.Add(new MultiObjectiveAnalyzer<TEncodedSolution>());
    5252
    5353      ParameterizeOperators();
     
    6060
    6161    public abstract bool[] Maximization { get; }
    62     public abstract double[] Evaluate(TSolution individual, IRandom random);
    63     public virtual void Analyze(TSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) { }
    64    
     62    public abstract double[] Evaluate(TEncodedSolution individual, IRandom random);
     63    public virtual void Analyze(TEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) { }
     64
    6565    protected override void OnOperatorsChanged() {
    6666      base.OnOperatorsChanged();
     
    9393
    9494    private void ParameterizeOperators() {
    95       foreach (var op in Operators.OfType<IMultiObjectiveEvaluationOperator<TSolution>>())
     95      foreach (var op in Operators.OfType<IMultiObjectiveEvaluationOperator<TEncodedSolution>>())
    9696        op.EvaluateFunc = Evaluate;
    97       foreach (var op in Operators.OfType<IMultiObjectiveAnalysisOperator<TSolution>>())
     97      foreach (var op in Operators.OfType<IMultiObjectiveAnalysisOperator<TEncodedSolution>>())
    9898        op.AnalyzeAction = Analyze;
    9999    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiObjectiveAnalyzer.cs

    r16723 r16751  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    2829using HeuristicLab.Operators;
    2930using HeuristicLab.Parameters;
    30 using HEAL.Attic;
    3131
    3232namespace HeuristicLab.Optimization {
    3333  [Item("Multi-objective Analyzer", "Calls the Analyze method of the problem definition.")]
    3434  [StorableType("903FE3D1-3179-4EA5-A7E1-63DE26239F9B")]
    35   public class MultiObjectiveAnalyzer<TSolution> : SingleSuccessorOperator, IMultiObjectiveAnalysisOperator<TSolution>, IStochasticOperator
    36   where TSolution : class, ISolution {
     35  public class MultiObjectiveAnalyzer<TEncodedSolution> : SingleSuccessorOperator, IMultiObjectiveAnalysisOperator<TEncodedSolution>, IStochasticOperator
     36  where TEncodedSolution : class, IEncodedSolution {
    3737    public bool EnabledByDefault { get { return true; } }
    3838
    39     public ILookupParameter<IEncoding<TSolution>> EncodingParameter {
    40       get { return (ILookupParameter<IEncoding<TSolution>>)Parameters["Encoding"]; }
     39    public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter {
     40      get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; }
    4141    }
    4242
     
    5353    }
    5454
    55     public Action<TSolution[], double[][], ResultCollection, IRandom> AnalyzeAction { get; set; }
     55    public Action<TEncodedSolution[], double[][], ResultCollection, IRandom> AnalyzeAction { get; set; }
    5656
    5757    [StorableConstructor]
    5858    protected MultiObjectiveAnalyzer(StorableConstructorFlag _) : base(_) { }
    59     protected MultiObjectiveAnalyzer(MultiObjectiveAnalyzer<TSolution> original, Cloner cloner) : base(original, cloner) { }
     59    protected MultiObjectiveAnalyzer(MultiObjectiveAnalyzer<TEncodedSolution> original, Cloner cloner) : base(original, cloner) { }
    6060    public MultiObjectiveAnalyzer() {
    6161      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    62       Parameters.Add(new LookupParameter<IEncoding<TSolution>>("Encoding", "An item that holds the problem's encoding."));
     62      Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("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."));
     
    6666
    6767    public override IDeepCloneable Clone(Cloner cloner) {
    68       return new MultiObjectiveAnalyzer<TSolution>(this, cloner);
     68      return new MultiObjectiveAnalyzer<TEncodedSolution>(this, cloner);
    6969    }
    7070
     
    7878        scopes = scopes.Select(x => (IEnumerable<IScope>)x.SubScopes).Aggregate((a, b) => a.Concat(b));
    7979
    80       var individuals = scopes.Select(s => ScopeUtil.GetSolution(s, encoding)).ToArray();
     80      var individuals = scopes.Select(s => 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

    r16723 r16751  
    2121
    2222using System;
     23using HEAL.Attic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    2627using HeuristicLab.Operators;
    2728using HeuristicLab.Parameters;
    28 using HEAL.Attic;
    2929
    3030namespace HeuristicLab.Optimization {
    3131  [Item("Multi-objective Evaluator", "Calls the Evaluate method of the problem definition and writes the return value into the scope.")]
    3232  [StorableType("C5605ED8-0ED2-4C7B-97A1-E7EB68A4FDBF")]
    33   public class MultiObjectiveEvaluator<TSolution> : InstrumentedOperator, IMultiObjectiveEvaluationOperator<TSolution>, IStochasticOperator
    34   where TSolution : class, ISolution {
     33  public class MultiObjectiveEvaluator<TEncodedSolution> : InstrumentedOperator, IMultiObjectiveEvaluationOperator<TEncodedSolution>, IStochasticOperator
     34  where TEncodedSolution : class, IEncodedSolution {
    3535
    3636    public ILookupParameter<IRandom> RandomParameter {
     
    3838    }
    3939
    40     public ILookupParameter<IEncoding<TSolution>> EncodingParameter {
    41       get { return (ILookupParameter<IEncoding<TSolution>>)Parameters["Encoding"]; }
     40    public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter {
     41      get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; }
    4242    }
    4343
     
    4646    }
    4747
    48     public Func<TSolution, IRandom, double[]> EvaluateFunc { get; set; }
     48    public Func<TEncodedSolution, IRandom, double[]> EvaluateFunc { get; set; }
    4949
    5050    [StorableConstructor]
    5151    protected MultiObjectiveEvaluator(StorableConstructorFlag _) : base(_) { }
    52     protected MultiObjectiveEvaluator(MultiObjectiveEvaluator<TSolution> original, Cloner cloner) : base(original, cloner) { }
     52    protected MultiObjectiveEvaluator(MultiObjectiveEvaluator<TEncodedSolution> original, Cloner cloner) : base(original, cloner) { }
    5353    public MultiObjectiveEvaluator() {
    5454      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    55       Parameters.Add(new LookupParameter<IEncoding<TSolution>>("Encoding", "An item that holds the problem's encoding."));
     55      Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));
    5656      Parameters.Add(new LookupParameter<DoubleArray>("Qualities", "The qualities of the parameter vector."));
    5757    }
    5858
    5959    public override IDeepCloneable Clone(Cloner cloner) {
    60       return new MultiObjectiveEvaluator<TSolution>(this, cloner);
     60      return new MultiObjectiveEvaluator<TEncodedSolution>(this, cloner);
    6161    }
    6262
     
    6464      var random = RandomParameter.ActualValue;
    6565      var encoding = EncodingParameter.ActualValue;
    66       var solution = ScopeUtil.GetSolution(ExecutionContext.Scope, encoding);
     66      var solution = 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

    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;
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveAnalyzer.cs

    r16723 r16751  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    2829using HeuristicLab.Operators;
    2930using HeuristicLab.Parameters;
    30 using HEAL.Attic;
    3131
    3232namespace HeuristicLab.Optimization {
    3333  [Item("Single-objective Analyzer", "Calls the script's Analyze method to be able to write into the results collection.")]
    3434  [StorableType("3D20F8E2-CE11-4021-A05B-CFCB02C0FD6F")]
    35   public sealed class SingleObjectiveAnalyzer<TSolution> : SingleSuccessorOperator, ISingleObjectiveAnalysisOperator<TSolution>, IAnalyzer, IStochasticOperator
    36   where TSolution : class, ISolution {
     35  public sealed class SingleObjectiveAnalyzer<TEncodedSolution> : SingleSuccessorOperator, ISingleObjectiveAnalysisOperator<TEncodedSolution>, IAnalyzer, IStochasticOperator
     36  where TEncodedSolution : class, IEncodedSolution {
    3737    public bool EnabledByDefault { get { return true; } }
    3838
    39     public ILookupParameter<IEncoding<TSolution>> EncodingParameter {
    40       get { return (ILookupParameter<IEncoding<TSolution>>)Parameters["Encoding"]; }
     39    public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter {
     40      get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; }
    4141    }
    4242
     
    5353    }
    5454
    55     public Action<TSolution[], double[], ResultCollection, IRandom> AnalyzeAction { get; set; }
     55    public Action<TEncodedSolution[], double[], ResultCollection, IRandom> AnalyzeAction { get; set; }
    5656
    5757    [StorableConstructor]
    5858    private SingleObjectiveAnalyzer(StorableConstructorFlag _) : base(_) { }
    59     private SingleObjectiveAnalyzer(SingleObjectiveAnalyzer<TSolution> original, Cloner cloner) : base(original, cloner) { }
     59    private SingleObjectiveAnalyzer(SingleObjectiveAnalyzer<TEncodedSolution> original, Cloner cloner) : base(original, cloner) { }
    6060    public SingleObjectiveAnalyzer() {
    61       Parameters.Add(new LookupParameter<IEncoding<TSolution>>("Encoding", "An item that holds the problem's encoding."));
     61      Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("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."));
     
    6666
    6767    public override IDeepCloneable Clone(Cloner cloner) {
    68       return new SingleObjectiveAnalyzer<TSolution>(this, cloner);
     68      return new SingleObjectiveAnalyzer<TEncodedSolution>(this, cloner);
    6969    }
    7070
     
    7878        scopes = scopes.Select(x => (IEnumerable<IScope>)x.SubScopes).Aggregate((a, b) => a.Concat(b));
    7979
    80       var individuals = scopes.Select(s => ScopeUtil.GetSolution(s, encoding)).ToArray();
     80      var individuals = scopes.Select(s => ScopeUtil.GetEncodedSolution(s, encoding)).ToArray();
    8181      AnalyzeAction(individuals, QualityParameter.ActualValue.Select(x => x.Value).ToArray(), results, random);
    8282      return base.Apply();
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveEvaluator.cs

    r16723 r16751  
    3131  [Item("Single-objective Evaluator", "Calls the script's Evaluate method to get the quality value of the parameter vector.")]
    3232  [StorableType("E8914B68-D0D7-407F-8D58-002FDF2F45CF")]
    33   public sealed class SingleObjectiveEvaluator<TSolution> : InstrumentedOperator, ISingleObjectiveEvaluationOperator<TSolution>, IStochasticOperator
    34   where TSolution : class, ISolution {
     33  public sealed class SingleObjectiveEvaluator<TEncodedSolution> : InstrumentedOperator, ISingleObjectiveEvaluationOperator<TEncodedSolution>, IStochasticOperator
     34  where TEncodedSolution : class, IEncodedSolution {
    3535
    3636    public ILookupParameter<IRandom> RandomParameter {
     
    3838    }
    3939
    40     public ILookupParameter<IEncoding<TSolution>> EncodingParameter {
    41       get { return (ILookupParameter<IEncoding<TSolution>>)Parameters["Encoding"]; }
     40    public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter {
     41      get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; }
    4242    }
    4343
     
    4646    }
    4747
    48     public Func<TSolution, IRandom, double> EvaluateFunc { get; set; }
     48    public Func<TEncodedSolution, IRandom, double> EvaluateFunc { get; set; }
    4949
    5050    [StorableConstructor]
    5151    private SingleObjectiveEvaluator(StorableConstructorFlag _) : base(_) { }
    52     private SingleObjectiveEvaluator(SingleObjectiveEvaluator<TSolution> original, Cloner cloner) : base(original, cloner) { }
     52    private SingleObjectiveEvaluator(SingleObjectiveEvaluator<TEncodedSolution> original, Cloner cloner) : base(original, cloner) { }
    5353    public SingleObjectiveEvaluator() {
    5454      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    55       Parameters.Add(new LookupParameter<IEncoding<TSolution>>("Encoding", "An item that holds the problem's encoding."));
     55      Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));
    5656      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the parameter vector."));
    5757    }
    5858
    59     public override IDeepCloneable Clone(Cloner cloner) { return new SingleObjectiveEvaluator<TSolution>(this, cloner); }
     59    public override IDeepCloneable Clone(Cloner cloner) { return new SingleObjectiveEvaluator<TEncodedSolution>(this, cloner); }
    6060
    6161    public override IOperation InstrumentedApply() {
    6262      var random = RandomParameter.ActualValue;
    6363      var encoding = EncodingParameter.ActualValue;
    64       var solution = ScopeUtil.GetSolution(ExecutionContext.Scope, encoding);
     64      var solution = ScopeUtil.GetEncodedSolution(ExecutionContext.Scope, encoding);
    6565      QualityParameter.ActualValue = new DoubleValue(EvaluateFunc(solution, random));
    6666      return base.InstrumentedApply();
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveImprover.cs

    r16723 r16751  
    3333  [Item("Single-objective Improver", "Improves a solution by calling GetNeighbors and Evaluate of the corresponding problem definition.")]
    3434  [StorableType("7A917E09-920C-4B47-9599-67371101B35F")]
    35   public sealed class SingleObjectiveImprover<TSolution> : SingleSuccessorOperator, INeighborBasedOperator<TSolution>, IImprovementOperator, ISingleObjectiveEvaluationOperator<TSolution>, IStochasticOperator
    36     where TSolution : class, ISolution {
     35  public sealed class SingleObjectiveImprover<TEncodedSolution> : SingleSuccessorOperator, INeighborBasedOperator<TEncodedSolution>, IImprovementOperator, ISingleObjectiveEvaluationOperator<TEncodedSolution>, IStochasticOperator
     36    where TEncodedSolution : class, IEncodedSolution {
    3737    public ILookupParameter<IRandom> RandomParameter {
    3838      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
    3939    }
    4040
    41     public ILookupParameter<IEncoding<TSolution>> EncodingParameter {
    42       get { return (ILookupParameter<IEncoding<TSolution>>)Parameters["Encoding"]; }
     41    public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter {
     42      get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; }
    4343    }
    4444
     
    6363    }
    6464
    65     public Func<TSolution, IRandom, double> EvaluateFunc { get; set; }
    66     public Func<TSolution, IRandom, IEnumerable<TSolution>> GetNeighborsFunc { get; set; }
     65    public Func<TEncodedSolution, IRandom, double> EvaluateFunc { get; set; }
     66    public Func<TEncodedSolution, IRandom, IEnumerable<TEncodedSolution>> GetNeighborsFunc { get; set; }
    6767
    6868    [StorableConstructor]
    6969    private SingleObjectiveImprover(StorableConstructorFlag _) : base(_) { }
    70     private SingleObjectiveImprover(SingleObjectiveImprover<TSolution> original, Cloner cloner) : base(original, cloner) { }
     70    private SingleObjectiveImprover(SingleObjectiveImprover<TEncodedSolution> original, Cloner cloner) : base(original, cloner) { }
    7171    public SingleObjectiveImprover() {
    7272      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    73       Parameters.Add(new LookupParameter<IEncoding<TSolution>>("Encoding", "An item that holds the problem's encoding."));
     73      Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));
    7474      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the parameter vector."));
    7575      Parameters.Add(new LookupParameter<BoolValue>("Maximization", "Whether the problem should be minimized or maximized."));
     
    8080
    8181    public override IDeepCloneable Clone(Cloner cloner) {
    82       return new SingleObjectiveImprover<TSolution>(this, cloner);
     82      return new SingleObjectiveImprover<TEncodedSolution>(this, cloner);
    8383    }
    8484
     
    8989      var maxAttempts = ImprovementAttemptsParameter.ActualValue.Value;
    9090      var sampleSize = SampleSizeParameter.ActualValue.Value;
    91       var solution = ScopeUtil.GetSolution(ExecutionContext.Scope, encoding);
     91      var solution = ScopeUtil.GetEncodedSolution(ExecutionContext.Scope, encoding);
    9292      var quality = QualityParameter.ActualValue == null ? EvaluateFunc(solution, random) : QualityParameter.ActualValue.Value;
    9393
    9494      var count = 0;
    9595      for (var i = 0; i < maxAttempts; i++) {
    96         TSolution best = default(TSolution);
     96        TEncodedSolution best = default(TEncodedSolution);
    9797        var bestQuality = quality;
    9898        foreach (var neighbor in GetNeighborsFunc(solution, random).Take(sampleSize)) {
     
    111111      QualityParameter.ActualValue = new DoubleValue(quality);
    112112
    113       ScopeUtil.CopySolutionToScope(ExecutionContext.Scope, encoding, solution);
     113      ScopeUtil.CopyEncodedSolutionToScope(ExecutionContext.Scope, encoding, solution);
    114114      return base.Apply();
    115115    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveMoveEvaluator.cs

    r16723 r16751  
    2121
    2222using System;
     23using HEAL.Attic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    2627using HeuristicLab.Operators;
    2728using HeuristicLab.Parameters;
    28 using HEAL.Attic;
    2929
    3030namespace HeuristicLab.Optimization {
    3131  [Item("Single-objective MoveEvaluator", "Evaluates a parameter vector that results from a move.")]
    3232  [StorableType("EE4B1EBA-50BF-40C7-B338-F4A9D9CC554E")]
    33   public class SingleObjectiveMoveEvaluator<TSolution> : SingleSuccessorOperator, ISingleObjectiveEvaluationOperator<TSolution>, ISingleObjectiveMoveEvaluator, IStochasticOperator, ISingleObjectiveMoveOperator
    34   where TSolution : class, ISolution {
     33  public class SingleObjectiveMoveEvaluator<TEncodedSolution> : SingleSuccessorOperator, ISingleObjectiveEvaluationOperator<TEncodedSolution>, ISingleObjectiveMoveEvaluator, IStochasticOperator, ISingleObjectiveMoveOperator
     34  where TEncodedSolution : class, IEncodedSolution {
    3535
    3636    public ILookupParameter<IRandom> RandomParameter {
     
    3838    }
    3939
    40     public ILookupParameter<IEncoding<TSolution>> EncodingParameter {
    41       get { return (ILookupParameter<IEncoding<TSolution>>)Parameters["Encoding"]; }
     40    public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter {
     41      get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; }
    4242    }
    4343
     
    5050    }
    5151
    52     public Func<TSolution, IRandom, double> EvaluateFunc { get; set; }
     52    public Func<TEncodedSolution, IRandom, double> EvaluateFunc { get; set; }
    5353
    5454    [StorableConstructor]
    5555    protected SingleObjectiveMoveEvaluator(StorableConstructorFlag _) : base(_) { }
    56     protected SingleObjectiveMoveEvaluator(SingleObjectiveMoveEvaluator<TSolution> original, Cloner cloner) : base(original, cloner) { }
     56    protected SingleObjectiveMoveEvaluator(SingleObjectiveMoveEvaluator<TEncodedSolution> original, Cloner cloner) : base(original, cloner) { }
    5757    public SingleObjectiveMoveEvaluator() {
    5858      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    59       Parameters.Add(new LookupParameter<IEncoding<TSolution>>("Encoding", "An item that holds the problem's encoding."));
     59      Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));
    6060      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the parameter vector."));
    6161      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The quality of the move."));
     
    6363
    6464    public override IDeepCloneable Clone(Cloner cloner) {
    65       return new SingleObjectiveMoveEvaluator<TSolution>(this, cloner);
     65      return new SingleObjectiveMoveEvaluator<TEncodedSolution>(this, cloner);
    6666    }
    6767
     
    6969      var random = RandomParameter.ActualValue;
    7070      var encoding = EncodingParameter.ActualValue;
    71       var individual = ScopeUtil.GetSolution(ExecutionContext.Scope, encoding);
     71      var individual = ScopeUtil.GetEncodedSolution(ExecutionContext.Scope, encoding);
    7272      MoveQualityParameter.ActualValue = new DoubleValue(EvaluateFunc(individual, random));
    7373      return base.Apply();
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveMoveGenerator.cs

    r16723 r16751  
    3434  [Item("Single-objective MoveGenerator", "Calls the GetNeighbors method of the problem definition to obtain the moves.")]
    3535  [StorableType("CB37E7D8-EAC3-4061-9D39-20538CD1064D")]
    36   public class SingleObjectiveMoveGenerator<TSolution> : SingleSuccessorOperator, INeighborBasedOperator<TSolution>, IMultiMoveGenerator, IStochasticOperator, ISingleObjectiveMoveOperator
    37   where TSolution : class, ISolution {
     36  public class SingleObjectiveMoveGenerator<TEncodedSolution> : SingleSuccessorOperator, INeighborBasedOperator<TEncodedSolution>, IMultiMoveGenerator, IStochasticOperator, ISingleObjectiveMoveOperator
     37  where TEncodedSolution : class, IEncodedSolution {
    3838    public ILookupParameter<IRandom> RandomParameter {
    3939      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
     
    4444    }
    4545
    46     public ILookupParameter<IEncoding<TSolution>> EncodingParameter {
    47       get { return (ILookupParameter<IEncoding<TSolution>>)Parameters["Encoding"]; }
     46    public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter {
     47      get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; }
    4848    }
    4949
    50     public Func<TSolution, IRandom, IEnumerable<TSolution>> GetNeighborsFunc { get; set; }
     50    public Func<TEncodedSolution, IRandom, IEnumerable<TEncodedSolution>> GetNeighborsFunc { get; set; }
    5151
    5252    [StorableConstructor]
    5353    protected SingleObjectiveMoveGenerator(StorableConstructorFlag _) : base(_) { }
    54     protected SingleObjectiveMoveGenerator(SingleObjectiveMoveGenerator<TSolution> original, Cloner cloner)
     54    protected SingleObjectiveMoveGenerator(SingleObjectiveMoveGenerator<TEncodedSolution> original, Cloner cloner)
    5555      : base(original, cloner) { }
    5656    public SingleObjectiveMoveGenerator() {
    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<TSolution>>("Encoding", "An item that holds the problem's encoding."));
     59      Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));
    6060    }
    6161
    6262    public override IDeepCloneable Clone(Cloner cloner) {
    63       return new SingleObjectiveMoveGenerator<TSolution>(this, cloner);
     63      return new SingleObjectiveMoveGenerator<TEncodedSolution>(this, cloner);
    6464    }
    6565
     
    6868      var sampleSize = SampleSizeParameter.ActualValue.Value;
    6969      var encoding = EncodingParameter.ActualValue;
    70       var solution = ScopeUtil.GetSolution(ExecutionContext.Scope, encoding);
     70      var solution = ScopeUtil.GetEncodedSolution(ExecutionContext.Scope, encoding);
    7171      var nbhood = GetNeighborsFunc(solution, random).Take(sampleSize).ToList();
    7272
     
    7474      for (int i = 0; i < moveScopes.Length; i++) {
    7575        moveScopes[i] = new Scope(i.ToString(CultureInfo.InvariantCulture.NumberFormat));
    76         ScopeUtil.CopySolutionToScope(moveScopes[i], encoding, nbhood[i]);
     76        ScopeUtil.CopyEncodedSolutionToScope(moveScopes[i], encoding, nbhood[i]);
    7777      }
    7878      ExecutionContext.Scope.SubScopes.AddRange(moveScopes);
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveMoveMaker.cs

    r16723 r16751  
    2121
    2222using System;
     23using HEAL.Attic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    2627using HeuristicLab.Operators;
    2728using HeuristicLab.Parameters;
    28 using HEAL.Attic;
    2929
    3030namespace HeuristicLab.Optimization {
    3131  [Item("Single-objective MoveMaker", "Applies a move.")]
    3232  [StorableType("C0ABF392-C825-4B98-8FB9-5749A9091FD6")]
    33   public class SingleObjectiveMoveMaker<TSolution> : InstrumentedOperator, IMoveMaker, ISingleObjectiveMoveOperator
    34   where TSolution : class, ISolution {
    35     public ILookupParameter<IEncoding<TSolution>> EncodingParameter {
    36       get { return (ILookupParameter<IEncoding<TSolution>>)Parameters["Encoding"]; }
     33  public 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"]; }
    3737    }
    3838
     
    4747    [StorableConstructor]
    4848    protected SingleObjectiveMoveMaker(StorableConstructorFlag _) : base(_) { }
    49     protected SingleObjectiveMoveMaker(SingleObjectiveMoveMaker<TSolution> original, Cloner cloner) : base(original, cloner) { }
     49    protected SingleObjectiveMoveMaker(SingleObjectiveMoveMaker<TEncodedSolution> original, Cloner cloner) : base(original, cloner) { }
    5050    public SingleObjectiveMoveMaker() {
    51       Parameters.Add(new LookupParameter<IEncoding<TSolution>>("Encoding", "An item that holds the problem's encoding."));
     51      Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));
    5252      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the parameter vector."));
    5353      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The quality of the move."));
     
    5555
    5656    public override IDeepCloneable Clone(Cloner cloner) {
    57       return new SingleObjectiveMoveMaker<TSolution>(this, cloner);
     57      return new SingleObjectiveMoveMaker<TEncodedSolution>(this, cloner);
    5858    }
    5959
     
    6262
    6363      var encoding = EncodingParameter.ActualValue;
    64       var solution = ScopeUtil.GetSolution(ExecutionContext.Scope, encoding);
    65       ScopeUtil.CopySolutionToScope(ExecutionContext.Scope.Parent.Parent, encoding, solution);
     64      var solution = ScopeUtil.GetEncodedSolution(ExecutionContext.Scope, encoding);
     65      ScopeUtil.CopyEncodedSolutionToScope(ExecutionContext.Scope.Parent.Parent, encoding, solution);
    6666
    6767      if (QualityParameter.ActualValue == null) QualityParameter.ActualValue = new DoubleValue(MoveQualityParameter.ActualValue.Value);
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Problem.cs

    r16723 r16751  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Parameters;
    28 using HEAL.Attic;
    2929
    3030namespace HeuristicLab.Optimization {
    3131  [StorableType("D877082E-9E77-4CB1-ABDB-35F63878E116")]
    32   public abstract class Problem<TEncoding, TSolution, TEvaluator> : Problem,
    33     IHeuristicOptimizationProblem, IProblemDefinition<TEncoding, TSolution>, IStorableContent
    34     where TEncoding : class, IEncoding<TSolution>
    35     where TSolution : class, ISolution
     32  public abstract class Problem<TEncoding, TEncodedSolution, TEvaluator> : Problem,
     33    IHeuristicOptimizationProblem, IProblemDefinition<TEncoding, TEncodedSolution>, IStorableContent
     34    where TEncoding : class, IEncoding<TEncodedSolution>
     35    where TEncodedSolution : class, IEncodedSolution
    3636    where TEvaluator : class, IEvaluator {
    3737
    3838    public string Filename { get; set; } // TODO: Really okay here? should be in Problem (non-generic)
    3939
    40     //TODO remove parametr for encoding?
     40    //TODO remove parameter for encoding?
    4141    protected IValueParameter<TEncoding> EncodingParameter {
    4242      get { return (IValueParameter<TEncoding>)Parameters["Encoding"]; }
     
    115115    }
    116116
    117     protected Problem(Problem<TEncoding, TSolution, TEvaluator> original, Cloner cloner)
     117    protected Problem(Problem<TEncoding, TEncodedSolution, TEvaluator> original, Cloner cloner)
    118118      : base(original, cloner) {
    119119      oldEncoding = cloner.Clone(original.oldEncoding);
     
    152152      oldEncoding = Encoding;
    153153
    154       foreach (var op in Operators.OfType<IEncodingOperator<TSolution>>())
     154      foreach (var op in Operators.OfType<IEncodingOperator<TEncodedSolution>>())
    155155        op.EncodingParameter.ActualName = EncodingParameter.Name;
    156156
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveProblem.cs

    r16723 r16751  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Data;
    2829using HeuristicLab.Parameters;
    29 using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Optimization {
    3232  [StorableType("2697320D-0259-44BB-BD71-7EE1B10F664C")]
    33   public abstract class SingleObjectiveProblem<TEncoding, TSolution> :
    34     Problem<TEncoding, TSolution, SingleObjectiveEvaluator<TSolution>>,
    35     ISingleObjectiveProblem<TEncoding, TSolution>,
    36     ISingleObjectiveProblemDefinition<TEncoding, TSolution>
    37     where TEncoding : class, IEncoding<TSolution>
    38     where TSolution : class, ISolution {
     33  public abstract class SingleObjectiveProblem<TEncoding, TEncodedSolution> :
     34    Problem<TEncoding, TEncodedSolution, SingleObjectiveEvaluator<TEncodedSolution>>,
     35    ISingleObjectiveProblem<TEncoding, TEncodedSolution>,
     36    ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>
     37    where TEncoding : class, IEncoding<TEncodedSolution>
     38    where TEncodedSolution : class, IEncodedSolution {
    3939
    4040    protected IValueParameter<DoubleValue> BestKnownQualityParameter {
     
    6464    protected SingleObjectiveProblem(StorableConstructorFlag _) : base(_) { }
    6565
    66     protected SingleObjectiveProblem(SingleObjectiveProblem<TEncoding, TSolution> original, Cloner cloner)
     66    protected SingleObjectiveProblem(SingleObjectiveProblem<TEncoding, TEncodedSolution> original, Cloner cloner)
    6767      : base(original, cloner) {
    6868      ParameterizeOperators();
     
    7575
    7676      Operators.Add(Evaluator);
    77       Operators.Add(new SingleObjectiveAnalyzer<TSolution>());
    78       Operators.Add(new SingleObjectiveImprover<TSolution>());
    79       Operators.Add(new SingleObjectiveMoveEvaluator<TSolution>());
    80       Operators.Add(new SingleObjectiveMoveGenerator<TSolution>());
    81       Operators.Add(new SingleObjectiveMoveMaker<TSolution>());
     77      Operators.Add(new SingleObjectiveAnalyzer<TEncodedSolution>());
     78      Operators.Add(new SingleObjectiveImprover<TEncodedSolution>());
     79      Operators.Add(new SingleObjectiveMoveEvaluator<TEncodedSolution>());
     80      Operators.Add(new SingleObjectiveMoveGenerator<TEncodedSolution>());
     81      Operators.Add(new SingleObjectiveMoveMaker<TEncodedSolution>());
    8282
    8383      ParameterizeOperators();
     
    9090
    9191      Operators.Add(Evaluator);
    92       Operators.Add(new SingleObjectiveAnalyzer<TSolution>());
    93       Operators.Add(new SingleObjectiveImprover<TSolution>());
    94       Operators.Add(new SingleObjectiveMoveEvaluator<TSolution>());
    95       Operators.Add(new SingleObjectiveMoveGenerator<TSolution>());
    96       Operators.Add(new SingleObjectiveMoveMaker<TSolution>());
     92      Operators.Add(new SingleObjectiveAnalyzer<TEncodedSolution>());
     93      Operators.Add(new SingleObjectiveImprover<TEncodedSolution>());
     94      Operators.Add(new SingleObjectiveMoveEvaluator<TEncodedSolution>());
     95      Operators.Add(new SingleObjectiveMoveGenerator<TEncodedSolution>());
     96      Operators.Add(new SingleObjectiveMoveMaker<TEncodedSolution>());
    9797
    9898      ParameterizeOperators();
     
    105105
    106106    public abstract bool Maximization { get; }
    107     public abstract double Evaluate(TSolution solution, IRandom random);
    108     public virtual void Analyze(TSolution[] solutions, double[] qualities, ResultCollection results, IRandom random) { }
    109     public virtual IEnumerable<TSolution> GetNeighbors(TSolution solution, IRandom random) {
    110       return Enumerable.Empty<TSolution>();
     107    public abstract double Evaluate(TEncodedSolution solution, IRandom random);
     108    public virtual void Analyze(TEncodedSolution[] solutions, double[] qualities, ResultCollection results, IRandom random) { }
     109    public virtual IEnumerable<TEncodedSolution> GetNeighbors(TEncodedSolution solution, IRandom random) {
     110      return Enumerable.Empty<TEncodedSolution>();
    111111    }
    112112
     
    115115    }
    116116
    117     protected Tuple<TSolution, double> GetBestSolution(TSolution[] solutions, double[] qualities) {
     117    protected Tuple<TEncodedSolution, double> GetBestSolution(TEncodedSolution[] solutions, double[] qualities) {
    118118      return GetBestSolution(solutions, qualities, Maximization);
    119119    }
    120     public static Tuple<TSolution, double> GetBestSolution(TSolution[] solutions, double[] qualities, bool maximization) {
     120    public static Tuple<TEncodedSolution, double> GetBestSolution(TEncodedSolution[] solutions, double[] qualities, bool maximization) {
    121121      var zipped = solutions.Zip(qualities, (s, q) => new { Solution = s, Quality = q });
    122122      var best = (maximization ? zipped.OrderByDescending(z => z.Quality) : zipped.OrderBy(z => z.Quality)).First();
     
    154154
    155155    private void ParameterizeOperators() {
    156       foreach (var op in Operators.OfType<ISingleObjectiveEvaluationOperator<TSolution>>())
     156      foreach (var op in Operators.OfType<ISingleObjectiveEvaluationOperator<TEncodedSolution>>())
    157157        op.EvaluateFunc = Evaluate;
    158       foreach (var op in Operators.OfType<ISingleObjectiveAnalysisOperator<TSolution>>())
     158      foreach (var op in Operators.OfType<ISingleObjectiveAnalysisOperator<TEncodedSolution>>())
    159159        op.AnalyzeAction = Analyze;
    160       foreach (var op in Operators.OfType<INeighborBasedOperator<TSolution>>())
     160      foreach (var op in Operators.OfType<INeighborBasedOperator<TEncodedSolution>>())
    161161        op.GetNeighborsFunc = GetNeighbors;
    162162    }
Note: See TracChangeset for help on using the changeset viewer.