Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3145


Ignore:
Timestamp:
03/20/10 20:16:18 (15 years ago)
Author:
abeham
Message:

fixed some things in trajectory based algorithms #933

Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearch.cs

    r3134 r3145  
    103103    #endregion
    104104
     105    [StorableConstructor]
     106    private LocalSearch(bool deserializing) : base() { }
    105107    public LocalSearch()
    106108      : base() {
     
    137139    }
    138140
    139     [StorableConstructor]
    140     private LocalSearch(bool deserializing) : base() { }
    141 
    142141    public override IDeepCloneable Clone(Cloner cloner) {
    143142      LocalSearch clone = (LocalSearch)base.Clone(cloner);
     
    156155      ParameterizeSolutionsCreator();
    157156      ParameterizeMainLoop();
    158       ParameterizeMoveEvaluator();
    159       ParameterizeMoveMaker();
     157      ParameterizeMoveEvaluators();
     158      ParameterizeMoveMakers();
    160159      UpdateMoveGenerator();
    161160      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
     
    171170      ParameterizeSolutionsCreator();
    172171      ParameterizeMainLoop();
    173       ParameterizeMoveEvaluator();
    174       ParameterizeMoveMaker();
     172      ParameterizeMoveEvaluators();
     173      ParameterizeMoveMakers();
    175174      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    176175      base.Problem_EvaluatorChanged(sender, e);
     
    179178      ParameterizeStochasticOperator(Problem.Visualizer);
    180179      ParameterizeMainLoop();
     180      if (Problem.Visualizer != null) Problem.Visualizer.VisualizationParameter.ActualNameChanged += new EventHandler(Visualizer_VisualizationParameter_ActualNameChanged);
    181181      base.Problem_VisualizerChanged(sender, e);
    182182    }
     
    194194        UpdateMoveParameters();
    195195      ParameterizeMainLoop();
    196       ParameterizeMoveEvaluator();
    197       ParameterizeMoveMaker();
     196      ParameterizeMoveEvaluators();
     197      ParameterizeMoveMakers();
    198198      base.Problem_OperatorsChanged(sender, e);
    199199    }
    200200    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
    201201      ParameterizeMainLoop();
    202       ParameterizeMoveEvaluator();
    203       ParameterizeMoveMaker();
     202      ParameterizeMoveEvaluators();
     203      ParameterizeMoveMakers();
    204204    }
    205205    private void MoveGeneratorParameter_ValueChanged(object sender, EventArgs e) {
     
    208208    private void MoveEvaluatorParameter_ValueChanged(object sender, EventArgs e) {
    209209      ParameterizeMainLoop();
    210       ParameterizeMoveEvaluator();
    211       ParameterizeMoveMaker();
     210      ParameterizeMoveEvaluators();
     211      ParameterizeMoveMakers();
    212212    }
    213213    private void MoveEvaluator_MoveQualityParameter_ActualNameChanged(object sender, EventArgs e) {
    214214      ParameterizeMainLoop();
    215       ParameterizeMoveEvaluator();
    216       ParameterizeMoveMaker();
     215      ParameterizeMoveEvaluators();
     216      ParameterizeMoveMakers();
     217    }
     218    private void Visualizer_VisualizationParameter_ActualNameChanged(object sender, EventArgs e) {
     219      ParameterizeMainLoop();
    217220    }
    218221    #endregion
     
    237240          MoveGeneratorParameter.ValidValues.Add(generator);
    238241      }
    239       if (oldMoveGenerator != null && MoveGeneratorParameter.ValidValues.Any(x => x.GetType() == oldMoveGenerator.GetType()))
    240         MoveGenerator = MoveGeneratorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveGenerator.GetType());
     242      if (oldMoveGenerator != null) {
     243        IMoveGenerator newMoveGenerator = MoveGeneratorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveGenerator.GetType());
     244        if (newMoveGenerator != null) MoveGenerator = newMoveGenerator;
     245      }
    241246      if (MoveGenerator == null) {
    242247        ClearMoveParameters();
     
    279284    }
    280285    private void ParameterizeMainLoop() {
     286      MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
    281287      MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
    282288      MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
    283289      if (MoveEvaluator != null)
    284290        MainLoop.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
    285       MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
    286291      MainLoop.VisualizerParameter.ActualName = Problem.VisualizerParameter.Name;
    287       MainLoop.VisualizationParameter.ActualName = Problem.Visualizer.VisualizationParameter.ActualName;
     292      if (Problem.Visualizer != null)
     293        MainLoop.VisualizationParameter.ActualName = Problem.Visualizer.VisualizationParameter.ActualName;
    288294    }
    289295    private void ParameterizeStochasticOperator(IOperator op) {
     
    291297        ((IStochasticOperator)op).RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
    292298    }
    293     private void ParameterizeMoveEvaluator() {
     299    private void ParameterizeMoveEvaluators() {
    294300      foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
    295301        op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
    296302      }
    297303    }
    298     private void ParameterizeMoveMaker() {
     304    private void ParameterizeMoveMakers() {
    299305      foreach (IMoveMaker op in Problem.Operators.OfType<IMoveMaker>()) {
    300306        op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
  • trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearchMainLoop.cs

    r3143 r3145  
    3535  [Item("LocalSearchMainLoop", "An operator which represents the main loop of a best improvement local search (if only a single move is generated in each iteration it is a first improvement local search).")]
    3636  [StorableClass]
    37   public class LocalSearchMainLoop : AlgorithmOperator {
     37  public sealed class LocalSearchMainLoop : AlgorithmOperator {
    3838    #region Parameter properties
    3939    public ValueLookupParameter<IRandom> RandomParameter {
     
    8282    #endregion
    8383
     84    [StorableConstructor]
     85    private LocalSearchMainLoop(bool deserializing) : base() { }
    8486    public LocalSearchMainLoop()
    8587      : base() {
     88      Initialize();
     89    }
     90
     91    private void Initialize() {
    8692      #region Create parameters
    8793      Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
  • trunk/sources/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealing.cs

    r3131 r3145  
    3535  [Item("Simulated Annealing", "A simulated annealing algorithm.")]
    3636  [Creatable("Algorithms")]
    37   public class SimulatedAnnealing : EngineAlgorithm {
     37  public sealed class SimulatedAnnealing : EngineAlgorithm {
    3838    #region Problem Properties
    3939    public override Type ProblemType {
     
    132132    #endregion
    133133
     134    [StorableConstructor]
     135    private SimulatedAnnealing(bool deserializing) : base() { }
    134136    public SimulatedAnnealing()
    135137      : base() {
     
    173175    }
    174176
    175     [StorableConstructor]
    176     private SimulatedAnnealing(bool deserializing) : base() { }
    177 
    178177    public override IDeepCloneable Clone(Cloner cloner) {
    179178      SimulatedAnnealing clone = (SimulatedAnnealing)base.Clone(cloner);
     
    213212      base.Problem_EvaluatorChanged(sender, e);
    214213    }
     214    protected override void Problem_VisualizerChanged(object sender, EventArgs e) {
     215      ParameterizeStochasticOperator(Problem.Visualizer);
     216      ParameterizeMainLoop();
     217      if (Problem.Visualizer != null) Problem.Visualizer.VisualizationParameter.ActualNameChanged += new EventHandler(Visualizer_VisualizationParameter_ActualNameChanged);
     218      base.Problem_VisualizerChanged(sender, e);
     219    }
    215220    protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
    216221      foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op);
     
    248253      ParameterizeMoveEvaluators();
    249254      ParameterizeMoveMakers();
     255    }
     256    private void Visualizer_VisualizationParameter_ActualNameChanged(object sender, EventArgs e) {
     257      ParameterizeMainLoop();
    250258    }
    251259    #endregion
     
    325333    }
    326334    private void ParameterizeMainLoop() {
     335      MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
    327336      MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
    328337      MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
    329338      if (MoveEvaluator != null)
    330339        MainLoop.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
     340      MainLoop.VisualizerParameter.ActualName = Problem.VisualizerParameter.Name;
     341      if (Problem.Visualizer != null)
     342        MainLoop.VisualizationParameter.ActualName = Problem.Visualizer.VisualizationParameter.ActualName;
    331343    }
    332344    private void ParameterizeStochasticOperator(IOperator op) {
  • trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearch.cs

    r3141 r3145  
    128128
    129129    [StorableConstructor]
    130     public TabuSearch(bool deserializing) : base() { }
     130    private TabuSearch(bool deserializing) : base() { }
    131131    public TabuSearch()
    132132      : base() {
  • trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearchMainLoop.cs

    r3143 r3145  
    8686    #endregion
    8787
     88    [StorableConstructor]
     89    private TabuSearchMainLoop(bool deserializing) : base() { }
    8890    public TabuSearchMainLoop()
    8991      : base() {
     92      Initialize();
     93    }
     94
     95    private void Initialize() {
    9096      #region Create parameters
    9197      Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
     
    97103      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed."));
    98104      Parameters.Add(new ValueLookupParameter<IntValue>("TabuTenure", "The length of the tabu list, and also means the number of iterations a move is kept tabu"));
    99      
     105
    100106      Parameters.Add(new ValueLookupParameter<IOperator>("MoveGenerator", "The operator that generates the moves."));
    101107      Parameters.Add(new ValueLookupParameter<IOperator>("MoveMaker", "The operator that performs a move and updates the quality."));
     
    192198      bestAverageWorstMoveQualityCalculator.QualityParameter.ActualName = MoveQualityParameter.Name;
    193199      bestAverageWorstMoveQualityCalculator.WorstQualityParameter.ActualName = "Worst Move Quality";
    194      
     200
    195201      valuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Move Quality"));
    196202      valuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Average Move Quality"));
Note: See TracChangeset for help on using the changeset viewer.