1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2015 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 |
|
---|
22 | using System.Text;
|
---|
23 | using HeuristicLab.Common;
|
---|
24 | using HeuristicLab.Core;
|
---|
25 | using HeuristicLab.Encodings.IntegerVectorEncoding;
|
---|
26 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
27 |
|
---|
28 | namespace HeuristicLab.Encodings.ScheduleEncoding {
|
---|
29 | [Item("PriorityRulesVectorEncoding", "Represents an encoding for a Scheduling Problem.")]
|
---|
30 | [StorableClass]
|
---|
31 | public class PRVEncoding : Item, ISchedule {
|
---|
32 | [Storable]
|
---|
33 | public IntegerVector PriorityRulesVector { get; set; }
|
---|
34 |
|
---|
35 | [Storable]
|
---|
36 | public int NrOfRules { get; private set; }
|
---|
37 |
|
---|
38 | [StorableConstructor]
|
---|
39 | protected PRVEncoding(bool deserializing) : base(deserializing) { }
|
---|
40 | protected PRVEncoding(PRVEncoding original, Cloner cloner)
|
---|
41 | : base(original, cloner) {
|
---|
42 | this.NrOfRules = original.NrOfRules;
|
---|
43 | this.PriorityRulesVector = cloner.Clone(original.PriorityRulesVector);
|
---|
44 | }
|
---|
45 | public PRVEncoding(int nrOfRules)
|
---|
46 | : base() {
|
---|
47 | this.NrOfRules = nrOfRules;
|
---|
48 | this.PriorityRulesVector = new IntegerVector();
|
---|
49 | }
|
---|
50 | public PRVEncoding(IntegerVector iv, int nrOfRules)
|
---|
51 | : base() {
|
---|
52 | this.NrOfRules = nrOfRules;
|
---|
53 | this.PriorityRulesVector = (IntegerVector)iv.Clone();
|
---|
54 | }
|
---|
55 | public PRVEncoding(int length, IRandom random, int min, int max, int nrOfRules)
|
---|
56 | : base() {
|
---|
57 | this.NrOfRules = nrOfRules;
|
---|
58 | this.PriorityRulesVector = new IntegerVector(length, random, min, max);
|
---|
59 | }
|
---|
60 |
|
---|
61 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
62 | return new PRVEncoding(this, cloner);
|
---|
63 | }
|
---|
64 |
|
---|
65 | public override string ToString() {
|
---|
66 | StringBuilder sb = new StringBuilder();
|
---|
67 | sb.Append("[ ");
|
---|
68 |
|
---|
69 | foreach (int i in PriorityRulesVector) {
|
---|
70 | sb.Append(i + " ");
|
---|
71 | }
|
---|
72 |
|
---|
73 | sb.Append("]");
|
---|
74 | return sb.ToString();
|
---|
75 | }
|
---|
76 | }
|
---|
77 | }
|
---|