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