Free cookie consent management tool by TermsFeed Policy Generator

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

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

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

File size: 1.2 KB
RevLine 
[13069]1using System.Collections.Generic;
2using System.Linq;
3using HeuristicLab.Common;
4using HeuristicLab.Encodings.RealVectorEncoding;
5using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
6using HeuristicLab.Random;
7
8namespace 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.