Free cookie consent management tool by TermsFeed Policy Generator

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

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

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

File size: 1.2 KB
Line 
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 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.