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