Changeset 17699 for branches/2521_ProblemRefactoring
- Timestamp:
- 07/25/20 01:23:08 (4 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 48 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorEncoding.cs
r17614 r17699 32 32 [Item("BinaryVectorEncoding", "Describes a binary vector encoding.")] 33 33 [StorableType("889C5E1A-3FBF-4AB3-AB2E-199A781503B5")] 34 public sealed class BinaryVectorEncoding : VectorEncoding <BinaryVector>{34 public sealed class BinaryVectorEncoding : VectorEncoding { 35 35 36 36 [StorableConstructor] -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorEncoding.cs
r17620 r17699 34 34 [Item("IntegerVectorEncoding", "Describes an integer vector encoding.")] 35 35 [StorableType("15D6E55E-C39F-4784-8350-14A0FD47CF0E")] 36 public sealed class IntegerVectorEncoding : VectorEncoding <IntegerVector>{36 public sealed class IntegerVectorEncoding : VectorEncoding { 37 37 [Storable] public IValueParameter<IntMatrix> BoundsParameter { get; private set; } 38 38 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageEncoding.cs
r17614 r17699 32 32 [Item("Linear Linkage Encoding", "Describes a linear linkage (LLE) encoding.")] 33 33 [StorableType("7AE11F39-E6BD-4FC7-8112-0A5EDCBFBDB6")] 34 public sealed class LinearLinkageEncoding : VectorEncoding <LinearLinkage>{34 public sealed class LinearLinkageEncoding : VectorEncoding { 35 35 36 36 [StorableConstructor] -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationEncoding.cs
r17614 r17699 34 34 [Item("PermutationEncoding", "Describes a permutation encoding.")] 35 35 [StorableType("E30E7507-44BA-4021-8F56-C3FC5569A6FE")] 36 public sealed class PermutationEncoding : VectorEncoding <Permutation>{36 public sealed class PermutationEncoding : VectorEncoding { 37 37 #region encoding parameters 38 38 [Storable] public IValueParameter<EnumValue<PermutationTypes>> PermutationTypeParameter { get; private set; } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorEncoding.cs
r17614 r17699 34 34 [Item("RealVectorEncoding", "Describes a real vector encoding.")] 35 35 [StorableType("155FFE02-931F-457D-AC95-A0389B0BFECD")] 36 public sealed class RealVectorEncoding : VectorEncoding <RealVector>{36 public sealed class RealVectorEncoding : VectorEncoding { 37 37 [Storable] public IValueParameter<DoubleMatrix> BoundsParameter { get; private set; } 38 38 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleEncoding.cs
r17680 r17699 29 29 namespace HeuristicLab.Encodings.ScheduleEncoding { 30 30 [StorableType("09b9d24c-2576-495a-b06c-338d095cba0d")] 31 public interface IScheduleEncoding : IEncoding <IScheduleSolution>{31 public interface IScheduleEncoding : IEncoding { 32 32 IValueParameter<ItemList<Job>> JobDataParameter { get; } 33 33 IFixedValueParameter<IntValue> JobsParameter { get; } … … 41 41 Schedule Decode(IScheduleSolution schedule, ItemList<Job> jobData); 42 42 } 43 44 public interface IScheduleEncoding<TSchedule> : IEncoding<TSchedule>45 where TSchedule : class, IScheduleSolution {46 47 }48 43 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding.cs
r17680 r17699 32 32 namespace HeuristicLab.Encodings.ScheduleEncoding { 33 33 [StorableType("D2FB1AF9-EF13-4ED2-B3E9-D5BE4E5772EA")] 34 public abstract class ScheduleEncoding<TSchedule> : Encoding <TSchedule>, IScheduleEncoding34 public abstract class ScheduleEncoding<TSchedule> : Encoding, IScheduleEncoding 35 35 where TSchedule : class, IScheduleSolution { 36 36 [Storable] public IValueParameter<ItemList<Job>> JobDataParameter { get; private set; } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeEncoding.cs
r17614 r17699 36 36 [Item("SymbolicExpressionTreeEncoding", "Describes a symbolic expression tree encoding.")] 37 37 [StorableType("3FDE530B-771F-4280-921F-20DA50A139BA")] 38 public sealed class SymbolicExpressionTreeEncoding : Encoding <ISymbolicExpressionTree>{38 public sealed class SymbolicExpressionTreeEncoding : Encoding { 39 39 #region Encoding Parameters 40 40 [Storable] -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/CombinedEncoding.cs
r17614 r17699 31 31 [Item("CombinedEncoding", "Describes a combined encoding consisting of multiple simpler encodings.")] 32 32 [StorableType("359E2173-4D0C-40E5-A2F3-E42E59840345")] 33 public sealed class CombinedEncoding : Encoding <CombinedSolution>{33 public sealed class CombinedEncoding : Encoding { 34 34 35 35 private ItemCollection<IEncoding> encodings; -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Encoding.cs
r17614 r17699 31 31 [Item("Encoding", "Base class for describing different encodings.")] 32 32 [StorableType("395B1372-FA54-4649-9EBE-5402A0AA9494")] 33 public abstract class Encoding<TEncodedSolution> : ParameterizedNamedItem, IEncoding<TEncodedSolution> 34 where TEncodedSolution : class, IEncodedSolution { 33 public abstract class Encoding : ParameterizedNamedItem, IEncoding { 35 34 public sealed override bool CanChangeName { 36 35 get { return false; } … … 48 47 get { return encodingOperators; } 49 48 set { 50 if (!value.OfType<ISolutionCreator<TEncodedSolution>>().Any()) 51 throw new ArgumentException("The provided operators contain no suitable solution creator"); 49 // SolutionCreator is now a parameter of the algorithm, we don't care! 50 //if (!value.OfType<ISolutionCreator<TEncodedSolution>>().Any()) 51 // throw new ArgumentException("The provided operators contain no suitable solution creator"); 52 52 encodingOperators.Clear(); 53 53 foreach (var op in value) encodingOperators.Add(op); … … 62 62 private void AfterDeserialization() { } 63 63 64 protected Encoding(Encoding <TEncodedSolution>original, Cloner cloner)64 protected Encoding(Encoding original, Cloner cloner) 65 65 : base(original, cloner) { 66 66 encodingOperators = cloner.Clone(original.encodingOperators); -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IEncoding.cs
r17614 r17699 35 35 event EventHandler OperatorsChanged; 36 36 } 37 38 [StorableType("DB23907F-BE6E-44E4-9596-3D3BF1532631")]39 public interface IEncoding<TEncodedSolution> : IEncoding40 where TEncodedSolution : class, IEncodedSolution {41 //new ISolutionCreator<TEncodedSolution> SolutionCreator { get; }42 }43 37 } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IEncodingOperator.cs
r17226 r17699 25 25 namespace HeuristicLab.Optimization { 26 26 [StorableType("20faaf8b-dd4f-4f0e-a772-4c4dec7fcccb")] 27 public interface IEncodingOperator <TEncodedSolution> : IOperator where TEncodedSolution : class, IEncodedSolution{28 ILookupParameter<IEncoding <TEncodedSolution>> EncodingParameter { get; }27 public interface IEncodingOperator : IOperator { 28 ILookupParameter<IEncoding> EncodingParameter { get; } 29 29 } 30 30 } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IMultiObjectiveProblem.cs
r17320 r17699 31 31 [StorableType("806fb361-1469-4903-9f54-f8678b0717b9")] 32 32 public interface IMultiObjectiveProblem<TEncoding, TEncodedSolution> : IMultiObjectiveProblem, IProblem<TEncoding, TEncodedSolution> 33 where TEncoding : class, IEncoding <TEncodedSolution>33 where TEncoding : class, IEncoding 34 34 where TEncodedSolution : class, IEncodedSolution { } 35 35 -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IMultiObjectiveProblemDefinition.cs
r17320 r17699 36 36 [StorableType("39eacdb5-80a0-425d-902a-00eb3e1d6610")] 37 37 public interface IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution> : IMultiObjectiveProblemDefinition, IProblemDefinition<TEncoding, TEncodedSolution> 38 where TEncoding : class, IEncoding <TEncodedSolution>38 where TEncoding : class, IEncoding 39 39 where TEncodedSolution : class, IEncodedSolution { 40 40 double[] Evaluate(TEncodedSolution solution, IRandom random); -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IProblem.cs
r17696 r17699 52 52 [StorableType("1b4af8b9-bdf5-4ffd-86e6-35b481bfbf45")] 53 53 public interface IProblem<TEncoding, TEncodedSolution> : IHeuristicOptimizationProblem 54 where TEncoding : class, IEncoding <TEncodedSolution>54 where TEncoding : class, IEncoding 55 55 where TEncodedSolution : class, IEncodedSolution { 56 56 } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IProblemDefinition.cs
r17612 r17699 31 31 [StorableType("747a3cea-b9ba-4322-a5c2-050cd7e16e2a")] 32 32 public interface IProblemDefinition<TEncoding, TEncodedSolution> : IProblemDefinition 33 where TEncoding : class, IEncoding <TEncodedSolution>33 where TEncoding : class, IEncoding 34 34 where TEncodedSolution : class, IEncodedSolution { 35 35 TEncoding Encoding { get; } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveProblem.cs
r17320 r17699 31 31 [StorableType("9cc9422f-0bb5-41e8-9d9e-6e0b66a66449")] 32 32 public interface ISingleObjectiveProblem<TEncoding, TEncodedSolution> : ISingleObjectiveProblem, IProblem<TEncoding, TEncodedSolution> 33 where TEncoding : class, IEncoding <TEncodedSolution>33 where TEncoding : class, IEncoding 34 34 where TEncodedSolution : class, IEncodedSolution { } 35 35 //TODO derive ISingleObjectiveProblem from ISingleObjectiveProblemDefinition? -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveProblemDefinition.cs
r17513 r17699 34 34 [StorableType("7ec7bf7e-aaa7-4681-828b-3401cf67e2b3")] 35 35 public interface ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution> : ISingleObjectiveProblemDefinition, IProblemDefinition<TEncoding, TEncodedSolution> 36 where TEncoding : class, IEncoding <TEncodedSolution>36 where TEncoding : class, IEncoding 37 37 where TEncodedSolution : class, IEncodedSolution { 38 38 -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/IMultiObjectiveAnalysisOperator.cs
r17226 r17699 26 26 namespace HeuristicLab.Optimization { 27 27 [StorableType("c9325602-3262-48a4-8985-03657fb0b34f")] 28 internal interface IMultiObjectiveAnalysisOperator<TEncodedSolution> : IEncodingOperator <TEncodedSolution>, IAnalyzer, IMultiObjectiveOperator28 internal interface IMultiObjectiveAnalysisOperator<TEncodedSolution> : IEncodingOperator, IAnalyzer, IMultiObjectiveOperator 29 29 where TEncodedSolution : class, IEncodedSolution { 30 30 Action<TEncodedSolution[], double[][], ResultCollection, IRandom> AnalyzeAction { get; set; } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/IMultiObjectiveEvaluationOperator.cs
r17226 r17699 26 26 namespace HeuristicLab.Optimization { 27 27 [StorableType("89da568c-70a2-48fb-8e6b-ea078bb6fc3f")] 28 internal interface IMultiObjectiveEvaluationOperator<TEncodedSolution> : IMultiObjectiveEvaluator, IEncodingOperator <TEncodedSolution>28 internal interface IMultiObjectiveEvaluationOperator<TEncodedSolution> : IMultiObjectiveEvaluator, IEncodingOperator 29 29 where TEncodedSolution : class, IEncodedSolution { 30 30 Func<TEncodedSolution, IRandom, double[]> EvaluateFunc { get; set; } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/INeighborBasedOperator.cs
r17363 r17699 27 27 namespace HeuristicLab.Optimization { 28 28 [StorableType("fda56e0b-9392-4711-9af1-55211bfa24ac")] 29 internal interface INeighborBasedOperator<TEncodedSolution> : IEncodingOperator <TEncodedSolution>29 internal interface INeighborBasedOperator<TEncodedSolution> : IEncodingOperator 30 30 where TEncodedSolution : class, IEncodedSolution { 31 31 Func<ISingleObjectiveSolutionContext<TEncodedSolution>, IRandom, IEnumerable<ISingleObjectiveSolutionContext<TEncodedSolution>>> GetNeighbors { get; set; } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/ISingleObjectiveAnalysisOperator.cs
r17363 r17699 26 26 namespace HeuristicLab.Optimization { 27 27 [StorableType("9731981c-10c6-4850-9308-a4720ac07da7")] 28 internal interface ISingleObjectiveAnalysisOperator<TEncodedSolution> : IEncodingOperator <TEncodedSolution>, ISingleObjectiveOperator28 internal interface ISingleObjectiveAnalysisOperator<TEncodedSolution> : IEncodingOperator, ISingleObjectiveOperator 29 29 where TEncodedSolution : class, IEncodedSolution { 30 30 Action<ISingleObjectiveSolutionContext<TEncodedSolution>[], ResultCollection, IRandom> Analyze { get; set; } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/ISingleObjectiveEvaluationOperator.cs
r17366 r17699 27 27 namespace HeuristicLab.Optimization { 28 28 [StorableType("5a9cf334-4815-4f0e-a2f8-f3d4edfcc829")] 29 internal interface ISingleObjectiveEvaluationOperator<TEncodedSolution> : ISingleObjectiveEvaluator, IEncodingOperator <TEncodedSolution>29 internal interface ISingleObjectiveEvaluationOperator<TEncodedSolution> : ISingleObjectiveEvaluator, IEncodingOperator 30 30 where TEncodedSolution : class, IEncodedSolution { 31 31 Action<ISingleObjectiveSolutionContext<TEncodedSolution>, IRandom, CancellationToken> Evaluate { get; set; } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveProblem.cs
r17690 r17699 36 36 IMultiObjectiveProblem<TEncoding, TEncodedSolution>, 37 37 IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution> 38 where TEncoding : class, IEncoding <TEncodedSolution>38 where TEncoding : class, IEncoding 39 39 where TEncodedSolution : class, IEncodedSolution { 40 40 -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiEncodingOperator.cs
r17226 r17699 30 30 namespace HeuristicLab.Optimization { 31 31 [StorableType("43619638-9D00-4951-8138-8CCD0786E784")] 32 internal abstract class MultiEncodingOperator<T> : InstrumentedOperator, IEncodingOperator <CombinedSolution>, IMultiEncodingOperator where T : class, IOperator {32 internal abstract class MultiEncodingOperator<T> : InstrumentedOperator, IEncodingOperator, IMultiEncodingOperator where T : class, IOperator { 33 33 public ILookupParameter<CombinedSolution> SolutionParameter { 34 34 get { return (ILookupParameter<CombinedSolution>)Parameters["Solution"]; } 35 35 } 36 36 37 public ILookupParameter<IEncoding <CombinedSolution>> EncodingParameter {38 get { return (ILookupParameter<IEncoding <CombinedSolution>>)Parameters["Encoding"]; }37 public ILookupParameter<IEncoding> EncodingParameter { 38 get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; } 39 39 } 40 40 … … 47 47 : base() { 48 48 Parameters.Add(new LookupParameter<CombinedSolution>("Solution", "The solution that gets created.")); 49 Parameters.Add(new LookupParameter<IEncoding <CombinedSolution>>("Encoding", "The encoding."));49 Parameters.Add(new LookupParameter<IEncoding>("Encoding", "The encoding.")); 50 50 } 51 51 -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiObjectiveAnalyzer.cs
r17226 r17699 37 37 public bool EnabledByDefault { get { return true; } } 38 38 39 public ILookupParameter<IEncoding <TEncodedSolution>> EncodingParameter {40 get { return (ILookupParameter<IEncoding <TEncodedSolution>>)Parameters["Encoding"]; }39 public ILookupParameter<IEncoding> EncodingParameter { 40 get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; } 41 41 } 42 42 … … 60 60 public MultiObjectiveAnalyzer() { 61 61 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use.")); 62 Parameters.Add(new LookupParameter<IEncoding <TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));62 Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding.")); 63 63 Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>("Qualities", "The qualities of the parameter vector.")); 64 64 Parameters.Add(new LookupParameter<ResultCollection>("Results", "The results collection to write to.")); … … 78 78 scopes = scopes.Select(x => (IEnumerable<IScope>)x.SubScopes).Aggregate((a, b) => a.Concat(b)); 79 79 80 var individuals = scopes.Select(s => ScopeUtil.GetEncodedSolution(s, encoding)).ToArray();80 var individuals = scopes.Select(s => (TEncodedSolution)ScopeUtil.GetEncodedSolution(s, encoding)).ToArray(); 81 81 AnalyzeAction(individuals, QualitiesParameter.ActualValue.Select(x => x.ToArray()).ToArray(), results, random); 82 82 return base.Apply(); -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiObjectiveEvaluator.cs
r17226 r17699 38 38 } 39 39 40 public ILookupParameter<IEncoding <TEncodedSolution>> EncodingParameter {41 get { return (ILookupParameter<IEncoding <TEncodedSolution>>)Parameters["Encoding"]; }40 public ILookupParameter<IEncoding> EncodingParameter { 41 get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; } 42 42 } 43 43 … … 53 53 public MultiObjectiveEvaluator() { 54 54 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use.")); 55 Parameters.Add(new LookupParameter<IEncoding <TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));55 Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding.")); 56 56 Parameters.Add(new LookupParameter<DoubleArray>("Qualities", "The qualities of the parameter vector.")); 57 57 } … … 64 64 var random = RandomParameter.ActualValue; 65 65 var encoding = EncodingParameter.ActualValue; 66 var solution = ScopeUtil.GetEncodedSolution(ExecutionContext.Scope, encoding);66 var solution = (TEncodedSolution)ScopeUtil.GetEncodedSolution(ExecutionContext.Scope, encoding); 67 67 QualitiesParameter.ActualValue = new DoubleArray(EvaluateFunc(solution, random)); 68 68 return base.InstrumentedApply(); -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/ScopeUtil.cs
r17577 r17699 31 31 32 32 // TODO: Create SolutionContexts that derive from IScope to have a unified datastructure (e.g. #1614) 33 public static TEncodedSolution CopyEncodedSolutionToScope<TEncodedSolution>(IScope scope, IEncoding <TEncodedSolution>encoding, TEncodedSolution solution)33 public static TEncodedSolution CopyEncodedSolutionToScope<TEncodedSolution>(IScope scope, IEncoding encoding, TEncodedSolution solution) 34 34 where TEncodedSolution : class, IEncodedSolution { 35 35 return CopyEncodedSolutionToScope(scope, encoding.Name, solution); … … 44 44 } 45 45 46 public static TEncodedSolution GetEncodedSolution<TEncodedSolution>(IScope scope, IEncoding<TEncodedSolution> encoding) 47 where TEncodedSolution : class, IEncodedSolution { 46 public static IEncodedSolution GetEncodedSolution(IScope scope, IEncoding encoding) { 48 47 var name = encoding.Name; 49 48 if (!scope.Variables.ContainsKey(name)) throw new ArgumentException(string.Format(" {0} cannot be found in the provided scope.", name)); 50 var value = scope.Variables[name].Value as TEncodedSolution; 51 if (value == null) throw new InvalidOperationException(string.Format("Value of {0} is null or not of type {1}.", name, typeof(TEncodedSolution).GetPrettyName())); 52 return value; 53 } 54 55 public static IEncodedSolution GetEncodedSolution(IScope scope, IEncoding encoding) { 56 return GetEncodedSolution(scope, encoding.Name); 49 if (scope.Variables[name].Value is IEncodedSolution value) 50 return value; 51 throw new InvalidOperationException(string.Format("Value of {0} is null or not of type {1}.", name, typeof(IEncodedSolution).GetPrettyName())); 57 52 } 58 53 … … 65 60 } 66 61 67 public static ISingleObjectiveSolutionContext<TEncodedSolution> CreateSolutionContext<TEncodedSolution>(IScope scope, IEncoding <TEncodedSolution>encoding)62 public static ISingleObjectiveSolutionContext<TEncodedSolution> CreateSolutionContext<TEncodedSolution>(IScope scope, IEncoding encoding) 68 63 where TEncodedSolution : class, IEncodedSolution { 69 var solution = GetEncodedSolution(scope, encoding);64 var solution = (TEncodedSolution)GetEncodedSolution(scope, encoding); 70 65 var context = new SingleObjectiveSolutionContext<TEncodedSolution>(solution); 71 66 foreach (var variable in scope.Variables) { -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveAnalyzer.cs
r17577 r17699 37 37 public bool EnabledByDefault { get { return true; } } 38 38 39 public ILookupParameter<IEncoding <TEncodedSolution>> EncodingParameter {40 get { return (ILookupParameter<IEncoding <TEncodedSolution>>)Parameters["Encoding"]; }39 public ILookupParameter<IEncoding> EncodingParameter { 40 get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; } 41 41 } 42 42 … … 59 59 private SingleObjectiveAnalyzer(SingleObjectiveAnalyzer<TEncodedSolution> original, Cloner cloner) : base(original, cloner) { } 60 60 public SingleObjectiveAnalyzer() { 61 Parameters.Add(new LookupParameter<IEncoding <TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));61 Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding.")); 62 62 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The quality of the parameter vector.")); 63 63 Parameters.Add(new LookupParameter<ResultCollection>("Results", "The results collection to write to.")); … … 79 79 80 80 var solutionContexts = scopes.Select(scope => { 81 return ScopeUtil.CreateSolutionContext (scope, encoding);81 return ScopeUtil.CreateSolutionContext<TEncodedSolution>(scope, encoding); 82 82 }).ToArray(); 83 83 -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveEvaluator.cs
r17592 r17699 39 39 } 40 40 41 public ILookupParameter<IEncoding <TEncodedSolution>> EncodingParameter {42 get { return (ILookupParameter<IEncoding <TEncodedSolution>>)Parameters["Encoding"]; }41 public ILookupParameter<IEncoding> EncodingParameter { 42 get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; } 43 43 } 44 44 … … 54 54 public SingleObjectiveEvaluator() { 55 55 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use.")); 56 Parameters.Add(new LookupParameter<IEncoding <TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));56 Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding.")); 57 57 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the parameter vector.")); 58 58 } … … 63 63 var random = RandomParameter.ActualValue; 64 64 var encoding = EncodingParameter.ActualValue; 65 var solutionContext = ScopeUtil.CreateSolutionContext (ExecutionContext.Scope, encoding);65 var solutionContext = ScopeUtil.CreateSolutionContext<TEncodedSolution>(ExecutionContext.Scope, encoding); 66 66 67 67 Evaluate(solutionContext, random, CancellationToken.None); -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveImprover.cs
r17592 r17699 40 40 } 41 41 42 public ILookupParameter<IEncoding <TEncodedSolution>> EncodingParameter {43 get { return (ILookupParameter<IEncoding <TEncodedSolution>>)Parameters["Encoding"]; }42 public ILookupParameter<IEncoding> EncodingParameter { 43 get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; } 44 44 } 45 45 … … 72 72 public SingleObjectiveImprover() { 73 73 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use.")); 74 Parameters.Add(new LookupParameter<IEncoding <TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));74 Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding.")); 75 75 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the parameter vector.")); 76 76 Parameters.Add(new LookupParameter<BoolValue>("Maximization", "Whether the problem should be minimized or maximized.")); … … 90 90 var maxAttempts = ImprovementAttemptsParameter.ActualValue.Value; 91 91 var sampleSize = SampleSizeParameter.ActualValue.Value; 92 var solutionContext = ScopeUtil.CreateSolutionContext (ExecutionContext.Scope, encoding);92 var solutionContext = ScopeUtil.CreateSolutionContext<TEncodedSolution>(ExecutionContext.Scope, encoding); 93 93 94 94 double quality; -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveMoveEvaluator.cs
r17592 r17699 39 39 } 40 40 41 public ILookupParameter<IEncoding <TEncodedSolution>> EncodingParameter {42 get { return (ILookupParameter<IEncoding <TEncodedSolution>>)Parameters["Encoding"]; }41 public ILookupParameter<IEncoding> EncodingParameter { 42 get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; } 43 43 } 44 44 … … 58 58 public SingleObjectiveMoveEvaluator() { 59 59 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use.")); 60 Parameters.Add(new LookupParameter<IEncoding <TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));60 Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding.")); 61 61 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the parameter vector.")); 62 62 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The quality of the move.")); … … 70 70 var random = RandomParameter.ActualValue; 71 71 var encoding = EncodingParameter.ActualValue; 72 var solutionContext = ScopeUtil.CreateSolutionContext (ExecutionContext.Scope, encoding);72 var solutionContext = ScopeUtil.CreateSolutionContext<TEncodedSolution>(ExecutionContext.Scope, encoding); 73 73 74 74 if (!solutionContext.IsEvaluated) -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveMoveGenerator.cs
r17577 r17699 44 44 } 45 45 46 public ILookupParameter<IEncoding <TEncodedSolution>> EncodingParameter {47 get { return (ILookupParameter<IEncoding <TEncodedSolution>>)Parameters["Encoding"]; }46 public ILookupParameter<IEncoding> EncodingParameter { 47 get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; } 48 48 } 49 49 … … 57 57 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use.")); 58 58 Parameters.Add(new ValueLookupParameter<IntValue>("SampleSize", "The number of moves to sample.")); 59 Parameters.Add(new LookupParameter<IEncoding <TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));59 Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding.")); 60 60 } 61 61 … … 68 68 var sampleSize = SampleSizeParameter.ActualValue.Value; 69 69 var encoding = EncodingParameter.ActualValue; 70 var solutionContext = ScopeUtil.CreateSolutionContext (ExecutionContext.Scope, encoding);70 var solutionContext = ScopeUtil.CreateSolutionContext<TEncodedSolution>(ExecutionContext.Scope, encoding); 71 71 72 72 var nbhood = GetNeighbors(solutionContext, random).Take(sampleSize).ToList(); -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveMoveMaker.cs
r17226 r17699 31 31 [Item("Single-objective MoveMaker", "Applies a move.")] 32 32 [StorableType("C0ABF392-C825-4B98-8FB9-5749A9091FD6")] 33 internal sealed class SingleObjectiveMoveMaker<TEncodedSolution> : InstrumentedOperator, IMoveMaker, ISingleObjectiveMoveOperator 34 where TEncodedSolution : class, IEncodedSolution { 35 public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter { 36 get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; } 33 internal sealed class SingleObjectiveMoveMaker : InstrumentedOperator, IMoveMaker, ISingleObjectiveMoveOperator { 34 public ILookupParameter<IEncoding> EncodingParameter { 35 get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; } 37 36 } 38 37 … … 47 46 [StorableConstructor] 48 47 private SingleObjectiveMoveMaker(StorableConstructorFlag _) : base(_) { } 49 private SingleObjectiveMoveMaker(SingleObjectiveMoveMaker <TEncodedSolution>original, Cloner cloner) : base(original, cloner) { }48 private SingleObjectiveMoveMaker(SingleObjectiveMoveMaker original, Cloner cloner) : base(original, cloner) { } 50 49 public SingleObjectiveMoveMaker() { 51 Parameters.Add(new LookupParameter<IEncoding <TEncodedSolution>>("Encoding", "An item that holds the problem's encoding."));50 Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding.")); 52 51 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the parameter vector.")); 53 52 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The quality of the move.")); … … 55 54 56 55 public override IDeepCloneable Clone(Cloner cloner) { 57 return new SingleObjectiveMoveMaker <TEncodedSolution>(this, cloner);56 return new SingleObjectiveMoveMaker(this, cloner); 58 57 } 59 58 -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Problem.cs
r17695 r17699 33 33 public abstract class Problem<TEncoding, TEncodedSolution, TEvaluator> : EncodedProblem, 34 34 IHeuristicOptimizationProblem, IProblemDefinition<TEncoding, TEncodedSolution>, IStorableContent 35 where TEncoding : class, IEncoding <TEncodedSolution>35 where TEncoding : class, IEncoding 36 36 where TEncodedSolution : class, IEncodedSolution 37 37 where TEvaluator : class, IEvaluator { … … 136 136 oldEncoding = Encoding; 137 137 138 foreach (var op in Operators.OfType<IEncodingOperator <TEncodedSolution>>())138 foreach (var op in Operators.OfType<IEncodingOperator>()) 139 139 op.EncodingParameter.ActualName = EncodingParameter.Name; 140 140 -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveProblem.cs
r17697 r17699 36 36 ISingleObjectiveProblem<TEncoding, TEncodedSolution>, 37 37 ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution> 38 where TEncoding : class, IEncoding <TEncodedSolution>38 where TEncoding : class, IEncoding 39 39 where TEncodedSolution : class, IEncodedSolution { 40 40 … … 85 85 Operators.Add(new SingleObjectiveMoveEvaluator<TEncodedSolution>()); 86 86 Operators.Add(new SingleObjectiveMoveGenerator<TEncodedSolution>()); 87 Operators.Add(new SingleObjectiveMoveMaker <TEncodedSolution>());87 Operators.Add(new SingleObjectiveMoveMaker()); 88 88 89 89 Parameterize(); -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/VectorEncoding.cs
r17587 r17699 30 30 [Item("VectorEncoding", "Represents a vector-based encoding.")] 31 31 [StorableType("fed1e058-6e47-4e0f-af0a-ff646a9a778b")] 32 public abstract class VectorEncoding<TEncodedSolution> : Encoding<TEncodedSolution> 33 where TEncodedSolution : class, IEncodedSolution { 32 public abstract class VectorEncoding : Encoding { 34 33 [Storable] public IFixedValueParameter<IntValue> LengthParameter { get; private set; } 35 34 … … 49 48 RegisterEventHandlers(); 50 49 } 51 protected VectorEncoding(VectorEncoding <TEncodedSolution>original, Cloner cloner)50 protected VectorEncoding(VectorEncoding original, Cloner cloner) 52 51 : base(original, cloner) { 53 52 LengthParameter = cloner.Clone(original.LengthParameter); -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/MultiObjectiveExternalEvaluationProblem.cs
r17320 r17699 38 38 [StorableType("CCA50199-A6AB-4C84-B4FA-0262CAF416EC")] 39 39 public class MultiObjectiveExternalEvaluationProblem<TEncoding, TEncodedSolution> : MultiObjectiveProblem<TEncoding, TEncodedSolution>, IExternalEvaluationProblem 40 where TEncoding : class, IEncoding <TEncodedSolution>40 where TEncoding : class, IEncoding 41 41 where TEncodedSolution : class, IEncodedSolution { 42 42 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/SingleObjectiveExternalEvaluationProblem.cs
r17567 r17699 41 41 // Rename class to SingleObjectiveExternalEvaluationProblem 42 42 public class ExternalEvaluationProblem<TEncoding, TEncodedSolution> : SingleObjectiveProblem<TEncoding, TEncodedSolution>, IExternalEvaluationProblem 43 where TEncoding : class, IEncoding <TEncodedSolution>43 where TEncoding : class, IEncoding 44 44 where TEncodedSolution : class, IEncodedSolution { 45 45 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/CompiledProblemDefinition.cs
r17382 r17699 29 29 namespace HeuristicLab.Problems.Programmable { 30 30 public abstract class CompiledProblemDefinition<TEncoding, TEncodedSolution> : IProblemDefinition<TEncoding, TEncodedSolution> 31 where TEncoding : class, IEncoding <TEncodedSolution>31 where TEncoding : class, IEncoding 32 32 where TEncodedSolution : class, IEncodedSolution { 33 33 private TEncoding encoding; … … 51 51 52 52 public abstract class CompiledSingleObjectiveProblemDefinition<TEncoding, TEncodedSolution> : CompiledProblemDefinition<TEncoding, TEncodedSolution>, ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution> 53 where TEncoding : class, IEncoding <TEncodedSolution>53 where TEncoding : class, IEncoding 54 54 where TEncodedSolution : class, IEncodedSolution { 55 55 protected CompiledSingleObjectiveProblemDefinition() : base() { } … … 95 95 96 96 public abstract class CompiledMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution> : CompiledProblemDefinition<TEncoding, TEncodedSolution>, IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution> 97 where TEncoding : class, IEncoding <TEncodedSolution>97 where TEncoding : class, IEncoding 98 98 where TEncodedSolution : class, IEncodedSolution { 99 99 protected CompiledMultiObjectiveProblemDefinition() : base() { } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProblemDefinitionScript.cs
r17320 r17699 31 31 [StorableType("17741D64-CF9D-4CCF-9892-0590C325D4E6")] 32 32 public sealed class MultiObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution> : ProblemDefinitionScript<TEncoding, TEncodedSolution>, IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>, IStorableContent 33 where TEncoding : class, IEncoding <TEncodedSolution>33 where TEncoding : class, IEncoding 34 34 where TEncodedSolution : class, IEncodedSolution { 35 35 public string Filename { get; set; } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProgrammableProblem.cs
r17320 r17699 35 35 [StorableType("1AA24077-4E1E-4FAE-8EC8-B6008DFD30B9")] 36 36 public abstract class MultiObjectiveProgrammableProblem<TEncoding, TEncodedSolution> : MultiObjectiveProblem<TEncoding, TEncodedSolution>, IProgrammableItem, IProgrammableProblem 37 where TEncoding : class, IEncoding <TEncodedSolution>37 where TEncoding : class, IEncoding 38 38 where TEncodedSolution : class, IEncodedSolution { 39 39 protected static readonly string ENCODING_NAMESPACE = "ENCODING_NAMESPACE"; -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/ProblemDefinitionScript.cs
r17226 r17699 57 57 [StorableType("0B3AF22C-4744-4860-BBCF-A92046000847")] 58 58 public abstract class ProblemDefinitionScript<TEncoding, TEncodedSolution> : ProblemDefinitionScript, IProblemDefinition<TEncoding, TEncodedSolution> 59 where TEncoding : class, IEncoding <TEncodedSolution>59 where TEncoding : class, IEncoding 60 60 where TEncodedSolution : class, IEncodedSolution { 61 61 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProblemDefinitionScript.cs
r17383 r17699 31 31 [StorableType("D0B2A649-EDDE-4A6E-A3B5-F40F5FD1B2C0")] 32 32 public sealed class SingleObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution> : ProblemDefinitionScript<TEncoding, TEncodedSolution>, ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>, IStorableContent 33 where TEncoding : class, IEncoding <TEncodedSolution>33 where TEncoding : class, IEncoding 34 34 where TEncodedSolution : class, IEncodedSolution { 35 35 public string Filename { get; set; } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblem.cs
r17383 r17699 36 36 [StorableType("44944E6B-E95E-4805-8F0A-0C0F7D761DB9")] 37 37 public abstract class SingleObjectiveProgrammableProblem<TEncoding, TEncodedSolution> : SingleObjectiveProblem<TEncoding, TEncodedSolution>, IProgrammableItem, IProgrammableProblem 38 where TEncoding : class, IEncoding <TEncodedSolution>38 where TEncoding : class, IEncoding 39 39 where TEncodedSolution : class, IEncodedSolution { 40 40 protected static readonly string ENCODING_NAMESPACE = "ENCODING_NAMESPACE"; -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/AlbaEncoding.cs
r17698 r17699 32 32 [Item("AlbaEncoding", "Represents the encoding for Alba encoded solutions.")] 33 33 [StorableType("9ff9f959-31d2-44e5-8a5e-b122220535c2")] 34 public class AlbaEncoding : Encoding <AlbaEncodedSolution>, IVRPEncoding<AlbaEncodedSolution>{34 public class AlbaEncoding : Encoding, IVRPEncoding { 35 35 36 36 [StorableConstructor] -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPEncoding.cs
r17698 r17699 22 22 using HEAL.Attic; 23 23 using HeuristicLab.Optimization; 24 using HeuristicLab.Problems.VehicleRouting.Interfaces;25 24 26 25 namespace HeuristicLab.Problems.VehicleRouting { … … 28 27 [StorableType("b6674651-cc95-48d8-a2c3-83ee9325def3")] 29 28 public interface IVRPEncoding : IEncoding { } 30 31 [StorableType("7d010ab3-2e01-4383-bb6c-7c47ef9d803f")]32 public interface IVRPEncoding<T> : IVRPEncoding, IEncoding<T> where T : class, IVRPEncodedSolution { }33 29 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r17698 r17699 45 45 [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 110)] 46 46 [StorableType("95137523-AE3B-4638-958C-E86829D54CE3")] 47 public sealed class VehicleRoutingProblem : SingleObjectiveProblem< AlbaEncoding, AlbaEncodedSolution>, IProblemInstanceConsumer<IVRPData> {47 public sealed class VehicleRoutingProblem : SingleObjectiveProblem<IVRPEncoding, IVRPEncodedSolution>, IProblemInstanceConsumer<IVRPData> { 48 48 49 49 public static new Image StaticItemImage { … … 97 97 } 98 98 99 public override ISingleObjectiveEvaluationResult Evaluate( AlbaEncodedSolution solution, IRandom random, CancellationToken cancellationToken) {99 public override ISingleObjectiveEvaluationResult Evaluate(IVRPEncodedSolution solution, IRandom random, CancellationToken cancellationToken) { 100 100 return new SingleObjectiveEvaluationResult(ProblemInstance.Evaluate(solution).Quality); 101 101 }
Note: See TracChangeset
for help on using the changeset viewer.