Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2981_MRCPSP/HeuristicLab.Problem.Scheduling.MRCPSP/3.3/Encoding/Activity.cs @ 16598

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

#2981:

  • added problem definition
  • added improvers and crossover
  • added file importer
File size: 2.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Parameters;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Problems.Scheduling.MRCPSP {
29
30  [Item(nameof(Activity), "")]
31  [StorableClass]
32  public sealed class Activity : ParameterizedNamedItem {
33    //public Activity()
34    //    : this() {
35    //}
36
37    public override string ToString() => $"{Name} (Activity {Number})";
38
39    [Storable]
40    private readonly IFixedValueParameter<IntValue> numberParam;
41
42    [Storable]
43    private readonly IValueParameter<ItemList<Mode>> modesParam;
44
45    [Storable]
46    private readonly IValueParameter<ItemList<IntValue>> successorsParam;
47
48    public Activity() {
49      Parameters.Add(numberParam = new FixedValueParameter<IntValue>(nameof(Number), new IntValue()));
50      Parameters.Add(modesParam = new ValueParameter<ItemList<Mode>>(nameof(Modes), new ItemList<Mode>()));
51      Parameters.Add(successorsParam = new ValueParameter<ItemList<IntValue>>(nameof(Successors), new ItemList<IntValue>()));
52    }
53
54    [StorableConstructor]
55    private Activity(bool deserializing)
56        : base(deserializing) { }
57
58    private Activity(Activity original, Cloner cloner)
59        : base(original, cloner) {
60      numberParam = cloner.Clone(original.numberParam);
61      modesParam = cloner.Clone(original.modesParam);
62      successorsParam = cloner.Clone(original.successorsParam);
63    }
64
65    public int Number {
66      get => numberParam.Value.Value;
67      set => numberParam.Value.Value = value;
68    }
69
70    public ItemList<Mode> Modes {
71      get => modesParam.Value;
72      set => modesParam.Value = value;
73    }
74
75    public ItemList<IntValue> Successors {
76      get => successorsParam.Value;
77      set => successorsParam.Value = value;
78    }
79
80    public override IDeepCloneable Clone(Cloner cloner) => new Activity(this, cloner);
81  }
82}
Note: See TracBrowser for help on using the repository browser.