1 | using System;
|
---|
2 | using System.Linq;
|
---|
3 | using HeuristicLab.Common;
|
---|
4 | using HeuristicLab.Core;
|
---|
5 | using HeuristicLab.Data;
|
---|
6 | using HeuristicLab.Operators;
|
---|
7 | using HeuristicLab.Optimization;
|
---|
8 | using HeuristicLab.PluginInfrastructure;
|
---|
9 | using HEAL.Attic;
|
---|
10 |
|
---|
11 | namespace 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 | }
|
---|