Changeset 16751 for branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveMoveGenerator.cs
- Timestamp:
- 04/03/19 15:37:38 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveMoveGenerator.cs
r16723 r16751 34 34 [Item("Single-objective MoveGenerator", "Calls the GetNeighbors method of the problem definition to obtain the moves.")] 35 35 [StorableType("CB37E7D8-EAC3-4061-9D39-20538CD1064D")] 36 public class SingleObjectiveMoveGenerator<T Solution> : SingleSuccessorOperator, INeighborBasedOperator<TSolution>, IMultiMoveGenerator, IStochasticOperator, ISingleObjectiveMoveOperator37 where T Solution : class, ISolution {36 public class SingleObjectiveMoveGenerator<TEncodedSolution> : SingleSuccessorOperator, INeighborBasedOperator<TEncodedSolution>, IMultiMoveGenerator, IStochasticOperator, ISingleObjectiveMoveOperator 37 where TEncodedSolution : class, IEncodedSolution { 38 38 public ILookupParameter<IRandom> RandomParameter { 39 39 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } … … 44 44 } 45 45 46 public ILookupParameter<IEncoding<T Solution>> EncodingParameter {47 get { return (ILookupParameter<IEncoding<T Solution>>)Parameters["Encoding"]; }46 public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter { 47 get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; } 48 48 } 49 49 50 public Func<T Solution, IRandom, IEnumerable<TSolution>> GetNeighborsFunc { get; set; }50 public Func<TEncodedSolution, IRandom, IEnumerable<TEncodedSolution>> GetNeighborsFunc { get; set; } 51 51 52 52 [StorableConstructor] 53 53 protected SingleObjectiveMoveGenerator(StorableConstructorFlag _) : base(_) { } 54 protected SingleObjectiveMoveGenerator(SingleObjectiveMoveGenerator<T Solution> original, Cloner cloner)54 protected SingleObjectiveMoveGenerator(SingleObjectiveMoveGenerator<TEncodedSolution> original, Cloner cloner) 55 55 : base(original, cloner) { } 56 56 public SingleObjectiveMoveGenerator() { 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<T Solution>>("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.")); 60 60 } 61 61 62 62 public override IDeepCloneable Clone(Cloner cloner) { 63 return new SingleObjectiveMoveGenerator<T Solution>(this, cloner);63 return new SingleObjectiveMoveGenerator<TEncodedSolution>(this, cloner); 64 64 } 65 65 … … 68 68 var sampleSize = SampleSizeParameter.ActualValue.Value; 69 69 var encoding = EncodingParameter.ActualValue; 70 var solution = ScopeUtil.Get Solution(ExecutionContext.Scope, encoding);70 var solution = ScopeUtil.GetEncodedSolution(ExecutionContext.Scope, encoding); 71 71 var nbhood = GetNeighborsFunc(solution, random).Take(sampleSize).ToList(); 72 72 … … 74 74 for (int i = 0; i < moveScopes.Length; i++) { 75 75 moveScopes[i] = new Scope(i.ToString(CultureInfo.InvariantCulture.NumberFormat)); 76 ScopeUtil.Copy SolutionToScope(moveScopes[i], encoding, nbhood[i]);76 ScopeUtil.CopyEncodedSolutionToScope(moveScopes[i], encoding, nbhood[i]); 77 77 } 78 78 ExecutionContext.Scope.SubScopes.AddRange(moveScopes);
Note: See TracChangeset
for help on using the changeset viewer.