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 PlantSupplierToggler : PlantBasedUtilizationModifier {
|
---|
12 |
|
---|
13 | #region Construction & Cloning
|
---|
14 | [StorableConstructor]
|
---|
15 | public PlantSupplierToggler(bool isDeserializing) {}
|
---|
16 | public PlantSupplierToggler(PlantSupplierToggler orig, Cloner cloner) : base(orig, cloner) {}
|
---|
17 | public PlantSupplierToggler() {}
|
---|
18 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
19 | return new PlantSupplierToggler(this, cloner);
|
---|
20 | }
|
---|
21 | #endregion
|
---|
22 |
|
---|
23 | public override void Redistribute(RealVector utilizations, List<int> supplierIndices) {
|
---|
24 | var i = supplierIndices.SampleRandom(Random, 1).First();
|
---|
25 | if (utilizations[i] > 0) {
|
---|
26 | utilizations[i] = 0;
|
---|
27 | } else {
|
---|
28 | var min = Bounds[i%Bounds.Rows, 0];
|
---|
29 | var max = Bounds[i%Bounds.Rows, 1];
|
---|
30 | utilizations[i] = (max + min)/2;
|
---|
31 | }
|
---|
32 | }
|
---|
33 |
|
---|
34 |
|
---|
35 | }
|
---|
36 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.