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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Text;
|
---|
25 | using HeuristicLab.Data;
|
---|
26 |
|
---|
27 | namespace 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 |
|
---|
44 | public TimeSlot(int start, int end) {
|
---|
45 | this.start = start;
|
---|
46 | this.end = end;
|
---|
47 | free = end - start;
|
---|
48 | maxFreeSlot = end - start;
|
---|
49 | }
|
---|
50 |
|
---|
51 | public TimeSlot(Operation op) {
|
---|
52 | operation = (Operation) op.Clone();
|
---|
53 | start = op.Start;
|
---|
54 | end = op.Start + op.Duration;
|
---|
55 | free = 0;
|
---|
56 | maxFreeSlot = 0;
|
---|
57 | }
|
---|
58 |
|
---|
59 | public TimeSlot(string s) {
|
---|
60 | string[] tokens = s.Split(',');
|
---|
61 | start = int.Parse(tokens[1]);
|
---|
62 | end = int.Parse(tokens[2]);
|
---|
63 | free = int.Parse(tokens[3]);
|
---|
64 | maxFreeSlot = int.Parse(tokens[4]);
|
---|
65 | int job = int.Parse(tokens[0]);
|
---|
66 | if (job != -1) {
|
---|
67 | int opIndex = int.Parse(tokens[5]);
|
---|
68 | int[] machines = new int[tokens.Length - 5];
|
---|
69 | for(int i = 0; i < tokens.Length - 5; i++) {
|
---|
70 | machines[i] = int.Parse(tokens[i]);
|
---|
71 | }
|
---|
72 | operation = new Operation(job, start, end - start, opIndex, machines, null);
|
---|
73 | }
|
---|
74 | }
|
---|
75 |
|
---|
76 | public override string ToString() {
|
---|
77 | StringBuilder builder = new StringBuilder();
|
---|
78 | builder.Append(String.Format("{2},{0},{1},{3},{4}", start, end, job, free, maxFreeSlot));
|
---|
79 | if(operation != null) {
|
---|
80 | builder.Append(String.Format(",{0}", operation.OperationIndex));
|
---|
81 | for (int i = 0; i < operation.Machines.Length; i++) {
|
---|
82 | builder.Append(String.Format(",{0}", operation.Machines[i]));
|
---|
83 | }
|
---|
84 | }
|
---|
85 | return builder.ToString();
|
---|
86 | }
|
---|
87 | }
|
---|
88 | }
|
---|