Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2981_MRCPSP/HeuristicLab.Problem.Scheduling.MRCPSP/3.3/Encoding/Mode.cs @ 17370

Last change on this file since 17370 was 16598, checked in by ddorfmei, 6 years ago

#2981:

  • added problem definition
  • added improvers and crossover
  • added file importer
File size: 2.0 KB
Line 
1using HeuristicLab.Common;
2using HeuristicLab.Core;
3using HeuristicLab.Data;
4using HeuristicLab.Parameters;
5using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
6
7namespace HeuristicLab.Problems.Scheduling.MRCPSP {
8
9  [Item(nameof(Mode), "")]
10  [StorableClass]
11  public sealed class Mode : ParameterizedNamedItem {
12    //public Mode()
13    //  : this() {
14    //}
15
16    [Storable]
17    private readonly IFixedValueParameter<IntValue> durationParam;
18
19    [Storable]
20    private readonly IFixedValueParameter<IntValue> numberParam;
21
22    [Storable]
23    private readonly IValueParameter<ItemList<ResourceDemand>> resourceDemandsParam;
24
25    public Mode() {
26      Parameters.Add(numberParam = new FixedValueParameter<IntValue>(nameof(Number), new IntValue()));
27      Parameters.Add(resourceDemandsParam = new ValueParameter<ItemList<ResourceDemand>>(nameof(ResourceDemands), new ItemList<ResourceDemand>()));
28      Parameters.Add(durationParam = new FixedValueParameter<IntValue>(nameof(Duration), new IntValue()));
29    }
30
31    [StorableConstructor]
32    private Mode(bool deserializing)
33      : base(deserializing) { }
34
35    private Mode(Mode original, Cloner cloner)
36      : base(original, cloner) {
37      numberParam = cloner.Clone(original.numberParam);
38      resourceDemandsParam = cloner.Clone(original.resourceDemandsParam);
39      durationParam = cloner.Clone(original.durationParam);
40    }
41
42    public int Duration {
43      get => durationParam.Value.Value;
44      set => durationParam.Value.Value = value;
45    }
46
47    public int Number {
48      get => numberParam.Value.Value;
49      set => numberParam.Value.Value = value;
50    }
51
52    public ItemList<ResourceDemand> ResourceDemands {
53      get => resourceDemandsParam.Value;
54      set => resourceDemandsParam.Value = value;
55    }
56
57    public override IDeepCloneable Clone(Cloner cloner) => new Mode(this, cloner);
58
59    public override string ToString() => $"{Name} (Mode {Number})";
60  }
61}
Note: See TracBrowser for help on using the repository browser.