Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/03/18 00:28:51 (6 years ago)
Author:
abeham
Message:

#1614:

  • fixed a bug in GRASP where solutions in the elite set would be mutated
  • introduced termination criteria when reaching best-known quality
  • tweaked generating random numbers in StochasticNMoveSingleMoveGenerator
  • changed DiscreteLocationCrossover to use an allele from one of the parents instead of introducing a mutation in case no feasible insert location is found
  • changed OSGA maxselpress to 500
  • slight change to contexts, introduced single-objectiveness much earlier in the class hierachy
    • limited ContextAlgorithm to SingleObjectiveBasicProblems (doesn't matter here)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/Infrastructure/Algorithms/ContextAlgorithm.cs

    r15562 r15572  
    3333  [Item("Context-based Algorithm", "Algorithms that make use of contexts to facilitate applying operators.")]
    3434  [StorableClass]
    35   public abstract class ContextAlgorithm<TContext> : BasicAlgorithm
    36     where TContext : class, IContext, new() {
     35  public abstract class ContextAlgorithm<TContext, TEncoding> : BasicAlgorithm
     36    where TContext : class, IContext, new()
     37    where TEncoding : class, IEncoding {
     38
     39    public override Type ProblemType {
     40      get { return typeof(SingleObjectiveBasicProblem<TEncoding>); }
     41    }
     42
     43    public new SingleObjectiveBasicProblem<TEncoding> Problem {
     44      get { return (SingleObjectiveBasicProblem<TEncoding>)base.Problem; }
     45      set { base.Problem = value; }
     46    }
    3747
    3848    [Storable]
     
    6272      get { return maximumRuntimeParameter; }
    6373    }
     74    [Storable]
     75    private FixedValueParameter<BoolValue> stopAtBestKnownQualityParameter;
     76    public IFixedValueParameter<BoolValue> StopAtBestKnownQualityParameter {
     77      get { return stopAtBestKnownQualityParameter; }
     78    }
    6479
    6580    public IAnalyzer Analyzer {
     
    7994      set { maximumRuntimeParameter.Value.Value = value; }
    8095    }
     96    public bool StopAtBestKnownQuality {
     97      get { return stopAtBestKnownQualityParameter.Value.Value; }
     98      set { stopAtBestKnownQualityParameter.Value.Value = value; }
     99    }
    81100
    82101    [StorableConstructor]
    83102    protected ContextAlgorithm(bool deserializing) : base(deserializing) { }
    84     protected ContextAlgorithm(ContextAlgorithm<TContext> original, Cloner cloner)
     103    protected ContextAlgorithm(ContextAlgorithm<TContext, TEncoding> original, Cloner cloner)
    85104      : base(original, cloner) {
    86105      context = cloner.Clone(original.context);
     
    89108      maximumEvaluationsParameter = cloner.Clone(original.maximumEvaluationsParameter);
    90109      maximumRuntimeParameter = cloner.Clone(original.maximumRuntimeParameter);
     110      stopAtBestKnownQualityParameter = cloner.Clone(original.stopAtBestKnownQualityParameter);
    91111    }
    92112    protected ContextAlgorithm()
     
    96116      Parameters.Add(maximumEvaluationsParameter = new FixedValueParameter<IntValue>("MaximumEvaluations", "The number of evaluated solutions that the algorithm should perform or < 1 to ignore.", new IntValue(0)));
    97117      Parameters.Add(maximumRuntimeParameter = new FixedValueParameter<TimeSpanValue>("MaximumRuntime", "The timespan that the algorithm is allowed to run.", new TimeSpanValue(TimeSpan.FromMinutes(1))));
     118      Parameters.Add(stopAtBestKnownQualityParameter = new FixedValueParameter<BoolValue>("StopAtBestKnownQuality", "Whether the algorithm should terminate if the best known quality has been found.", new BoolValue(true)));
    98119    }
    99120
     
    121142      return MaximumIterations > 0 && Context.Iterations > MaximumIterations
    122143        || MaximumEvaluations > 0 && Context.EvaluatedSolutions > MaximumEvaluations
    123         || MaximumRuntime > TimeSpan.Zero && ExecutionTime > MaximumRuntime;
     144        || MaximumRuntime > TimeSpan.Zero && ExecutionTime > MaximumRuntime
     145        || StopAtBestKnownQuality && !double.IsNaN(Problem.BestKnownQuality)
     146          && Context.BestQuality.IsAlmost(Problem.BestKnownQuality);
    124147    }
    125148  }
Note: See TracChangeset for help on using the changeset viewer.