Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2981_MRCPSP/HeuristicLab.Problem.Scheduling.MRCPSP/3.3/Encoding/ResourceDemand.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: 1.6 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(ResourceDemand), "")]
10  [StorableClass]
11  public sealed class ResourceDemand : ParameterizedNamedItem {
12    //public ResourceDemand()
13    //  : this() {
14    //}
15
16    [Storable]
17    private readonly IFixedValueParameter<IntValue> demandParam;
18
19    [Storable]
20    private readonly IFixedValueParameter<IntValue> numberParam;
21
22    public ResourceDemand() {
23      Parameters.Add(numberParam = new FixedValueParameter<IntValue>(nameof(Number), new IntValue()));
24      Parameters.Add(demandParam = new FixedValueParameter<IntValue>(nameof(Demand), new IntValue()));
25    }
26
27    public override string ToString() => $"{Name} (Resource {Number})";
28
29    [StorableConstructor]
30    private ResourceDemand(bool deserializing)
31      : base(deserializing) { }
32
33    private ResourceDemand(ResourceDemand original, Cloner cloner)
34      : base(original, cloner) {
35      numberParam = cloner.Clone(original.numberParam);
36      demandParam = cloner.Clone(original.demandParam);
37    }
38
39    public int Demand {
40      get => demandParam.Value.Value;
41      set => demandParam.Value.Value = value;
42    }
43
44    public int Number {
45      get => numberParam.Value.Value;
46      set => numberParam.Value.Value = value;
47    }
48
49    public override IDeepCloneable Clone(Cloner cloner) => new ResourceDemand(this, cloner);
50  }
51}
Note: See TracBrowser for help on using the repository browser.