[6121] | 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;
|
---|
| 23 | using System.Windows.Forms;
|
---|
| 24 | using HeuristicLab.Core;
|
---|
| 25 | using HeuristicLab.Core.Views;
|
---|
[6475] | 26 | using HeuristicLab.Encodings.ScheduleEncoding;
|
---|
[6121] | 27 | using HeuristicLab.MainForm;
|
---|
| 28 | using HeuristicLab.PluginInfrastructure;
|
---|
| 29 |
|
---|
| 30 | namespace HeuristicLab.Problems.Scheduling.Views {
|
---|
| 31 | [View("JobShop Scheduling Problem View")]
|
---|
| 32 | [Content(typeof(JobShopSchedulingProblem), true)]
|
---|
| 33 | public partial class JobShopSchedulingProblemView : NamedItemView {
|
---|
| 34 | public JobShopSchedulingProblemView() {
|
---|
| 35 | InitializeComponent();
|
---|
| 36 | }
|
---|
| 37 | private SchedulingProblemImportDialog spImportDialog;
|
---|
| 38 |
|
---|
| 39 | public new JobShopSchedulingProblem Content {
|
---|
| 40 | get { return (JobShopSchedulingProblem)base.Content; }
|
---|
| 41 | set { base.Content = value; }
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | protected override void OnContentChanged() {
|
---|
| 45 | base.OnContentChanged();
|
---|
| 46 | if (Content == null) {
|
---|
| 47 | parameterCollectionView.Content = null;
|
---|
[6177] | 48 | ganttChart.Reset();
|
---|
[6121] | 49 | } else {
|
---|
| 50 | parameterCollectionView.Content = ((IParameterizedNamedItem)Content).Parameters;
|
---|
[6177] | 51 | FillGanttChart(Content);
|
---|
[6121] | 52 | }
|
---|
| 53 | }
|
---|
| 54 |
|
---|
[6177] | 55 | private void FillGanttChart(JobShopSchedulingProblem content) {
|
---|
| 56 | //Add Jobs as Categories
|
---|
[6260] | 57 | ganttChart.Reset();
|
---|
[6177] | 58 | int jobCount = 0;
|
---|
[6260] | 59 | Random random = new Random(1);
|
---|
[6294] | 60 | foreach (Job j in content.JobData) {
|
---|
| 61 | double lastEndTime = 0;
|
---|
| 62 | foreach (Task t in content.JobData[jobCount].Tasks) {
|
---|
[6412] | 63 | int categoryNr = t.JobNr;
|
---|
[6260] | 64 | string categoryName = "Job" + categoryNr;
|
---|
[6177] | 65 | ganttChart.AddData(categoryName,
|
---|
[6260] | 66 | categoryNr,
|
---|
[6482] | 67 | t.TaskNr,
|
---|
[6294] | 68 | lastEndTime + 1,
|
---|
[6412] | 69 | lastEndTime + t.Duration,
|
---|
| 70 | "Job" + t.JobNr + " - " + "Task#" + t.TaskNr.ToString());
|
---|
| 71 | lastEndTime += t.Duration;
|
---|
[6177] | 72 | }
|
---|
| 73 | jobCount++;
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 |
|
---|
[6121] | 77 | protected override void SetEnabledStateOfControls() {
|
---|
| 78 | base.SetEnabledStateOfControls();
|
---|
| 79 | parameterCollectionView.Enabled = Content != null;
|
---|
| 80 | importButton.Enabled = Content != null && !ReadOnly;
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | private void importButton_Click(object sender, EventArgs e) {
|
---|
| 84 | if (spImportDialog == null) spImportDialog = new SchedulingProblemImportDialog();
|
---|
| 85 |
|
---|
| 86 | if (spImportDialog.ShowDialog(this) == DialogResult.OK) {
|
---|
| 87 | try {
|
---|
| 88 | switch (spImportDialog.Format) {
|
---|
| 89 | case SPFormat.ORLib:
|
---|
| 90 | Content.ImportFromORLibrary(spImportDialog.SPFileName);
|
---|
| 91 | break;
|
---|
| 92 | }
|
---|
| 93 |
|
---|
[6260] | 94 |
|
---|
[6121] | 95 | if (!string.IsNullOrEmpty(spImportDialog.OptimalScheduleFileName))
|
---|
[6260] | 96 | Content.ImportJSMSolution(spImportDialog.OptimalScheduleFileName);
|
---|
[6177] | 97 | OnContentChanged();
|
---|
[6121] | 98 | }
|
---|
| 99 | catch (Exception ex) {
|
---|
| 100 | ErrorHandling.ShowErrorDialog(this, ex);
|
---|
| 101 | }
|
---|
| 102 | }
|
---|
| 103 | }
|
---|
| 104 | }
|
---|
| 105 | }
|
---|