Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/10/17 22:11:10 (6 years ago)
Author:
abeham
Message:

#1614: refactored code

  • change problem to derive from basic problem
  • using a combined instance class instead of individual parameters
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Manipulators/MultiGQAPManipulator.cs

    r11505 r15504  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3535  [Item("MultiGQAPManipulator", "Randomly selects and applies one of its manipulators every time it is called.")]
    3636  [StorableClass]
    37   public class MultiGQAPManipulator : StochasticMultiBranch<IGQAPManipulator>, IGQAPManipulator {
     37  public class MultiGQAPManipulator : StochasticMultiBranch<IGQAPManipulator>, IGQAPManipulator,
     38    IProblemInstanceAwareGQAPOperator {
    3839    public override bool CanChangeName {
    3940      get { return false; }
     
    4647      get { return (ILookupParameter<IntegerVector>)Parameters["Assignment"]; }
    4748    }
     49    public ILookupParameter<GQAPInstance> ProblemInstanceParameter {
     50      get { return (ILookupParameter<GQAPInstance>)Parameters["ProblemInstance"]; }
     51    }
    4852
    4953    [StorableConstructor]
     
    5357      : base() {
    5458      Parameters.Add(new LookupParameter<IntegerVector>("Assignment", GQAPSolutionCreator.AssignmentDescription));
     59      Parameters.Add(new LookupParameter<GQAPInstance>("ProblemInstance", GQAP.ProblemInstanceDescription));
     60
    5561      foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(IGQAPManipulator))) {
    5662        if (!typeof(MultiOperator<IGQAPManipulator>).IsAssignableFrom(type))
     
    7379
    7480    private void Parameterize() {
    75       foreach (var op in Operators.OfType<IGQAPManipulator>())
     81      foreach (var op in Operators.OfType<IGQAPManipulator>()) {
    7682        op.AssignmentParameter.ActualName = AssignmentParameter.Name;
    77       foreach (var op in Operators.OfType<IStochasticOperator>())
     83        op.AssignmentParameter.Hidden = true;
     84      }
     85      foreach (var op in Operators.OfType<IStochasticOperator>()) {
    7886        op.RandomParameter.ActualName = RandomParameter.Name;
     87        op.RandomParameter.Hidden = true;
     88      }
     89      foreach (var op in Operators.OfType<IProblemInstanceAwareGQAPOperator>()) {
     90        op.ProblemInstanceParameter.ActualName = ProblemInstanceParameter.Name;
     91        op.ProblemInstanceParameter.Hidden = true;
     92      }
    7993    }
    8094
    8195    public override IOperation InstrumentedApply() {
    8296      if (Operators.Count == 0) throw new InvalidOperationException(Name + ": Please add at least one manipulator to choose from.");
    83       return base.Apply();
     97      return base.InstrumentedApply();
    8498    }
    8599  }
Note: See TracChangeset for help on using the changeset viewer.