Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/31/18 14:01:55 (7 years ago)
Author:
abeham
Message:

#1614: Added random search and fixed execution time counting for commercial solvers

Location:
branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/RandomSearch
Files:
1 added
2 copied

Legend:

Unmodified
Added
Removed
  • branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/RandomSearch/RandomSearch.cs

    r15687 r15698  
    3030
    3131namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms.LocalSearch {
    32   [Item("Multi-start Local Search (GQAP)", "Multi-start local search for the GQAP.")]
     32  [Item("Random Search (GQAP)", "Random search for the GQAP.")]
    3333  [Creatable(CreatableAttribute.Categories.SingleSolutionAlgorithms)]
    3434  [StorableClass]
    35   public sealed class MultistartLS : StochasticAlgorithm<LocalSearchContext, IntegerVectorEncoding> {
     35  public sealed class RandomSearch : StochasticAlgorithm<LocalSearchContext, IntegerVectorEncoding> {
    3636
    3737    public override bool SupportsPause {
     
    4949
    5050    [StorableConstructor]
    51     private MultistartLS(bool deserializing) : base(deserializing) { }
    52     private MultistartLS(MultistartLS original, Cloner cloner)
     51    private RandomSearch(bool deserializing) : base(deserializing) { }
     52    private RandomSearch(RandomSearch original, Cloner cloner)
    5353      : base(original, cloner) {
    5454    }
    55     public MultistartLS() {
     55    public RandomSearch() {
    5656
    5757      Problem = new GQAP();
     
    5959   
    6060    public override IDeepCloneable Clone(Cloner cloner) {
    61       return new MultistartLS(this, cloner);
     61      return new RandomSearch(this, cloner);
    6262    }
    6363
     
    7474
    7575      while (!StoppingCriterion()) {
    76         var lsevaluations = 0;
    7776        var assign = new IntegerVector(Problem.ProblemInstance.Demands.Length, Context.Random, 0, Problem.ProblemInstance.Capacities.Length);
    7877        var eval = Problem.ProblemInstance.Evaluate(assign);
     78        var candidate = new GQAPSolution(assign, eval);
    7979        Context.EvaluatedSolutions++;
    80 
    81         var candidate = new GQAPSolution(assign, eval);
    82         OneOptLocalSearch.Apply(Context.Random, candidate, Problem.ProblemInstance, out lsevaluations);
    83         Context.EvaluatedSolutions += lsevaluations;
    8480
    8581        var candidateFit = Problem.ProblemInstance.ToSingleObjective(candidate.Evaluation);
  • branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/RandomSearch/RandomSearchContext.cs

    r15687 r15698  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms.LocalSearch {
    28   [Item("Local Search Context", "Context for local search algorithms.")]
     27namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms.RandomSearch {
     28  [Item("Random Search Context", "Context for random search algorithms.")]
    2929  [StorableClass]
    30   public sealed class LocalSearchContext : SingleSolutionContext<ISingleObjectiveSolutionScope<GQAPSolution>> {
     30  public sealed class RandomSearchContext : SingleSolutionContext<ISingleObjectiveSolutionScope<GQAPSolution>> {
    3131    [Storable]
    3232    private IValueParameter<GQAP> problem;
     
    4444   
    4545    [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)
    4848    : base(original, cloner) {
    4949      problem = cloner.Clone(original.problem);
    5050      bestSolution = cloner.Clone(original.bestSolution);
    5151    }
    52     public LocalSearchContext() {
     52    public RandomSearchContext() {
    5353      Parameters.Add(problem = new ValueParameter<GQAP>("Problem"));
    5454      Parameters.Add(bestSolution = new ValueParameter<GQAPSolution>("BestFoundSolution"));
     
    5656
    5757    public override IDeepCloneable Clone(Cloner cloner) {
    58       return new LocalSearchContext(this, cloner);
     58      return new RandomSearchContext(this, cloner);
    5959    }
    6060
Note: See TracChangeset for help on using the changeset viewer.