Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Scheduling.JSSP/3.2/TimeSlot.cs @ 1875

Last change on this file since 1875 was 1530, checked in by gkronber, 16 years ago

Moved source files of plugins Hive ... Visualization.Test into version-specific sub-folders. #576

File size: 2.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 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;
23using System.Collections.Generic;
24using System.Text;
25using HeuristicLab.Data;
26
27namespace HeuristicLab.Scheduling.JSSP {
28  public class TimeSlot {
29    public int start;
30    public int end;
31    public int free;
32    public int maxFreeSlot;
33    public int job {
34      get {
35        if (operation != null) {
36          return operation.Job;
37        } else {
38          return -1;
39        }
40      }
41    }
42    public Operation operation;
43    public List<TimeSlot> dependentSlots;
44    public TimeSlot parent;
45
46    public TimeSlot(int start, int end) {
47      this.start = start;
48      this.end = end;
49      free = end - start;
50      maxFreeSlot = end - start;
51      dependentSlots = new List<TimeSlot>();
52    }
53
54    public TimeSlot(Operation op) {
55      operation = (Operation) op.Clone();
56      start = op.Start;
57      end = op.Start + op.Duration;
58      free = 0;
59      maxFreeSlot = 0;
60      dependentSlots = new List<TimeSlot>();
61    }
62
63    public TimeSlot(string s) {
64      string[] tokens = s.Split(',');
65      start = int.Parse(tokens[1]);
66      end = int.Parse(tokens[2]);
67      free = int.Parse(tokens[3]);
68      maxFreeSlot = int.Parse(tokens[4]);
69      int job = int.Parse(tokens[0]);
70      if (job != -1) {
71        int opIndex = int.Parse(tokens[5]);
72        int[] machines = new int[tokens.Length - 5];
73        for(int i = 0; i < tokens.Length - 5; i++) {
74          machines[i] = int.Parse(tokens[i]);
75        }
76        operation = new Operation(job, start, end - start, opIndex, machines, null);
77      }
78      dependentSlots = new List<TimeSlot>();
79    }
80
81    public override string ToString() {
82      StringBuilder builder = new StringBuilder();
83      builder.Append(String.Format("{2},{0},{1},{3},{4}", start, end, job, free, maxFreeSlot));
84      if(operation != null) {
85        builder.Append(String.Format(",{0}", operation.OperationIndex));
86        for (int i = 0; i < operation.Machines.Length; i++) {
87          builder.Append(String.Format(",{0}", operation.Machines[i]));
88        }
89      }
90      return builder.ToString();
91    }
92  }
93}
Note: See TracBrowser for help on using the repository browser.