Changeset 16751


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

#2521: Renamed Solution to EncodedSolution.

Location:
branches/2521_ProblemRefactoring
Files:
51 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Analysis/3.3/AlleleFrequencyAnalysis/AlleleFrequencyAnalyzer.cs

    r16723 r16751  
    3737  [Item("AlleleFrequencyAnalyzer", "An operator for analyzing the frequency of alleles.")]
    3838  [StorableType("FB4ABEB4-E94E-4B79-9356-8AC48D8F77BE")]
    39   public abstract class AlleleFrequencyAnalyzer<T> : SingleSuccessorOperator, IAnalyzer, ISingleObjectiveOperator where T : class, ISolution {
     39  public abstract class AlleleFrequencyAnalyzer<T> : SingleSuccessorOperator, IAnalyzer, ISingleObjectiveOperator where T : class, IEncodedSolution {
    4040    public virtual bool EnabledByDefault {
    4141      get { return false; }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVector.cs

    r16723 r16751  
    2929  [StorableType("B349929A-675C-41F4-AEB9-EEA3121E73A9")]
    3030  [Item("BinaryVector", "Represents a vector of binary values.")]
    31   public class BinaryVector : BoolArray, ISolution {
     31  public class BinaryVector : BoolArray, IEncodedSolution {
    3232    [StorableConstructor]
    3333    protected BinaryVector(StorableConstructorFlag _) : base(_) { }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVector.cs

    r16723 r16751  
    3030  [StorableType("2DDD33C1-4732-478B-83B1-17226A8F2B61")]
    3131  [Item("IntegerVector", "Represents a vector of integer values.")]
    32   public class IntegerVector : IntArray, ISolution {
     32  public class IntegerVector : IntArray, IEncodedSolution {
    3333    [StorableConstructor]
    3434    protected IntegerVector(StorableConstructorFlag _) : base(_) { }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkage.cs

    r16723 r16751  
    3232  [Item("LinearLinkage", "Represents an LLE grouping of items.")]
    3333  [StorableType("91492281-3335-4F5A-82BA-BA76142DAD2D")]
    34   public sealed class LinearLinkage : IntArray, ISolution {
     34  public sealed class LinearLinkage : IntArray, IEncodedSolution {
    3535
    3636    [StorableConstructor]
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Permutation.cs

    r16723 r16751  
    3030  [Item("Permutation", "Represents a permutation of integer values.")]
    3131  [StorableType("FBBCFA53-C1AE-4069-907B-99C720F5AC51")]
    32   public class Permutation : IntArray, ISolution {
     32  public class Permutation : IntArray, IEncodedSolution {
    3333    [Storable]
    3434    private PermutationTypes permutationType;
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVector.cs

    r16723 r16751  
    3030  [StorableType("C4213FB3-77C3-4814-A7A3-0151B0FF5270")]
    3131  [Item("RealVector", "Represents a vector of real values.")]
    32   public class RealVector : DoubleArray, ISolution {
     32  public class RealVector : DoubleArray, IEncodedSolution {
    3333    [StorableConstructor]
    3434    protected RealVector(StorableConstructorFlag _) : base(_) { }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/ISchedule.cs

    r13437 r16751  
    2323
    2424namespace HeuristicLab.Encodings.ScheduleEncoding {
    25   public interface ISchedule : ISolution {
     25  public interface ISchedule : IEncodedSolution {
    2626  }
    2727}
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTree.cs

    r16723 r16751  
    2828namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    2929  [StorableType("433dd098-7813-4226-aa76-a41d63c25f81")]
    30   public interface ISymbolicExpressionTree : IItem, ISolution {
     30  public interface ISymbolicExpressionTree : IItem, IEncodedSolution {
    3131    ISymbolicExpressionTreeNode Root { get; set; }
    3232    int Length { get; }
  • 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    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r16723 r16751  
    143143    <Compile Include="BasicProblems\Interfaces\ISingleObjectiveMoveOperator.cs" />
    144144    <Compile Include="BasicProblems\Interfaces\ISingleObjectiveProblemDefinition.cs" />
    145     <Compile Include="BasicProblems\Interfaces\ISolution.cs" />
     145    <Compile Include="BasicProblems\Interfaces\IEncodedSolution.cs" />
    146146    <Compile Include="BasicProblems\MultiObjectiveProblem.cs" />
    147147    <Compile Include="BasicProblems\Operators\MultiObjectiveAnalyzer.cs" />
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Interfaces/IProblem.cs

    r16723 r16751  
    2222using System;
    2323using System.Collections.Generic;
     24using HEAL.Attic;
    2425using HeuristicLab.Core;
    25 using HEAL.Attic;
    2626
    2727namespace HeuristicLab.Optimization {
     
    3838  }
    3939
    40   public interface IProblem<TEncoding, TSolution> : IHeuristicOptimizationProblem
    41     where TEncoding : class, IEncoding<TSolution>
    42     where TSolution : class, ISolution {
     40  public interface IProblem<TEncoding, TEncodedSolution> : IHeuristicOptimizationProblem
     41    where TEncoding : class, IEncoding<TEncodedSolution>
     42    where TEncodedSolution : class, IEncodedSolution {
    4343  }
    4444}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Interfaces/ISolutionCreator.cs

    r16723 r16751  
    2020#endregion
    2121
     22using HEAL.Attic;
    2223using HeuristicLab.Core;
    23 using HEAL.Attic;
    2424
    2525namespace HeuristicLab.Optimization {
     
    3030  public interface ISolutionCreator : IOperator { }
    3131
    32   public interface ISolutionCreator<TSolution> : ISolutionCreator where TSolution : class, ISolution {
    33     //ILookupParameter<TSolution> SolutionParameter { get; } // TODO: unify encoding specific parameters by defining ISolutionOperator and ISolutionsOperator
     32  public interface ISolutionCreator<TEncodedSolution> : ISolutionCreator where TEncodedSolution : class, IEncodedSolution {
     33    //ILookupParameter<TEncodedSolution> SolutionParameter { get; } // TODO: unify encoding specific parameters by defining ISolutionOperator and ISolutionsOperator
    3434  }
    3535}
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/ExternalEvaluationProblem.cs

    r16723 r16751  
    4040  // BackwardsCompatibility3.3
    4141  // Rename class to SingleObjectiveExternalEvaluationProblem
    42   public class ExternalEvaluationProblem : SingleObjectiveProblem<IEncoding<ISolution>, ISolution>, IExternalEvaluationProblem {
     42  public class ExternalEvaluationProblem : SingleObjectiveProblem<IEncoding<IEncodedSolution>, IEncodedSolution>, IExternalEvaluationProblem {
    4343
    4444    public static new Image StaticItemImage {
     
    6666
    6767    #region Properties
    68     public new IEncoding<ISolution> Encoding {
     68    public new IEncoding<IEncodedSolution> Encoding {
    6969      get { return base.Encoding; }
    7070      set { base.Encoding = value; }
     
    114114    }
    115115
    116     public override double Evaluate(ISolution individual, IRandom random) {
     116    public override double Evaluate(IEncodedSolution individual, IRandom random) {
    117117      var qualityMessage = Evaluate(BuildSolutionMessage(individual));
    118118      if (!qualityMessage.HasExtension(SingleObjectiveQualityMessage.QualityMessage_))
     
    126126    }
    127127
    128     public override void Analyze(ISolution[] individuals, double[] qualities, ResultCollection results, IRandom random) {
     128    public override void Analyze(IEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random) {
    129129      OptimizationSupport.Analyze(individuals, qualities, results, random);
    130130    }
    131131
    132     public override IEnumerable<ISolution> GetNeighbors(ISolution individual, IRandom random) {
     132    public override IEnumerable<IEncodedSolution> GetNeighbors(IEncodedSolution individual, IRandom random) {
    133133      return OptimizationSupport.GetNeighbors(individual, random);
    134134    }
     
    167167    }
    168168
    169     private SolutionMessage BuildSolutionMessage(ISolution solution, int solutionId = 0) {
     169    private SolutionMessage BuildSolutionMessage(IEncodedSolution solution, int solutionId = 0) {
    170170      lock (clientLock) {
    171171        SolutionMessage.Builder protobufBuilder = SolutionMessage.CreateBuilder();
    172172        protobufBuilder.SolutionId = solutionId;
    173173        var scope = new Scope();
    174         ScopeUtil.CopySolutionToScope(scope, Encoding, solution);
     174        ScopeUtil.CopyEncodedSolutionToScope(scope, Encoding, solution);
    175175        foreach (var variable in scope.Variables) {
    176176          try {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Interfaces/IMultiObjectiveOptimizationSupport.cs

    r16723 r16751  
    2727  [StorableType("f924ef9c-d824-40d2-89b2-6dd1220df98b")]
    2828  public interface IMultiObjectiveOptimizationSupport {
    29     void Analyze(ISolution[] individuals, double[][] qualities, ResultCollection results, IRandom random);
     29    void Analyze(IEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random);
    3030  }
    3131}
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Interfaces/ISingleObjectiveOptimizationSupport.cs

    r16723 r16751  
    2828  [StorableType("09d522e0-c10f-474c-b7c0-7d7f98e63f44")]
    2929  public interface ISingleObjectiveOptimizationSupport {
    30     void Analyze(ISolution[] individuals, double[] qualities, ResultCollection results, IRandom random);
    31     IEnumerable<ISolution> GetNeighbors(ISolution individual, IRandom random);
     30    void Analyze(IEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random);
     31    IEnumerable<IEncodedSolution> GetNeighbors(IEncodedSolution individual, IRandom random);
    3232  }
    3333}
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/MultiObjectiveExternalEvaluationProblem.cs

    r16723 r16751  
    3737  [Creatable(CreatableAttribute.Categories.ExternalEvaluationProblems, Priority = 200)]
    3838  [StorableType("CCA50199-A6AB-4C84-B4FA-0262CAF416EC")]
    39   public class MultiObjectiveExternalEvaluationProblem : MultiObjectiveProblem<IEncoding<ISolution>, ISolution>, IExternalEvaluationProblem {
     39  public class MultiObjectiveExternalEvaluationProblem : MultiObjectiveProblem<IEncoding<IEncodedSolution>, IEncodedSolution>, IExternalEvaluationProblem {
    4040
    4141    public static new Image StaticItemImage {
     
    6363
    6464    #region Properties
    65     public new IEncoding<ISolution> Encoding {
     65    public new IEncoding<IEncodedSolution> Encoding {
    6666      get { return base.Encoding; }
    6767      set { base.Encoding = value; }
     
    114114    }
    115115
    116     public override double[] Evaluate(ISolution individual, IRandom random) {
     116    public override double[] Evaluate(IEncodedSolution individual, IRandom random) {
    117117      var qualityMessage = Evaluate(BuildSolutionMessage(individual));
    118118      if (!qualityMessage.HasExtension(MultiObjectiveQualityMessage.QualityMessage_))
     
    126126    }
    127127
    128     public override void Analyze(ISolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
     128    public override void Analyze(IEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
    129129      OptimizationSupport.Analyze(individuals, qualities, results, random);
    130130    }
     
    164164    }
    165165
    166     private SolutionMessage BuildSolutionMessage(ISolution solution, int solutionId = 0) {
     166    private SolutionMessage BuildSolutionMessage(IEncodedSolution solution, int solutionId = 0) {
    167167      lock (clientLock) {
    168168        SolutionMessage.Builder protobufBuilder = SolutionMessage.CreateBuilder();
    169169        protobufBuilder.SolutionId = solutionId;
    170170        var scope = new Scope();
    171         ScopeUtil.CopySolutionToScope(scope, Encoding, solution);
     171        ScopeUtil.CopyEncodedSolutionToScope(scope, Encoding, solution);
    172172        foreach (var variable in scope.Variables) {
    173173          try {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/CompiledMultiObjectiveOptimizationSupport.cs

    r13372 r16751  
    55  public class CompiledMultiObjectiveOptimizationSupport : CompiledOptimizationSupport, IMultiObjectiveOptimizationSupport {
    66
    7     public void Analyze(ISolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
     7    public void Analyze(IEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
    88      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    99      // Write or update results given the range of vectors and resulting qualities
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/CompiledSingleObjectiveOptimizationSupport.cs

    r13372 r16751  
    66  public class CompiledSingleObjectiveOptimizationSupport : CompiledOptimizationSupport, ISingleObjectiveOptimizationSupport {
    77
    8     public void Analyze(ISolution[] individuals, double[] qualities, ResultCollection results, IRandom random) {
     8    public void Analyze(IEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random) {
    99      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    1010      // Write or update results given the range of vectors and resulting qualities
     
    1717    }
    1818
    19     public IEnumerable<ISolution> GetNeighbors(ISolution individual, IRandom random) {
     19    public IEnumerable<IEncodedSolution> GetNeighbors(IEncodedSolution individual, IRandom random) {
    2020      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    2121      // Create new vectors, based on the given one that represent small changes
     
    2424        // Algorithm will draw only a finite amount of samples
    2525        // Change to a for-loop to return a concrete amount of neighbors
    26         var neighbor = (ISolution)individual.Clone();
     26        var neighbor = (IEncodedSolution)individual.Clone();
    2727        // For instance, perform a single bit-flip in a binary parameter
    2828        //var bIndex = random.Next(neighbor.BinaryVector("b").Length);
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/MultiObjectiveOptimizationSupportScript.cs

    r16723 r16751  
    3939    }
    4040
    41     void IMultiObjectiveOptimizationSupport.Analyze(ISolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
     41    void IMultiObjectiveOptimizationSupport.Analyze(IEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
    4242      CompiledInstance.Analyze(individuals, qualities, results, random);
    4343    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/SingleObjectiveOptimizationSupportScript.cs

    r16723 r16751  
    4040    }
    4141
    42     void ISingleObjectiveOptimizationSupport.Analyze(ISolution[] individuals, double[] qualities, ResultCollection results, IRandom random) {
     42    void ISingleObjectiveOptimizationSupport.Analyze(IEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random) {
    4343      CompiledInstance.Analyze(individuals, qualities, results, random);
    4444    }
    4545
    46     IEnumerable<ISolution> ISingleObjectiveOptimizationSupport.GetNeighbors(ISolution individual, IRandom random) {
     46    IEnumerable<IEncodedSolution> ISingleObjectiveOptimizationSupport.GetNeighbors(IEncodedSolution individual, IRandom random) {
    4747      return CompiledInstance.GetNeighbors(individual, random);
    4848    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/CompiledProblemDefinition.cs

    r16723 r16751  
    2626
    2727namespace HeuristicLab.Problems.Programmable {
    28   public abstract class CompiledProblemDefinition<TEncoding, TSolution> : IProblemDefinition<TEncoding, TSolution>
    29     where TEncoding : class, IEncoding<TSolution>
    30     where TSolution : class, ISolution {
     28  public abstract class CompiledProblemDefinition<TEncoding, TEncodedSolution> : IProblemDefinition<TEncoding, TEncodedSolution>
     29    where TEncoding : class, IEncoding<TEncodedSolution>
     30    where TEncodedSolution : class, IEncodedSolution {
    3131    private TEncoding encoding;
    3232    public TEncoding Encoding {
     
    4848  }
    4949
    50   public abstract class CompiledSingleObjectiveProblemDefinition<TEncoding, TSolution> : CompiledProblemDefinition<TEncoding, TSolution>, ISingleObjectiveProblemDefinition<TEncoding, TSolution>
    51     where TEncoding : class, IEncoding<TSolution>
    52     where TSolution : class, ISolution {
     50  public abstract class CompiledSingleObjectiveProblemDefinition<TEncoding, TEncodedSolution> : CompiledProblemDefinition<TEncoding, TEncodedSolution>, ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>
     51    where TEncoding : class, IEncoding<TEncodedSolution>
     52    where TEncodedSolution : class, IEncodedSolution {
    5353
    5454    protected CompiledSingleObjectiveProblemDefinition() : base() { }
     
    5757      : base(encoding) { }
    5858
    59     #region ISingleObjectiveProblemDefinition<TEncoding,TSolution> Members
     59    #region ISingleObjectiveProblemDefinition<TEncoding,TEncodedSolution> Members
    6060    public abstract bool Maximization { get; }
    61     public abstract double Evaluate(TSolution individual, IRandom random);
    62     public abstract void Analyze(TSolution[] individuals, double[] qualities, ResultCollection results, IRandom random);
    63     public abstract IEnumerable<TSolution> GetNeighbors(TSolution individual, IRandom random);
     61    public abstract double Evaluate(TEncodedSolution individual, IRandom random);
     62    public abstract void Analyze(TEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random);
     63    public abstract IEnumerable<TEncodedSolution> GetNeighbors(TEncodedSolution individual, IRandom random);
    6464
    6565    public bool IsBetter(double quality, double bestQuality) {
     
    6969  }
    7070
    71   public abstract class CompiledMultiObjectiveProblemDefinition<TEncoding, TSolution> : CompiledProblemDefinition<TEncoding, TSolution>, IMultiObjectiveProblemDefinition<TEncoding, TSolution>
    72     where TEncoding : class, IEncoding<TSolution>
    73     where TSolution : class, ISolution {
     71  public abstract class CompiledMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution> : CompiledProblemDefinition<TEncoding, TEncodedSolution>, IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>
     72    where TEncoding : class, IEncoding<TEncodedSolution>
     73    where TEncodedSolution : class, IEncodedSolution {
    7474
    7575    protected CompiledMultiObjectiveProblemDefinition() : base() { }
     
    7878      : base(encoding) { }
    7979
    80     #region ISingleObjectiveProblemDefinition<TEncoding,TSolution> Members
     80    #region ISingleObjectiveProblemDefinition<TEncoding,TEncodedSolution> Members
    8181    public abstract bool[] Maximization { get; }
    82     public abstract double[] Evaluate(TSolution individual, IRandom random);
    83     public abstract void Analyze(TSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random);
    84     public abstract IEnumerable<TSolution> GetNeighbors(TSolution individual, IRandom random);
     82    public abstract double[] Evaluate(TEncodedSolution individual, IRandom random);
     83    public abstract void Analyze(TEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random);
     84    public abstract IEnumerable<TEncodedSolution> GetNeighbors(TEncodedSolution individual, IRandom random);
    8585    #endregion
    8686  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProblemDefinitionScript.cs

    r16723 r16751  
    2020#endregion
    2121
     22using HEAL.Attic;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.Optimization;
    25 using HEAL.Attic;
    2626
    2727namespace HeuristicLab.Problems.Programmable {
    2828  [Item("Multi-objective Problem Definition Script", "Script that defines the parameter vector and evaluates the solution for a programmable problem.")]
    2929  [StorableType("17741D64-CF9D-4CCF-9892-0590C325D4E6")]
    30   public sealed class MultiObjectiveProblemDefinitionScript<TEncoding, TSolution> : ProblemDefinitionScript<TEncoding, TSolution>, IMultiObjectiveProblemDefinition<TEncoding, TSolution>, IStorableContent
    31     where TEncoding : class, IEncoding<TSolution>
    32     where TSolution : class, ISolution {
     30  public sealed class MultiObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution> : ProblemDefinitionScript<TEncoding, TEncodedSolution>, IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>, IStorableContent
     31    where TEncoding : class, IEncoding<TEncodedSolution>
     32    where TEncodedSolution : class, IEncodedSolution {
    3333    public string Filename { get; set; }
    3434
    35     private new IMultiObjectiveProblemDefinition<TEncoding, TSolution> CompiledProblemDefinition {
    36       get { return (IMultiObjectiveProblemDefinition<TEncoding, TSolution>)base.CompiledProblemDefinition; }
     35    private new IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution> CompiledProblemDefinition {
     36      get { return (IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>)base.CompiledProblemDefinition; }
    3737    }
    3838
    3939    [StorableConstructor]
    4040    private MultiObjectiveProblemDefinitionScript(StorableConstructorFlag _) : base(_) { }
    41     private MultiObjectiveProblemDefinitionScript(MultiObjectiveProblemDefinitionScript<TEncoding, TSolution> original, Cloner cloner) : base(original, cloner) { }
     41    private MultiObjectiveProblemDefinitionScript(MultiObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution> original, Cloner cloner) : base(original, cloner) { }
    4242    public MultiObjectiveProblemDefinitionScript(string codeTemplate) : base(codeTemplate) { }
    4343    public MultiObjectiveProblemDefinitionScript() : base() { }
    4444
    4545    public override IDeepCloneable Clone(Cloner cloner) {
    46       return new MultiObjectiveProblemDefinitionScript<TEncoding, TSolution>(this, cloner);
     46      return new MultiObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution>(this, cloner);
    4747    }
    4848
    49     bool[] IMultiObjectiveProblemDefinition<TEncoding, TSolution>.Maximization {
     49    bool[] IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Maximization {
    5050      get { return CompiledProblemDefinition.Maximization; }
    5151    }
    5252
    53     double[] IMultiObjectiveProblemDefinition<TEncoding, TSolution>.Evaluate(TSolution individual, IRandom random) {
     53    double[] IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Evaluate(TEncodedSolution individual, IRandom random) {
    5454      return CompiledProblemDefinition.Evaluate(individual, random);
    5555    }
    5656
    57     void IMultiObjectiveProblemDefinition<TEncoding, TSolution>.Analyze(TSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
     57    void IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Analyze(TEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
    5858      CompiledProblemDefinition.Analyze(individuals, qualities, results, random);
    5959    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProgrammableProblem.cs

    r16725 r16751  
    3434  [Creatable(CreatableAttribute.Categories.Problems, Priority = 120)]
    3535  [StorableType("1AA24077-4E1E-4FAE-8EC8-B6008DFD30B9")]
    36   public class MultiObjectiveProgrammableProblem<TEncoding, TSolution> : MultiObjectiveProblem<TEncoding, TSolution>, IProgrammableItem, IProgrammableProblem
    37     where TEncoding : class, IEncoding<TSolution>
    38     where TSolution : class, ISolution {
     36  public class MultiObjectiveProgrammableProblem<TEncoding, TEncodedSolution> : MultiObjectiveProblem<TEncoding, TEncodedSolution>, IProgrammableItem, IProgrammableProblem
     37    where TEncoding : class, IEncoding<TEncodedSolution>
     38    where TEncodedSolution : class, IEncodedSolution {
    3939    protected static readonly string ENCODING_NAMESPACE = "ENCODING_NAMESPACE";
    4040    protected static readonly string ENCODING_CLASS = "ENCODING_CLASS";
     
    4545    }
    4646
    47     private FixedValueParameter<MultiObjectiveProblemDefinitionScript<TEncoding, TSolution>> MultiObjectiveProblemScriptParameter {
    48       get { return (FixedValueParameter<MultiObjectiveProblemDefinitionScript<TEncoding, TSolution>>)Parameters["ProblemScript"]; }
     47    private FixedValueParameter<MultiObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution>> MultiObjectiveProblemScriptParameter {
     48      get { return (FixedValueParameter<MultiObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution>>)Parameters["ProblemScript"]; }
    4949    }
    5050
     
    5252      get { return ProblemScript; }
    5353    }
    54     public MultiObjectiveProblemDefinitionScript<TEncoding, TSolution> ProblemScript {
     54    public MultiObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution> ProblemScript {
    5555      get { return MultiObjectiveProblemScriptParameter.Value; }
    5656    }
    5757
    58     public IMultiObjectiveProblemDefinition<TEncoding, TSolution> ProblemDefinition {
     58    public IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution> ProblemDefinition {
    5959      get { return MultiObjectiveProblemScriptParameter.Value; }
    6060    }
     
    6262    [StorableConstructor]
    6363    protected MultiObjectiveProgrammableProblem(StorableConstructorFlag _) : base(_) { }
    64     protected MultiObjectiveProgrammableProblem(MultiObjectiveProgrammableProblem<TEncoding, TSolution> original, Cloner cloner)
     64    protected MultiObjectiveProgrammableProblem(MultiObjectiveProgrammableProblem<TEncoding, TEncodedSolution> original, Cloner cloner)
    6565      : base(original, cloner) {
    6666      RegisterEvents();
     
    6868
    6969    public override IDeepCloneable Clone(Cloner cloner) {
    70       return new MultiObjectiveProgrammableProblem<TEncoding, TSolution>(this, cloner);
     70      return new MultiObjectiveProgrammableProblem<TEncoding, TEncodedSolution>(this, cloner);
    7171    }
    7272
    7373    public MultiObjectiveProgrammableProblem()
    7474      : base() {
    75       Parameters.Add(new FixedValueParameter<MultiObjectiveProblemDefinitionScript<TEncoding, TSolution>>("ProblemScript", "Defines the problem.",
    76         new MultiObjectiveProblemDefinitionScript<TEncoding, TSolution>() { Name = Name }));
     75      Parameters.Add(new FixedValueParameter<MultiObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution>>("ProblemScript", "Defines the problem.",
     76        new MultiObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution>() { Name = Name }));
    7777      ProblemScript.Encoding = (TEncoding)Encoding.Clone();
    7878
     
    8080      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, typeof(TEncoding).Namespace);
    8181      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, typeof(TEncoding).Name);
    82       codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, typeof(TSolution).Name);
     82      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, typeof(TEncodedSolution).Name);
    8383      ProblemScript.Code = codeTemplate;
    8484
     
    116116    }
    117117
    118     public override double[] Evaluate(TSolution individual, IRandom random) {
     118    public override double[] Evaluate(TEncodedSolution individual, IRandom random) {
    119119      return ProblemDefinition.Evaluate(individual, random);
    120120    }
    121121
    122     public override void Analyze(TSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
     122    public override void Analyze(TEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
    123123      ProblemDefinition.Analyze(individuals, qualities, results, random);
    124124    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/ProblemDefinitionScript.cs

    r16725 r16751  
    5656  [Item("ProblemDefinitionScript", "Script that defines the parameter vector and evaluates the solution for a programmable problem.")]
    5757  [StorableType("0B3AF22C-4744-4860-BBCF-A92046000847")]
    58   public abstract class ProblemDefinitionScript<TEncoding, TSolution> : ProblemDefinitionScript, IProblemDefinition<TEncoding, TSolution>
    59     where TEncoding : class, IEncoding<TSolution>
    60     where TSolution : class, ISolution {
     58  public abstract class ProblemDefinitionScript<TEncoding, TEncodedSolution> : ProblemDefinitionScript, IProblemDefinition<TEncoding, TEncodedSolution>
     59    where TEncoding : class, IEncoding<TEncodedSolution>
     60    where TEncodedSolution : class, IEncodedSolution {
    6161
    6262    [Storable]
     
    7070    }
    7171
    72     TEncoding IProblemDefinition<TEncoding, TSolution>.Encoding {
     72    TEncoding IProblemDefinition<TEncoding, TEncodedSolution>.Encoding {
    7373      get { return Encoding; }
    7474    }
     
    8080    [StorableConstructor]
    8181    protected ProblemDefinitionScript(StorableConstructorFlag _) : base(_) { }
    82     protected ProblemDefinitionScript(ProblemDefinitionScript<TEncoding, TSolution> original, Cloner cloner)
     82    protected ProblemDefinitionScript(ProblemDefinitionScript<TEncoding, TEncodedSolution> original, Cloner cloner)
    8383      : base(original, cloner) {
    8484      encoding = cloner.Clone(original.encoding);
     
    9393
    9494    private readonly object compileLock = new object();
    95     private volatile CompiledProblemDefinition<TEncoding, TSolution> compiledProblemDefinition;
    96     protected CompiledProblemDefinition<TEncoding, TSolution> CompiledProblemDefinition {
     95    private volatile CompiledProblemDefinition<TEncoding, TEncodedSolution> compiledProblemDefinition;
     96    protected CompiledProblemDefinition<TEncoding, TEncodedSolution> CompiledProblemDefinition {
    9797      get {
    9898        // double checked locking pattern
     
    119119      var assembly = base.Compile();
    120120      var types = assembly.GetTypes();
    121       if (!types.Any(x => typeof(CompiledProblemDefinition<TEncoding, TSolution>).IsAssignableFrom(x)))
     121      if (!types.Any(x => typeof(CompiledProblemDefinition<TEncoding, TEncodedSolution>).IsAssignableFrom(x)))
    122122        throw new ProblemDefinitionScriptException("The compiled code doesn't contain a problem definition." + Environment.NewLine + "The problem definition must be a subclass of CompiledProblemDefinition.");
    123       if (types.Count(x => typeof(CompiledProblemDefinition<TEncoding, TSolution>).IsAssignableFrom(x)) > 1)
     123      if (types.Count(x => typeof(CompiledProblemDefinition<TEncoding, TEncodedSolution>).IsAssignableFrom(x)) > 1)
    124124        throw new ProblemDefinitionScriptException("The compiled code contains multiple problem definitions." + Environment.NewLine + "Only one subclass of CompiledProblemDefinition is allowed.");
    125125
    126       CompiledProblemDefinition<TEncoding, TSolution> inst;
     126      CompiledProblemDefinition<TEncoding, TEncodedSolution> inst;
    127127      try {
    128         inst = (CompiledProblemDefinition<TEncoding, TSolution>)Activator.CreateInstance(types.Single(x => typeof(CompiledProblemDefinition<TEncoding, TSolution>).IsAssignableFrom(x)));
     128        inst = (CompiledProblemDefinition<TEncoding, TEncodedSolution>)Activator.CreateInstance(types.Single(x => typeof(CompiledProblemDefinition<TEncoding, TEncodedSolution>).IsAssignableFrom(x)));
    129129      } catch (Exception e) {
    130130        compiledProblemDefinition = null;
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProblemDefinitionScript.cs

    r16723 r16751  
    2121
    2222using System.Collections.Generic;
     23using HEAL.Attic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Optimization;
    26 using HEAL.Attic;
    2727
    2828namespace HeuristicLab.Problems.Programmable {
    2929  [Item("Single-objective Problem Definition Script", "Script that defines the parameter vector and evaluates the solution for a programmable problem.")]
    3030  [StorableType("D0B2A649-EDDE-4A6E-A3B5-F40F5FD1B2C0")]
    31   public sealed class SingleObjectiveProblemDefinitionScript<TEncoding, TSolution> : ProblemDefinitionScript<TEncoding, TSolution>, ISingleObjectiveProblemDefinition<TEncoding, TSolution>, IStorableContent
    32     where TEncoding : class, IEncoding<TSolution>
    33     where TSolution : class, ISolution {
     31  public sealed class SingleObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution> : ProblemDefinitionScript<TEncoding, TEncodedSolution>, ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>, IStorableContent
     32    where TEncoding : class, IEncoding<TEncodedSolution>
     33    where TEncodedSolution : class, IEncodedSolution {
    3434    public string Filename { get; set; }
    3535
    36     private new ISingleObjectiveProblemDefinition<TEncoding, TSolution> CompiledProblemDefinition {
    37       get { return (ISingleObjectiveProblemDefinition<TEncoding, TSolution>)base.CompiledProblemDefinition; }
     36    private new ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution> CompiledProblemDefinition {
     37      get { return (ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>)base.CompiledProblemDefinition; }
    3838    }
    3939
    4040    [StorableConstructor]
    4141    private SingleObjectiveProblemDefinitionScript(StorableConstructorFlag _) : base(_) { }
    42     private SingleObjectiveProblemDefinitionScript(SingleObjectiveProblemDefinitionScript<TEncoding, TSolution> original, Cloner cloner) : base(original, cloner) { }
     42    private SingleObjectiveProblemDefinitionScript(SingleObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution> original, Cloner cloner) : base(original, cloner) { }
    4343    public SingleObjectiveProblemDefinitionScript(string codeTemplate) : base(codeTemplate) { }
    4444    public SingleObjectiveProblemDefinitionScript() { }
    4545
    4646    public override IDeepCloneable Clone(Cloner cloner) {
    47       return new SingleObjectiveProblemDefinitionScript<TEncoding, TSolution>(this, cloner);
     47      return new SingleObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution>(this, cloner);
    4848    }
    4949
    50     bool ISingleObjectiveProblemDefinition<TEncoding, TSolution>.Maximization {
     50    bool ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Maximization {
    5151      get { return CompiledProblemDefinition.Maximization; }
    5252    }
    5353
    54     double ISingleObjectiveProblemDefinition<TEncoding, TSolution>.Evaluate(TSolution individual, IRandom random) {
     54    double ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Evaluate(TEncodedSolution individual, IRandom random) {
    5555      return CompiledProblemDefinition.Evaluate(individual, random);
    5656    }
    5757
    58     void ISingleObjectiveProblemDefinition<TEncoding, TSolution>.Analyze(TSolution[] individuals, double[] qualities, ResultCollection results, IRandom random) {
     58    void ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Analyze(TEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random) {
    5959      CompiledProblemDefinition.Analyze(individuals, qualities, results, random);
    6060    }
    61     IEnumerable<TSolution> ISingleObjectiveProblemDefinition<TEncoding, TSolution>.GetNeighbors(TSolution individual, IRandom random) {
     61    IEnumerable<TEncodedSolution> ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.GetNeighbors(TEncodedSolution individual, IRandom random) {
    6262      return CompiledProblemDefinition.GetNeighbors(individual, random);
    6363    }
    6464
    65     bool ISingleObjectiveProblemDefinition<TEncoding, TSolution>.IsBetter(double quality, double bestQuality) {
     65    bool ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.IsBetter(double quality, double bestQuality) {
    6666      return CompiledProblemDefinition.IsBetter(quality, bestQuality);
    6767    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblem.cs

    r16725 r16751  
    3636  [Creatable(CreatableAttribute.Categories.Problems, Priority = 110)]
    3737  [StorableType("44944E6B-E95E-4805-8F0A-0C0F7D761DB9")]
    38   public class SingleObjectiveProgrammableProblem<TEncoding, TSolution> : SingleObjectiveProblem<TEncoding, TSolution>, IProgrammableItem, IProgrammableProblem
    39     where TEncoding : class, IEncoding<TSolution>
    40     where TSolution : class, ISolution {
     38  public class SingleObjectiveProgrammableProblem<TEncoding, TEncodedSolution> : SingleObjectiveProblem<TEncoding, TEncodedSolution>, IProgrammableItem, IProgrammableProblem
     39    where TEncoding : class, IEncoding<TEncodedSolution>
     40    where TEncodedSolution : class, IEncodedSolution {
    4141    protected static readonly string ENCODING_NAMESPACE = "ENCODING_NAMESPACE";
    4242    protected static readonly string ENCODING_CLASS = "ENCODING_CLASS";
     
    4747    }
    4848
    49     private FixedValueParameter<SingleObjectiveProblemDefinitionScript<TEncoding, TSolution>> SingleObjectiveProblemScriptParameter {
    50       get { return (FixedValueParameter<SingleObjectiveProblemDefinitionScript<TEncoding, TSolution>>)Parameters["ProblemScript"]; }
     49    private FixedValueParameter<SingleObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution>> SingleObjectiveProblemScriptParameter {
     50      get { return (FixedValueParameter<SingleObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution>>)Parameters["ProblemScript"]; }
    5151    }
    5252
     
    5454      get { return ProblemScript; }
    5555    }
    56     public SingleObjectiveProblemDefinitionScript<TEncoding, TSolution> ProblemScript {
     56    public SingleObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution> ProblemScript {
    5757      get { return SingleObjectiveProblemScriptParameter.Value; }
    5858    }
    5959
    60     public ISingleObjectiveProblemDefinition<TEncoding, TSolution> ProblemDefinition {
     60    public ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution> ProblemDefinition {
    6161      get { return SingleObjectiveProblemScriptParameter.Value; }
    6262    }
    6363
    64     protected SingleObjectiveProgrammableProblem(SingleObjectiveProgrammableProblem<TEncoding, TSolution> original, Cloner cloner)
     64    protected SingleObjectiveProgrammableProblem(SingleObjectiveProgrammableProblem<TEncoding, TEncodedSolution> original, Cloner cloner)
    6565      : base(original, cloner) {
    6666      RegisterEvents();
     
    6868
    6969    public override IDeepCloneable Clone(Cloner cloner) {
    70       return new SingleObjectiveProgrammableProblem<TEncoding, TSolution>(this, cloner);
     70      return new SingleObjectiveProgrammableProblem<TEncoding, TEncodedSolution>(this, cloner);
    7171    }
    7272
     
    7575    public SingleObjectiveProgrammableProblem()
    7676      : base() {
    77       Parameters.Add(new FixedValueParameter<SingleObjectiveProblemDefinitionScript<TEncoding, TSolution>>("ProblemScript", "Defines the problem.", new SingleObjectiveProblemDefinitionScript<TEncoding, TSolution>() { Name = Name }));
     77      Parameters.Add(new FixedValueParameter<SingleObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution>>("ProblemScript", "Defines the problem.", new SingleObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution>() { Name = Name }));
    7878      ProblemScript.Encoding = (TEncoding)Encoding.Clone();
    7979
     
    8181      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, typeof(TEncoding).Namespace);
    8282      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, typeof(TEncoding).Name);
    83       codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, typeof(TSolution).Name);
     83      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, typeof(TEncodedSolution).Name);
    8484      ProblemScript.Code = codeTemplate;
    8585
     
    118118    }
    119119
    120     public override double Evaluate(TSolution individual, IRandom random) {
     120    public override double Evaluate(TEncodedSolution individual, IRandom random) {
    121121      return ProblemDefinition.Evaluate(individual, random);
    122122    }
    123123
    124     public override void Analyze(TSolution[] individuals, double[] qualities, ResultCollection results, IRandom random) {
     124    public override void Analyze(TEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random) {
    125125      ProblemDefinition.Analyze(individuals, qualities, results, random);
    126126    }
    127     public override IEnumerable<TSolution> GetNeighbors(TSolution individual, IRandom random) {
     127    public override IEnumerable<TEncodedSolution> GetNeighbors(TEncodedSolution individual, IRandom random) {
    128128      return ProblemDefinition.GetNeighbors(individual, random);
    129129    }
Note: See TracChangeset for help on using the changeset viewer.