Changeset 15698
- Timestamp:
- 01/31/18 14:01:55 (7 years ago)
- Location:
- branches/1614_GeneralizedQAP
- Files:
-
- 1 added
- 6 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/1614_GeneralizedQAP/HeuristicLab.Algorithms.GRASP/3.3/HeuristicLab.Algorithms.GRASP-3.3.csproj
r15688 r15698 108 108 <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project> 109 109 <Name>HeuristicLab.Optimization-3.3</Name> 110 <Private>False</Private>111 110 </ProjectReference> 112 111 </ItemGroup> -
branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/CPLEX/CplexSolver.cs
r15634 r15698 28 28 using HeuristicLab.Encodings.IntegerVectorEncoding; 29 29 using HeuristicLab.Optimization; 30 using HeuristicLab.Parameters; 30 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 32 using ILOG.CPLEX; … … 49 50 } 50 51 52 [Storable] 53 private ValueParameter<DateTimeValue> lastUpdateTimeParameter; 54 public IValueParameter<DateTimeValue> LastUpdateTimeParameter { 55 get { return lastUpdateTimeParameter; } 56 } 57 51 58 [StorableConstructor] 52 59 protected CplexSolver(bool deserializing) : base(deserializing) { } 53 60 protected CplexSolver(CplexSolver original, Cloner cloner) 54 61 : base(original, cloner) { 62 lastUpdateTimeParameter = cloner.Clone(original.lastUpdateTimeParameter); 55 63 } 56 64 public CplexSolver() { 57 65 Problem = new GQAP(); 58 ((MultiAnalyzer)Analyzer).AddOperator(new QualityPerClockAnalyzer()); 66 Parameters.Add(lastUpdateTimeParameter = new ValueParameter<DateTimeValue>("LastUpdateTime", "") { Hidden = true }); 67 var qpc = new QualityPerClockAnalyzer(); 68 qpc.LastUpdateTimeParameter.ActualName = LastUpdateTimeParameter.Name; 69 ((MultiAnalyzer)Analyzer).AddOperator(qpc); 59 70 } 60 71 … … 69 80 opl.AddDataSource(dataSource); 70 81 opl.Generate(); 82 LastUpdateTimeParameter.Value = new DateTimeValue(DateTime.UtcNow); 71 83 cplex.Solve(); 72 84 cplex.End(); -
branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms-3.3.csproj
r15688 r15698 142 142 <Compile Include="Properties\AssemblyInfo.cs" /> 143 143 <Compile Include="Infrastructure\SingleObjectiveSolutionScope.cs" /> 144 <Compile Include="RandomSearch\RandomSearchContext.cs" /> 145 <Compile Include="RandomSearch\RandomSearch.cs" /> 144 146 </ItemGroup> 145 147 <ItemGroup> -
branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/LocalSolverNet/GQAPBinarySolver.cs
r15633 r15698 21 21 22 22 using System; 23 using System.Linq; 23 24 using System.Threading; 25 using HeuristicLab.Analysis; 24 26 using HeuristicLab.Common; 25 27 using HeuristicLab.Core; … … 124 126 125 127 protected override void Run(CancellationToken cancellationToken) { 128 var qpc = ((MultiAnalyzer)Analyzer).Operators.OfType<QualityPerClockAnalyzer>().FirstOrDefault(); 129 if (qpc != null) { 130 qpc.LastUpdateTimeParameter.ActualName = Context.LastUpdateTimeParameter.Name; 131 } 126 132 token = cancellationToken; 127 133 lastUpdate = DateTime.UtcNow.AddSeconds(-1); … … 205 211 localSolver.AddCallback(LSCallbackType.IterationTicked, LocalSolverOnIterationTicked); 206 212 213 Context.LastUpdateTimeParameter.Value = new DateTimeValue(DateTime.UtcNow); 214 207 215 localSolver.Solve(); 208 216 -
branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/LocalSolverNet/GQAPIntegerSolver.cs
r15633 r15698 21 21 22 22 using System; 23 using System.Linq; 23 24 using System.Threading; 25 using HeuristicLab.Analysis; 24 26 using HeuristicLab.Common; 25 27 using HeuristicLab.Core; … … 118 120 119 121 protected override void Run(CancellationToken cancellationToken) { 122 var qpc = ((MultiAnalyzer)Analyzer).Operators.OfType<QualityPerClockAnalyzer>().FirstOrDefault(); 123 if (qpc != null) { 124 qpc.LastUpdateTimeParameter.ActualName = Context.LastUpdateTimeParameter.Name; 125 } 120 126 token = cancellationToken; 121 127 lastUpdate = DateTime.UtcNow.AddSeconds(-1); … … 177 183 localSolver.AddCallback(LSCallbackType.IterationTicked, LocalSolverOnIterationTicked); 178 184 185 Context.LastUpdateTimeParameter.Value = new DateTimeValue(DateTime.UtcNow); 186 179 187 localSolver.Solve(); 180 188 } finally { -
branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/LocalSolverNet/LocalSolverContext.cs
r15616 r15698 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data; 24 25 using HeuristicLab.Parameters; 25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 44 45 } 45 46 47 [Storable] 48 private ValueParameter<DateTimeValue> lastUpdateTimeParameter; 49 public IValueParameter<DateTimeValue> LastUpdateTimeParameter { 50 get { return lastUpdateTimeParameter; } 51 } 52 46 53 [StorableConstructor] 47 54 protected LocalSolverContext(bool deserializing) : base(deserializing) { } … … 50 57 problem = cloner.Clone(original.problem); 51 58 bestSolution = cloner.Clone(original.bestSolution); 59 lastUpdateTimeParameter = cloner.Clone(original.lastUpdateTimeParameter); 52 60 } 53 61 public LocalSolverContext() : base() { 54 62 Parameters.Add(problem = new ValueParameter<GQAP>("Problem")); 55 63 Parameters.Add(bestSolution = new ValueParameter<GQAPSolution>("BestFoundSolution")); 64 Parameters.Add(lastUpdateTimeParameter = new ValueParameter<DateTimeValue>("LastUpdateTime")); 56 65 } 57 66 public LocalSolverContext(string name) : base(name) { 58 67 Parameters.Add(problem = new ValueParameter<GQAP>("Problem")); 59 68 Parameters.Add(bestSolution = new ValueParameter<GQAPSolution>("BestFoundSolution")); 69 Parameters.Add(lastUpdateTimeParameter = new ValueParameter<DateTimeValue>("LastUpdateTime")); 60 70 } 61 71 public LocalSolverContext(string name, ParameterCollection parameters) : base(name, parameters) { 62 72 Parameters.Add(problem = new ValueParameter<GQAP>("Problem")); 63 73 Parameters.Add(bestSolution = new ValueParameter<GQAPSolution>("BestFoundSolution")); 74 Parameters.Add(lastUpdateTimeParameter = new ValueParameter<DateTimeValue>("LastUpdateTime")); 64 75 } 65 76 public LocalSolverContext(string name, string description) : base(name, description) { 66 77 Parameters.Add(problem = new ValueParameter<GQAP>("Problem")); 67 78 Parameters.Add(bestSolution = new ValueParameter<GQAPSolution>("BestFoundSolution")); 79 Parameters.Add(lastUpdateTimeParameter = new ValueParameter<DateTimeValue>("LastUpdateTime")); 68 80 } 69 81 public LocalSolverContext(string name, string description, ParameterCollection parameters) : base(name, description, parameters) { 70 82 Parameters.Add(problem = new ValueParameter<GQAP>("Problem")); 71 83 Parameters.Add(bestSolution = new ValueParameter<GQAPSolution>("BestFoundSolution")); 84 Parameters.Add(lastUpdateTimeParameter = new ValueParameter<DateTimeValue>("LastUpdateTime")); 72 85 } 73 86 -
branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/RandomSearch/RandomSearch.cs
r15687 r15698 30 30 31 31 namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms.LocalSearch { 32 [Item(" Multi-start Local Search (GQAP)", "Multi-start localsearch for the GQAP.")]32 [Item("Random Search (GQAP)", "Random search for the GQAP.")] 33 33 [Creatable(CreatableAttribute.Categories.SingleSolutionAlgorithms)] 34 34 [StorableClass] 35 public sealed class MultistartLS: StochasticAlgorithm<LocalSearchContext, IntegerVectorEncoding> {35 public sealed class RandomSearch : StochasticAlgorithm<LocalSearchContext, IntegerVectorEncoding> { 36 36 37 37 public override bool SupportsPause { … … 49 49 50 50 [StorableConstructor] 51 private MultistartLS(bool deserializing) : base(deserializing) { }52 private MultistartLS(MultistartLSoriginal, Cloner cloner)51 private RandomSearch(bool deserializing) : base(deserializing) { } 52 private RandomSearch(RandomSearch original, Cloner cloner) 53 53 : base(original, cloner) { 54 54 } 55 public MultistartLS() {55 public RandomSearch() { 56 56 57 57 Problem = new GQAP(); … … 59 59 60 60 public override IDeepCloneable Clone(Cloner cloner) { 61 return new MultistartLS(this, cloner);61 return new RandomSearch(this, cloner); 62 62 } 63 63 … … 74 74 75 75 while (!StoppingCriterion()) { 76 var lsevaluations = 0;77 76 var assign = new IntegerVector(Problem.ProblemInstance.Demands.Length, Context.Random, 0, Problem.ProblemInstance.Capacities.Length); 78 77 var eval = Problem.ProblemInstance.Evaluate(assign); 78 var candidate = new GQAPSolution(assign, eval); 79 79 Context.EvaluatedSolutions++; 80 81 var candidate = new GQAPSolution(assign, eval);82 OneOptLocalSearch.Apply(Context.Random, candidate, Problem.ProblemInstance, out lsevaluations);83 Context.EvaluatedSolutions += lsevaluations;84 80 85 81 var candidateFit = Problem.ProblemInstance.ToSingleObjective(candidate.Evaluation); -
branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/RandomSearch/RandomSearchContext.cs
r15687 r15698 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms. LocalSearch {28 [Item(" Local Search Context", "Context for localsearch algorithms.")]27 namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms.RandomSearch { 28 [Item("Random Search Context", "Context for random search algorithms.")] 29 29 [StorableClass] 30 public sealed class LocalSearchContext : SingleSolutionContext<ISingleObjectiveSolutionScope<GQAPSolution>> {30 public sealed class RandomSearchContext : SingleSolutionContext<ISingleObjectiveSolutionScope<GQAPSolution>> { 31 31 [Storable] 32 32 private IValueParameter<GQAP> problem; … … 44 44 45 45 [StorableConstructor] 46 private LocalSearchContext(bool deserializing) : base(deserializing) { }47 private LocalSearchContext(LocalSearchContext original, Cloner cloner)46 private RandomSearchContext(bool deserializing) : base(deserializing) { } 47 private RandomSearchContext(RandomSearchContext original, Cloner cloner) 48 48 : base(original, cloner) { 49 49 problem = cloner.Clone(original.problem); 50 50 bestSolution = cloner.Clone(original.bestSolution); 51 51 } 52 public LocalSearchContext() {52 public RandomSearchContext() { 53 53 Parameters.Add(problem = new ValueParameter<GQAP>("Problem")); 54 54 Parameters.Add(bestSolution = new ValueParameter<GQAPSolution>("BestFoundSolution")); … … 56 56 57 57 public override IDeepCloneable Clone(Cloner cloner) { 58 return new LocalSearchContext(this, cloner);58 return new RandomSearchContext(this, cloner); 59 59 } 60 60
Note: See TracChangeset
for help on using the changeset viewer.