Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PRVEncoding.cs @ 13437

Last change on this file since 13437 was 13437, checked in by mkommend, 9 years ago

#2521: Added encodings for schedules.

File size: 2.6 KB
Line 
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
22using System.Text;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Encodings.IntegerVectorEncoding;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace 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}
Note: See TracBrowser for help on using the repository browser.