Free cookie consent management tool by TermsFeed Policy Generator

source: branches/dataset-ids-2695/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PRVEncoding.cs @ 15529

Last change on this file since 15529 was 14185, checked in by swagner, 8 years ago

#2526: Updated year of copyrights in license headers

File size: 2.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 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 System.Text;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Encodings.IntegerVectorEncoding;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace 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}
Note: See TracBrowser for help on using the repository browser.