Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Crossovers/IntValue/MultiIntValueCrossover.cs

Last change on this file was 16996, checked in by gkronber, 5 years ago

#2520 Update plugin dependencies and references for HL.MetaOptimization for new persistence

File size: 1.8 KB
Line 
1using System;
2using System.Linq;
3using HeuristicLab.Common;
4using HeuristicLab.Core;
5using HeuristicLab.Data;
6using HeuristicLab.Operators;
7using HeuristicLab.Optimization;
8using HeuristicLab.PluginInfrastructure;
9using HEAL.Attic;
10
11namespace HeuristicLab.Problems.MetaOptimization.Operators.Crossovers {
12  [Item("MultiIntValueCrossover", "Randomly selects and applies one of its crossovers every time it is called.")]
13  [StorableType("FEF9B863-E609-4743-B8C6-AA8DE6A65470")]
14  public class MultiIntValueCrossover : StochasticMultiBranch<IIntValueCrossover>, IIntValueCrossover, IStochasticOperator {
15    public override bool CanChangeName {
16      get { return false; }
17    }
18    protected override bool CreateChildOperation {
19      get { return true; }
20    }
21
22    [StorableConstructor]
23    protected MultiIntValueCrossover(StorableConstructorFlag _) : base(_) { }
24    public MultiIntValueCrossover() {
25      foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(IIntValueCrossover)).OrderBy(op => op.Name)) {
26        if (!typeof(MultiOperator<IIntValueCrossover>).IsAssignableFrom(type))
27          Operators.Add((IIntValueCrossover)Activator.CreateInstance(type), true);
28      }
29    }
30    protected MultiIntValueCrossover(MultiIntValueCrossover original, Cloner cloner)
31      : base(original, cloner) {
32    }
33    public override IDeepCloneable Clone(Cloner cloner) {
34      return new MultiIntValueCrossover(this, cloner);
35    }
36
37    public override IOperation InstrumentedApply() {
38      if (Operators.Count == 0) throw new InvalidOperationException(Name + ": Please add at least one permutation crossover to choose from.");
39      return base.InstrumentedApply();
40    }
41
42    public void Apply(IRandom random, IntValue value, IntValue other, IntValueRange range) {
43
44    }
45  }
46}
Note: See TracBrowser for help on using the repository browser.