source: branches/HeuristicLab.Problems.BioBoost/HeuristicLab.Problems.BioBoost/3.3/Operators/Mutation/PlantSupplierEqualizer.cs @ 13069

Last change on this file since 13069 was 13069, checked in by gkronber, 7 years ago

#2499: imported source code for HeuristicLab.BioBoost from private repository with some changes

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