1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2011 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 |
|
---|
45 | [StorableConstructor]
|
---|
46 | protected PRVEncoding(bool deserializing) : base(deserializing) { }
|
---|
47 | protected PRVEncoding(PRVEncoding original, Cloner cloner)
|
---|
48 | : base(original, cloner) {
|
---|
49 | this.nrOfRules = cloner.Clone(original.NrOfRules);
|
---|
50 | this.PriorityRulesVector = cloner.Clone(original.PriorityRulesVector);
|
---|
51 | }
|
---|
52 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
53 | return new PRVEncoding(this, cloner);
|
---|
54 | }
|
---|
55 | public PRVEncoding(int nrOfRules)
|
---|
56 | : base() {
|
---|
57 | this.nrOfRules = new IntValue(nrOfRules);
|
---|
58 | this.PriorityRulesVector = new IntegerVector();
|
---|
59 | }
|
---|
60 | public PRVEncoding(IntegerVector iv, IntValue nrOfRules)
|
---|
61 | : base() {
|
---|
62 | this.nrOfRules = (IntValue)nrOfRules.Clone();
|
---|
63 | this.PriorityRulesVector = (IntegerVector)iv.Clone();
|
---|
64 | }
|
---|
65 | public PRVEncoding(int length, IRandom random, int min, int max, IntValue nrOfRules)
|
---|
66 | : base() {
|
---|
67 | this.nrOfRules = (IntValue)nrOfRules.Clone();
|
---|
68 | this.PriorityRulesVector = new IntegerVector(length, random, min, max);
|
---|
69 | }
|
---|
70 |
|
---|
71 |
|
---|
72 | public override string ToString() {
|
---|
73 | StringBuilder sb = new StringBuilder();
|
---|
74 | sb.Append("[ ");
|
---|
75 |
|
---|
76 | foreach (int i in PriorityRulesVector) {
|
---|
77 | sb.Append(i.ToString() + " ");
|
---|
78 | }
|
---|
79 |
|
---|
80 | sb.Append("]");
|
---|
81 | return sb.ToString();
|
---|
82 | }
|
---|
83 | }
|
---|
84 | }
|
---|