Changeset 15564 for branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/Evolutionary/OSGAContext.cs
- Timestamp:
- 01/01/18 23:52:39 (6 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/Evolutionary/OSGAContext.cs
r15562 r15564 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Data; 25 26 using HeuristicLab.Parameters; 26 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 28 28 namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms. GRASP{29 [Item(" GRASP+PR (GQAP) Context", "Context for GRASP+PR(GQAP).")]29 namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms.Evolutionary { 30 [Item("OSGA (GQAP) Context", "Context for OSGA (GQAP).")] 30 31 [StorableClass] 31 public sealed class GRASPContext : SingleObjectivePopulationContext<ISingleObjectiveSolutionScope<GQAPSolution>> {32 public sealed class OSGAContext : SingleObjectivePopulationContext<ISingleObjectiveSolutionScope<GQAPSolution>> { 32 33 33 34 [Storable] … … 44 45 set { bestSolution.Value = value; } 45 46 } 46 47 48 [Storable] 49 private IValueParameter<ItemList<ISingleObjectiveSolutionScope<GQAPSolution>>> nextGeneration; 50 public ItemList<ISingleObjectiveSolutionScope<GQAPSolution>> NextGeneration { 51 get { return nextGeneration.Value; } 52 set { nextGeneration.Value = value; } 53 } 54 55 [Storable] 56 private IValueParameter<DoubleValue> selectionPressure; 57 public double SelectionPressure { 58 get { return selectionPressure.Value.Value; } 59 set { selectionPressure.Value.Value = value; } 60 } 61 62 [Storable] 63 private IValueParameter<IntValue> attempts; 64 public int Attempts { 65 get { return attempts.Value.Value; } 66 set { attempts.Value.Value = value; } 67 } 68 47 69 public void SortPopulation() { 48 70 Scope.SubScopes.Replace(Scope.SubScopes.OfType<ISingleObjectiveSolutionScope<GQAPSolution>>().OrderBy(x => Problem.Maximization ? -x.Fitness : x.Fitness).ToList()); … … 50 72 51 73 [StorableConstructor] 52 private GRASPContext(bool deserializing) : base(deserializing) { }53 private GRASPContext(GRASPContext original, Cloner cloner)74 private OSGAContext(bool deserializing) : base(deserializing) { } 75 private OSGAContext(OSGAContext original, Cloner cloner) 54 76 : base(original, cloner) { 55 77 problem = cloner.Clone(original.problem); 56 78 bestSolution = cloner.Clone(original.bestSolution); 79 nextGeneration = cloner.Clone(original.nextGeneration); 80 selectionPressure = cloner.Clone(original.selectionPressure); 81 attempts = cloner.Clone(original.attempts); 57 82 } 58 public GRASPContext() : this("GRASP+PR(GQAP) Context") { }59 public GRASPContext(string name) : base(name) {83 public OSGAContext() : this("OSGA (GQAP) Context") { } 84 public OSGAContext(string name) : base(name) { 60 85 Parameters.Add(problem = new ValueParameter<GQAP>("Problem")); 61 86 Parameters.Add(bestSolution = new ValueParameter<GQAPSolution>("BestFoundSolution")); 87 Parameters.Add(nextGeneration = new ValueParameter<ItemList<ISingleObjectiveSolutionScope<GQAPSolution>>>("NextGeneration")); 88 Parameters.Add(selectionPressure = new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0))); 89 Parameters.Add(attempts = new ValueParameter<IntValue>("Attempts", new IntValue(0))); 62 90 } 63 91 64 92 public override IDeepCloneable Clone(Cloner cloner) { 65 return new GRASPContext(this, cloner);93 return new OSGAContext(this, cloner); 66 94 } 67 95
Note: See TracChangeset
for help on using the changeset viewer.