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/Crossovers/MultiGQAPCrossover.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("MultiGQAPCrossover", "Randomly selects and applies one of its crossovers every time it is called.")]
    3636  [StorableClass]
    37   public class MultiGQAPCrossover : StochasticMultiBranch<IGQAPCrossover>, IGQAPCrossover {
     37  public class MultiGQAPCrossover : StochasticMultiBranch<IGQAPCrossover>, IGQAPCrossover, IProblemInstanceAwareGQAPOperator, IStochasticOperator {
    3838    public override bool CanChangeName {
    3939      get { return false; }
     
    4949      get { return (ILookupParameter<IntegerVector>)Parameters["Child"]; }
    5050    }
     51    public ILookupParameter<GQAPInstance> ProblemInstanceParameter {
     52      get { return (ILookupParameter<GQAPInstance>)Parameters["ProblemInstance"]; }
     53    }
    5154
    5255    [StorableConstructor]
     
    5760      Parameters.Add(new ScopeTreeLookupParameter<IntegerVector>("Parents", "The parent vectors which should be crossed.", "Assignment"));
    5861      Parameters.Add(new LookupParameter<IntegerVector>("Child", "The child vector resulting from the crossover.", "Assignment"));
     62      Parameters.Add(new LookupParameter<GQAPInstance>("ProblemInstance", GQAP.ProblemInstanceDescription));
     63
    5964      foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(IGQAPCrossover))) {
    6065        if (!typeof(MultiOperator<IGQAPCrossover>).IsAssignableFrom(type))
     
    7984      foreach (var op in Operators.OfType<IGQAPCrossover>()) {
    8085        op.ParentsParameter.ActualName = ParentsParameter.Name;
     86        op.ParentsParameter.Hidden = true;
    8187        op.ChildParameter.ActualName = ChildParameter.Name;
     88        op.ChildParameter.Hidden = true;
    8289      }
    8390      foreach (var op in Operators.OfType<IStochasticOperator>()) {
    8491        op.RandomParameter.ActualName = RandomParameter.Name;
     92        op.RandomParameter.Hidden = true;
     93      }
     94      foreach (var op in Operators.OfType<IProblemInstanceAwareGQAPOperator>()) {
     95        op.ProblemInstanceParameter.ActualName = ProblemInstanceParameter.Name;
     96        op.ProblemInstanceParameter.Hidden = true;
    8597      }
    8698    }
     
    88100    public override IOperation InstrumentedApply() {
    89101      if (Operators.Count == 0) throw new InvalidOperationException(Name + ": Please add at least one crossover to choose from.");
    90       return base.Apply();
     102      return base.InstrumentedApply();
    91103    }
    92104  }
Note: See TracChangeset for help on using the changeset viewer.