source: branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/GQAPAssignmentArchiveView.cs @ 7418

Last change on this file since 7418 was 7418, checked in by abeham, 9 years ago

#1614

  • Added shaking operator based on n-moves
  • Added pareto analyzer regarding flowdistance and installation qualities
File size: 3.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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.ComponentModel;
24using System.Windows.Forms;
25using HeuristicLab.Collections;
26using HeuristicLab.Core.Views;
27using HeuristicLab.MainForm;
28using HeuristicLab.MainForm.WindowsForms;
29
30namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views {
31  [View("GQAPAssignmentArchiveView")]
32  [Content(typeof(GQAPAssignmentArchive), IsDefaultView = true)]
33  public partial class GQAPAssignmentArchiveView : ItemView {
34    public new GQAPAssignmentArchive Content {
35      get { return (GQAPAssignmentArchive)base.Content; }
36      set { base.Content = value; }
37    }
38
39    public GQAPAssignmentArchiveView() {
40      InitializeComponent();
41    }
42
43    #region Register Content Events
44    protected override void DeregisterContentEvents() {
45      Content.PropertyChanged -= new PropertyChangedEventHandler(Content_PropertyChanged);
46      Content.Solutions.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<GQAPSolution>>(ContentSolutions_Changed);
47      Content.Solutions.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<GQAPSolution>>(ContentSolutions_Changed);
48      Content.Solutions.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<GQAPSolution>>(ContentSolutions_Changed);
49      base.DeregisterContentEvents();
50    }
51    protected override void RegisterContentEvents() {
52      base.RegisterContentEvents();
53      Content.PropertyChanged += new PropertyChangedEventHandler(Content_PropertyChanged);
54      Content.Solutions.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<GQAPSolution>>(ContentSolutions_Changed);
55      Content.Solutions.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<GQAPSolution>>(ContentSolutions_Changed);
56      Content.Solutions.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<GQAPSolution>>(ContentSolutions_Changed);
57    }
58
59    private void ContentSolutions_Changed(object sender, CollectionItemsChangedEventArgs<IndexedItem<GQAPSolution>> e) {
60      UpdateParetoFront();
61    }
62
63    private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) {
64      UpdateParetoFront();
65    }
66    #endregion
67
68    protected override void OnContentChanged() {
69      base.OnContentChanged();
70      UpdateParetoFront();
71    }
72
73    protected override void SetEnabledStateOfControls() {
74      base.SetEnabledStateOfControls();
75    }
76
77    private void UpdateParetoFront() {
78      if (InvokeRequired) Invoke((Action)UpdateParetoFront);
79      else {
80        paretoFrontChart.Series[0].Points.SuspendUpdates();
81        try {
82          paretoFrontChart.Series[0].Points.Clear();
83          if (Content == null) return;
84          foreach (var solution in Content.Solutions) {
85            if (solution.OverbookedCapacity.Value <= 0.0)
86              paretoFrontChart.Series[0].Points.AddXY(solution.FlowDistanceQuality.Value, solution.InstallationQuality.Value);
87          }
88        } finally {
89          paretoFrontChart.Series[0].Points.ResumeUpdates();
90          messageLabel.Visible = paretoFrontChart.Series[0].Points.Count == 0;
91        }
92      }
93    }
94  }
95}
Note: See TracBrowser for help on using the repository browser.