Line | |
---|
1 | using System.Collections.Generic;
|
---|
2 | using System.Linq;
|
---|
3 | using HeuristicLab.Common;
|
---|
4 | using HeuristicLab.Encodings.RealVectorEncoding;
|
---|
5 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
6 | using HeuristicLab.Random;
|
---|
7 |
|
---|
8 | namespace HeuristicLab.BioBoost.Operators.Mutation {
|
---|
9 |
|
---|
10 | [StorableClass]
|
---|
11 | public class PlantSupplierUtilizationExchanger : PlantBasedUtilizationModifier {
|
---|
12 |
|
---|
13 | #region Construction & Cloning
|
---|
14 | [StorableConstructor]
|
---|
15 | public PlantSupplierUtilizationExchanger(bool isDeserializing) {}
|
---|
16 | public PlantSupplierUtilizationExchanger(PlantSupplierUtilizationExchanger orig, Cloner cloner) : base(orig, cloner) {}
|
---|
17 | public PlantSupplierUtilizationExchanger() {}
|
---|
18 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
19 | return new PlantSupplierUtilizationExchanger(this, cloner);
|
---|
20 | }
|
---|
21 | #endregion
|
---|
22 |
|
---|
23 | public override void Redistribute(RealVector utilizations, List<int> supplierIndices) {
|
---|
24 | var suppliers = supplierIndices.SampleRandom(Random, 2).ToArray();
|
---|
25 | if (suppliers.Length >= 2) {
|
---|
26 | var temp = utilizations[suppliers[0]];
|
---|
27 | utilizations[suppliers[0]] = utilizations[suppliers[1]];
|
---|
28 | utilizations[suppliers[1]] = temp;
|
---|
29 | }
|
---|
30 | }
|
---|
31 |
|
---|
32 |
|
---|
33 | }
|
---|
34 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.