Changeset 6952
- Timestamp:
- 11/06/11 20:47:56 (13 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 deleted
- 5 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/HeuristicLab.Problems.QuadraticAssignment.Views-3.3.csproj
r6891 r6952 212 212 </ProjectReference> 213 213 </ItemGroup> 214 <ItemGroup>215 <WCFMetadata Include="Service References\" />216 </ItemGroup>217 214 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 218 215 <PropertyGroup> -
trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QuadraticAssignmentProblemView.Designer.cs
r6891 r6952 54 54 this.visualizationTabPage = new System.Windows.Forms.TabPage(); 55 55 this.qapView = new HeuristicLab.Problems.QuadraticAssignment.Views.QAPVisualizationControl(); 56 this.reloadInstancesButton = new System.Windows.Forms.Button();57 this.loadInstanceWorker = new System.ComponentModel.BackgroundWorker();58 this.progressBar = new System.Windows.Forms.ProgressBar();59 this.getInstancesWorker = new System.ComponentModel.BackgroundWorker();60 56 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 61 57 this.tabControl.SuspendLayout(); … … 94 90 this.toolTip.SetToolTip(this.importInstanceButton, "Import files in QAPLIB format."); 95 91 this.importInstanceButton.UseVisualStyleBackColor = true; 96 this.importInstanceButton.Click += new System.EventHandler(this.import FileInstanceButton_Click);92 this.importInstanceButton.Click += new System.EventHandler(this.importInstanceButton_Click); 97 93 // 98 94 // openFileDialog … … 124 120 this.instancesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 125 121 this.instancesComboBox.FormattingEnabled = true; 126 this.instancesComboBox.Location = new System.Drawing.Point(1 37, 1);122 this.instancesComboBox.Location = new System.Drawing.Point(105, 2); 127 123 this.instancesComboBox.Name = "instancesComboBox"; 128 this.instancesComboBox.Size = new System.Drawing.Size(3 26, 21);124 this.instancesComboBox.Size = new System.Drawing.Size(358, 21); 129 125 this.instancesComboBox.TabIndex = 7; 130 126 this.instancesComboBox.SelectedValueChanged += new System.EventHandler(this.instancesComboBox_SelectedValueChanged); … … 188 184 this.qapView.Weights = null; 189 185 // 190 // reloadInstancesButton191 //192 this.reloadInstancesButton.Location = new System.Drawing.Point(105, 0);193 this.reloadInstancesButton.Name = "reloadInstancesButton";194 this.reloadInstancesButton.Size = new System.Drawing.Size(26, 23);195 this.reloadInstancesButton.TabIndex = 9;196 this.reloadInstancesButton.Text = "Reload";197 this.reloadInstancesButton.UseVisualStyleBackColor = true;198 this.reloadInstancesButton.Click += new System.EventHandler(this.reloadInstancesButton_Click);199 //200 // loadInstanceWorker201 //202 this.loadInstanceWorker.WorkerReportsProgress = true;203 this.loadInstanceWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.loadInstanceWorker_DoWork);204 this.loadInstanceWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.worker_ProgressChanged);205 this.loadInstanceWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.worker_RunWorkerCompleted);206 //207 // progressBar208 //209 this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)210 | System.Windows.Forms.AnchorStyles.Right)));211 this.progressBar.Location = new System.Drawing.Point(137, 0);212 this.progressBar.Name = "progressBar";213 this.progressBar.Size = new System.Drawing.Size(326, 23);214 this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;215 this.progressBar.TabIndex = 10;216 this.progressBar.Visible = false;217 //218 // getInstancesWorker219 //220 this.getInstancesWorker.WorkerReportsProgress = true;221 this.getInstancesWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.getInstancesWorker_DoWork);222 this.getInstancesWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.worker_ProgressChanged);223 this.getInstancesWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.worker_RunWorkerCompleted);224 //225 186 // QuadraticAssignmentProblemView 226 187 // 227 188 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 228 189 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 229 this.Controls.Add(this.progressBar);230 190 this.Controls.Add(this.instancesComboBox); 231 191 this.Controls.Add(this.tabControl); 232 192 this.Controls.Add(this.importInstanceButton); 233 193 this.Controls.Add(this.loadInstanceButton); 234 this.Controls.Add(this.reloadInstancesButton);235 194 this.Controls.Add(this.QAPLIBInstancesLabel); 236 195 this.Name = "QuadraticAssignmentProblemView"; 237 196 this.Size = new System.Drawing.Size(647, 492); 238 197 this.Controls.SetChildIndex(this.QAPLIBInstancesLabel, 0); 239 this.Controls.SetChildIndex(this.reloadInstancesButton, 0);240 198 this.Controls.SetChildIndex(this.loadInstanceButton, 0); 241 199 this.Controls.SetChildIndex(this.importInstanceButton, 0); … … 246 204 this.Controls.SetChildIndex(this.nameLabel, 0); 247 205 this.Controls.SetChildIndex(this.nameTextBox, 0); 248 this.Controls.SetChildIndex(this.progressBar, 0);249 206 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 250 207 this.tabControl.ResumeLayout(false); … … 266 223 private System.Windows.Forms.TabPage visualizationTabPage; 267 224 private QAPVisualizationControl qapView; 268 private System.Windows.Forms.Button reloadInstancesButton;269 private System.ComponentModel.BackgroundWorker loadInstanceWorker;270 private System.Windows.Forms.ProgressBar progressBar;271 private System.ComponentModel.BackgroundWorker getInstancesWorker;272 225 } 273 226 } -
trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QuadraticAssignmentProblemView.cs
r6891 r6952 21 21 22 22 using System; 23 using System.ComponentModel;24 23 using System.Drawing; 25 using System. Linq;24 using System.IO; 26 25 using System.Windows.Forms; 27 26 using HeuristicLab.Common.Resources; 28 using HeuristicLab.Core;29 27 using HeuristicLab.Core.Views; 30 using HeuristicLab.Data;31 using HeuristicLab.Encodings.PermutationEncoding;32 28 using HeuristicLab.MainForm; 33 29 using HeuristicLab.MainForm.WindowsForms; 34 using HeuristicLab.Problems.QuadraticAssignment.QAPInstanceService;35 30 36 31 namespace HeuristicLab.Problems.QuadraticAssignment.Views { … … 46 41 InitializeComponent(); 47 42 importInstanceButton.Image = VSImageLibrary.Open; 48 reloadInstancesButton.Text = String.Empty;49 reloadInstancesButton.Image = VSImageLibrary.Refresh;50 loadInstanceButton.Image = VSImageLibrary.Internet;51 43 Controls.Remove(parameterCollectionView); 52 44 parameterCollectionView.Dock = DockStyle.Fill; … … 59 51 Content.WeightsParameter.ValueChanged += new EventHandler(WeightsParameter_ValueChanged); 60 52 Content.BestKnownSolutionParameter.ValueChanged += new EventHandler(BestKnownSolutionParameter_ValueChanged); 61 Content.Instances.ItemsAdded += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);62 Content.Instances.ItemsMoved += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);63 Content.Instances.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);64 Content.Instances.ItemsReplaced += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);65 Content.Instances.CollectionReset += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);66 53 } 67 54 … … 70 57 Content.WeightsParameter.ValueChanged -= new EventHandler(WeightsParameter_ValueChanged); 71 58 Content.BestKnownSolutionParameter.ValueChanged -= new EventHandler(BestKnownSolutionParameter_ValueChanged); 72 Content.Instances.ItemsAdded -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);73 Content.Instances.ItemsMoved -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);74 Content.Instances.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);75 Content.Instances.ItemsReplaced -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);76 Content.Instances.CollectionReset -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<string>>(Content_Instances_Changed);77 59 base.DeregisterContentEvents(); 78 }79 80 private void Content_Instances_Changed(object sender, EventArgs e) {81 instancesComboBox.Items.Clear();82 foreach (string name in Content.Instances)83 instancesComboBox.Items.Add(name);84 if (instancesComboBox.Items.Count > 0)85 instancesComboBox.SelectedIndex = 0;86 60 } 87 61 … … 100 74 protected override void OnContentChanged() { 101 75 base.OnContentChanged(); 76 instancesComboBox.Items.Clear(); 102 77 if (Content != null) { 78 foreach (string instance in Content.Instances) { 79 instancesComboBox.Items.Add(instance); 80 } 103 81 qapView.Distances = Content.Distances; 104 82 qapView.Weights = Content.Weights; … … 113 91 protected override void SetEnabledStateOfControls() { 114 92 base.SetEnabledStateOfControls(); 115 reloadInstancesButton.Enabled = !ReadOnly && !Locked && Content != null;116 93 instancesComboBox.Enabled = !ReadOnly && !Locked && Content != null; 117 loadInstanceButton.Enabled = !ReadOnly && !Locked && Content != null && !String.IsNullOrEmpty((string)instancesComboBox.SelectedItem);94 loadInstanceButton.Enabled = !ReadOnly && !Locked && Content != null && instancesComboBox.SelectedItem != null; 118 95 importInstanceButton.Enabled = !ReadOnly && !Locked && Content != null; 119 96 } 120 97 121 98 private void instancesComboBox_SelectedValueChanged(object sender, System.EventArgs e) { 122 SetEnabledStateOfControls();99 loadInstanceButton.Enabled = instancesComboBox.SelectedItem != null; 123 100 } 124 101 125 102 private void loadInstanceButton_Click(object sender, System.EventArgs e) { 126 ReadOnly = true; 127 string instanceStr = instancesComboBox.SelectedItem as string; 128 progressBar.Visible = true; 129 loadInstanceWorker.RunWorkerAsync(instanceStr); 103 string instance = instancesComboBox.SelectedItem as string; 104 try { 105 Content.LoadInstanceFromEmbeddedResource(instance); 106 } catch (Exception ex) { 107 PluginInfrastructure.ErrorHandling.ShowErrorDialog(ex); 108 } 130 109 } 131 110 132 private void import FileInstanceButton_Click(object sender, System.EventArgs e) {111 private void importInstanceButton_Click(object sender, System.EventArgs e) { 133 112 if (openFileDialog.ShowDialog() == DialogResult.OK) { 134 113 try { 135 Content.LoadInstanceFromFile(openFileDialog.FileName); 114 string datFile = openFileDialog.FileName; 115 string directory = Path.GetDirectoryName(datFile); 116 string solFile = Path.Combine(directory, Path.GetFileNameWithoutExtension(datFile) + ".sln"); 117 if (File.Exists(solFile)) { 118 Content.LoadInstanceFromFile(datFile, solFile); 119 } else { 120 Content.LoadInstanceFromFile(datFile); 121 } 136 122 } catch (Exception ex) { 137 123 PluginInfrastructure.ErrorHandling.ShowErrorDialog(ex); 138 124 } 139 125 } 140 }141 142 private void reloadInstancesButton_Click(object sender, EventArgs e) {143 ReadOnly = true;144 progressBar.Visible = true;145 getInstancesWorker.RunWorkerAsync();146 }147 148 private void loadInstanceWorker_DoWork(object sender, DoWorkEventArgs e) {149 string instance = (string)e.Argument;150 if (String.IsNullOrEmpty(instance)) return;151 using (var client = new QAPClient()) {152 loadInstanceWorker.ReportProgress(10);153 var data = client.GetProblemInstanceData(instance);154 loadInstanceWorker.ReportProgress(60);155 DoubleMatrix weights = new DoubleMatrix(data.Weights.Length, data.Weights.Length);156 DoubleMatrix distances = new DoubleMatrix(data.Weights.Length, data.Weights.Length);157 try {158 for (int i = 0; i < data.Weights.Length; i++)159 for (int j = 0; j < data.Weights.Length; j++) {160 weights[i, j] = data.Weights[i][j];161 distances[i, j] = data.Distances[i][j];162 }163 } catch (IndexOutOfRangeException) {164 MessageBox.Show("The problem data is malformed, the problem could not be loaded.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);165 }166 loadInstanceWorker.ReportProgress(65);167 Content.Name = data.Name;168 Content.Description = data.Description;169 Content.Maximization.Value = data.Maximization;170 Content.Weights = weights;171 Content.Distances = distances;172 173 Content.BestKnownQualityParameter.Value = null;174 Content.BestKnownSolution = null;175 Content.BestKnownSolutions = new ItemSet<Permutation>();176 var solutions = client.GetBestSolutionsData(instance);177 loadInstanceWorker.ReportProgress(90);178 if (solutions.Any()) {179 Content.BestKnownQualityParameter.Value = new DoubleValue(solutions.First().Quality);180 Content.BestKnownSolution = new Permutation(PermutationTypes.Absolute, solutions.First().Assignment);181 foreach (var solution in solutions) {182 Content.BestKnownSolutions.Add(new Permutation(PermutationTypes.Absolute, solution.Assignment));183 }184 }185 loadInstanceWorker.ReportProgress(100);186 }187 }188 189 private void getInstancesWorker_DoWork(object sender, DoWorkEventArgs e) {190 using (var client = new QAPClient()) {191 getInstancesWorker.ReportProgress(10);192 var instances = client.GetProblemInstances();193 getInstancesWorker.ReportProgress(85);194 Content.Instances.Replace(instances);195 getInstancesWorker.ReportProgress(100);196 }197 }198 199 private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e) {200 progressBar.Value = e.ProgressPercentage;201 }202 203 private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {204 progressBar.Visible = false;205 ReadOnly = false;206 if (e.Error != null)207 PluginInfrastructure.ErrorHandling.ShowErrorDialog(e.Error);208 126 } 209 127 -
trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/Data
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/branches/GP.Grammar.Editor/HeuristicLab.Problems.QuadraticAssignment/3.3/Data merged eligible /branches/CloningRefactoring/HeuristicLab.Problems.QuadraticAssignment/3.3/Data 4656-4721 /branches/DataAnalysis Refactoring/HeuristicLab.Problems.QuadraticAssignment/3.3/Data 5471-5808 /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Problems.QuadraticAssignment/3.3/Data 5815-6180 /branches/DataAnalysis/HeuristicLab.Problems.QuadraticAssignment/3.3/Data 4458-4459,4462,4464 /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.QuadraticAssignment/3.3/Data 5060 /branches/NET40/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/Data 5138-5162 /branches/ParallelEngine/HeuristicLab.Problems.QuadraticAssignment/3.3/Data 5175-5192 /branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/Data 6350-6627 /branches/Restructure trunk solution/HeuristicLab.Problems.QuadraticAssignment/3.3/Data 6828 /branches/SuccessProgressAnalysis/HeuristicLab.Problems.QuadraticAssignment/3.3/Data 5370-5682 /branches/Trunk/HeuristicLab.Problems.QuadraticAssignment/3.3/Data 6829-6865 /branches/VNS/HeuristicLab.Problems.QuadraticAssignment/3.3/Data 5594-5752 /branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/Data 5959-6341
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/HeuristicLab.Problems.QuadraticAssignment-3.3.csproj
r6891 r6952 130 130 <Compile Include="QAPPermutationProximityCalculator.cs" /> 131 131 <Compile Include="QuadraticAssignmentProblem.cs" /> 132 <Compile Include="Service References\QAPInstanceService\Reference.cs"> 133 <AutoGen>True</AutoGen> 134 <DesignTime>True</DesignTime> 135 <DependentUpon>Reference.svcmap</DependentUpon> 136 </Compile> 137 <None Include="app.config" /> 132 <EmbeddedResource Include="Data\bur26a.dat" /> 133 <EmbeddedResource Include="Data\bur26b.dat" /> 134 <EmbeddedResource Include="Data\bur26c.dat" /> 135 <EmbeddedResource Include="Data\bur26d.dat" /> 136 <EmbeddedResource Include="Data\bur26e.dat" /> 137 <EmbeddedResource Include="Data\bur26f.dat" /> 138 <EmbeddedResource Include="Data\bur26g.dat" /> 139 <EmbeddedResource Include="Data\bur26h.dat" /> 140 <EmbeddedResource Include="Data\chr12a.dat" /> 141 <EmbeddedResource Include="Data\chr12b.dat" /> 142 <EmbeddedResource Include="Data\chr12c.dat" /> 143 <EmbeddedResource Include="Data\chr15a.dat" /> 144 <EmbeddedResource Include="Data\chr15b.dat" /> 145 <EmbeddedResource Include="Data\chr15c.dat" /> 146 <EmbeddedResource Include="Data\chr18a.dat" /> 147 <EmbeddedResource Include="Data\chr18b.dat" /> 148 <EmbeddedResource Include="Data\chr20a.dat" /> 149 <EmbeddedResource Include="Data\chr20b.dat" /> 150 <EmbeddedResource Include="Data\chr20c.dat" /> 151 <EmbeddedResource Include="Data\chr22a.dat" /> 152 <EmbeddedResource Include="Data\chr22b.dat" /> 153 <EmbeddedResource Include="Data\chr25a.dat" /> 154 <EmbeddedResource Include="Data\els19.dat" /> 155 <EmbeddedResource Include="Data\esc128.dat" /> 156 <EmbeddedResource Include="Data\esc16a.dat" /> 157 <EmbeddedResource Include="Data\esc16b.dat" /> 158 <EmbeddedResource Include="Data\esc16c.dat" /> 159 <EmbeddedResource Include="Data\esc16d.dat" /> 160 <EmbeddedResource Include="Data\esc16e.dat" /> 161 <EmbeddedResource Include="Data\esc16f.dat" /> 162 <EmbeddedResource Include="Data\esc16g.dat" /> 163 <EmbeddedResource Include="Data\esc16h.dat" /> 164 <EmbeddedResource Include="Data\esc16i.dat" /> 165 <EmbeddedResource Include="Data\esc16j.dat" /> 166 <EmbeddedResource Include="Data\esc32a.dat" /> 167 <EmbeddedResource Include="Data\esc32b.dat" /> 168 <EmbeddedResource Include="Data\esc32c.dat" /> 169 <EmbeddedResource Include="Data\esc32d.dat" /> 170 <EmbeddedResource Include="Data\esc32e.dat" /> 171 <EmbeddedResource Include="Data\esc32f.dat" /> 172 <EmbeddedResource Include="Data\esc32g.dat" /> 173 <EmbeddedResource Include="Data\esc32h.dat" /> 174 <EmbeddedResource Include="Data\esc64a.dat" /> 175 <EmbeddedResource Include="Data\had12.dat" /> 176 <EmbeddedResource Include="Data\had14.dat" /> 177 <EmbeddedResource Include="Data\had16.dat" /> 178 <EmbeddedResource Include="Data\had18.dat" /> 179 <EmbeddedResource Include="Data\had20.dat" /> 180 <EmbeddedResource Include="Data\kra30a.dat" /> 181 <EmbeddedResource Include="Data\kra30b.dat" /> 182 <EmbeddedResource Include="Data\kra32.dat" /> 183 <EmbeddedResource Include="Data\lipa20a.dat" /> 184 <EmbeddedResource Include="Data\lipa20b.dat" /> 185 <EmbeddedResource Include="Data\lipa30a.dat" /> 186 <EmbeddedResource Include="Data\lipa30b.dat" /> 187 <EmbeddedResource Include="Data\lipa40a.dat" /> 188 <EmbeddedResource Include="Data\lipa40b.dat" /> 189 <EmbeddedResource Include="Data\lipa50a.dat" /> 190 <EmbeddedResource Include="Data\lipa50b.dat" /> 191 <EmbeddedResource Include="Data\lipa60a.dat" /> 192 <EmbeddedResource Include="Data\lipa60b.dat" /> 193 <EmbeddedResource Include="Data\lipa70a.dat" /> 194 <EmbeddedResource Include="Data\lipa70b.dat" /> 195 <EmbeddedResource Include="Data\lipa80a.dat" /> 196 <EmbeddedResource Include="Data\lipa80b.dat" /> 197 <EmbeddedResource Include="Data\lipa90a.dat" /> 198 <EmbeddedResource Include="Data\lipa90b.dat" /> 199 <EmbeddedResource Include="Data\nug12.dat" /> 200 <EmbeddedResource Include="Data\nug14.dat" /> 201 <EmbeddedResource Include="Data\nug15.dat" /> 202 <EmbeddedResource Include="Data\nug16a.dat" /> 203 <EmbeddedResource Include="Data\nug16b.dat" /> 204 <EmbeddedResource Include="Data\nug17.dat" /> 205 <EmbeddedResource Include="Data\nug18.dat" /> 206 <EmbeddedResource Include="Data\nug20.dat" /> 207 <EmbeddedResource Include="Data\nug21.dat" /> 208 <EmbeddedResource Include="Data\nug22.dat" /> 209 <EmbeddedResource Include="Data\nug24.dat" /> 210 <EmbeddedResource Include="Data\nug25.dat" /> 211 <EmbeddedResource Include="Data\nug27.dat" /> 212 <EmbeddedResource Include="Data\nug28.dat" /> 213 <EmbeddedResource Include="Data\nug30.dat" /> 214 <EmbeddedResource Include="Data\rou12.dat" /> 215 <EmbeddedResource Include="Data\rou15.dat" /> 216 <EmbeddedResource Include="Data\rou20.dat" /> 217 <EmbeddedResource Include="Data\scr12.dat" /> 218 <EmbeddedResource Include="Data\scr15.dat" /> 219 <EmbeddedResource Include="Data\scr20.dat" /> 220 <EmbeddedResource Include="Data\sko100a.dat" /> 221 <EmbeddedResource Include="Data\sko100b.dat" /> 222 <EmbeddedResource Include="Data\sko100c.dat" /> 223 <EmbeddedResource Include="Data\sko100d.dat" /> 224 <EmbeddedResource Include="Data\sko100e.dat" /> 225 <EmbeddedResource Include="Data\sko100f.dat" /> 226 <EmbeddedResource Include="Data\sko42.dat" /> 227 <EmbeddedResource Include="Data\sko49.dat" /> 228 <EmbeddedResource Include="Data\sko56.dat" /> 229 <EmbeddedResource Include="Data\sko64.dat" /> 230 <EmbeddedResource Include="Data\sko72.dat" /> 231 <EmbeddedResource Include="Data\sko81.dat" /> 232 <EmbeddedResource Include="Data\sko90.dat" /> 233 <EmbeddedResource Include="Data\ste36a.dat" /> 234 <EmbeddedResource Include="Data\ste36b.dat" /> 235 <EmbeddedResource Include="Data\ste36c.dat" /> 236 <EmbeddedResource Include="Data\tai100a.dat" /> 237 <EmbeddedResource Include="Data\tai100b.dat" /> 238 <EmbeddedResource Include="Data\tai10a.dat" /> 239 <EmbeddedResource Include="Data\tai10b.dat" /> 240 <EmbeddedResource Include="Data\tai12a.dat" /> 241 <EmbeddedResource Include="Data\tai12b.dat" /> 242 <EmbeddedResource Include="Data\tai150b.dat" /> 243 <EmbeddedResource Include="Data\tai15a.dat" /> 244 <EmbeddedResource Include="Data\tai15b.dat" /> 245 <EmbeddedResource Include="Data\tai17a.dat" /> 246 <EmbeddedResource Include="Data\tai20a.dat" /> 247 <EmbeddedResource Include="Data\tai20b.dat" /> 248 <EmbeddedResource Include="Data\tai256c.dat" /> 249 <EmbeddedResource Include="Data\tai25a.dat" /> 250 <EmbeddedResource Include="Data\tai25b.dat" /> 251 <EmbeddedResource Include="Data\tai30a.dat" /> 252 <EmbeddedResource Include="Data\tai30b.dat" /> 253 <EmbeddedResource Include="Data\tai35a.dat" /> 254 <EmbeddedResource Include="Data\tai35b.dat" /> 255 <EmbeddedResource Include="Data\tai40a.dat" /> 256 <EmbeddedResource Include="Data\tai40b.dat" /> 257 <EmbeddedResource Include="Data\tai50a.dat" /> 258 <EmbeddedResource Include="Data\tai50b.dat" /> 259 <EmbeddedResource Include="Data\tai60a.dat" /> 260 <EmbeddedResource Include="Data\tai60b.dat" /> 261 <EmbeddedResource Include="Data\tai64c.dat" /> 262 <EmbeddedResource Include="Data\tai80a.dat" /> 263 <EmbeddedResource Include="Data\tai80b.dat" /> 264 <EmbeddedResource Include="Data\tho150.dat" /> 265 <EmbeddedResource Include="Data\tho30.dat" /> 266 <EmbeddedResource Include="Data\tho40.dat" /> 267 <EmbeddedResource Include="Data\wil100.dat" /> 268 <EmbeddedResource Include="Data\wil50.dat" /> 138 269 <None Include="Plugin.cs.frame" /> 139 270 <Compile Include="Plugin.cs" /> 140 271 <Compile Include="Properties\AssemblyInfo.cs" /> 141 272 <None Include="Properties\AssemblyInfo.cs.frame" /> 142 <None Include="Service References\QAPInstanceService\HeuristicLab.Problems.QuadraticAssignment.QAPInstanceService.QAPInstanceDto.datasource">143 <DependentUpon>Reference.svcmap</DependentUpon>144 </None>145 <None Include="Service References\QAPInstanceService\HeuristicLab.Problems.QuadraticAssignment.QAPInstanceService.QAPSolutionDto.datasource">146 <DependentUpon>Reference.svcmap</DependentUpon>147 </None>148 <None Include="Service References\QAPInstanceService\QAP.wsdl" />149 <None Include="Service References\QAPInstanceService\QAP.xsd">150 <SubType>Designer</SubType>151 </None>152 <None Include="Service References\QAPInstanceService\QAP1.xsd">153 <SubType>Designer</SubType>154 </None>155 <None Include="Service References\QAPInstanceService\QAP2.xsd">156 <SubType>Designer</SubType>157 </None>158 <None Include="Service References\QAPInstanceService\QAP3.xsd">159 <SubType>Designer</SubType>160 </None>161 273 </ItemGroup> 162 274 <ItemGroup> … … 226 338 </ItemGroup> 227 339 <ItemGroup> 228 <WCFMetadata Include="Service References\" /> 229 </ItemGroup> 230 <ItemGroup> 231 <WCFMetadataStorage Include="Service References\QAPInstanceService\" /> 232 </ItemGroup> 233 <ItemGroup> 234 <None Include="Service References\QAPInstanceService\QAP.disco" /> 235 </ItemGroup> 236 <ItemGroup> 237 <None Include="Service References\QAPInstanceService\configuration91.svcinfo" /> 238 </ItemGroup> 239 <ItemGroup> 240 <None Include="Service References\QAPInstanceService\configuration.svcinfo" /> 241 </ItemGroup> 242 <ItemGroup> 243 <None Include="Service References\QAPInstanceService\Reference.svcmap"> 244 <Generator>WCF Proxy Generator</Generator> 245 <LastGenOutput>Reference.cs</LastGenOutput> 246 </None> 340 <EmbeddedResource Include="Data\bur26a.sln" /> 341 <EmbeddedResource Include="Data\bur26b.sln" /> 342 <EmbeddedResource Include="Data\bur26c.sln" /> 343 <EmbeddedResource Include="Data\bur26d.sln" /> 344 <EmbeddedResource Include="Data\bur26e.sln" /> 345 <EmbeddedResource Include="Data\bur26f.sln" /> 346 <EmbeddedResource Include="Data\bur26g.sln" /> 347 <EmbeddedResource Include="Data\bur26h.sln" /> 348 <EmbeddedResource Include="Data\chr12a.sln" /> 349 <EmbeddedResource Include="Data\chr12b.sln" /> 350 <EmbeddedResource Include="Data\chr12c.sln" /> 351 <EmbeddedResource Include="Data\chr15a.sln" /> 352 <EmbeddedResource Include="Data\chr15b.sln" /> 353 <EmbeddedResource Include="Data\chr15c.sln" /> 354 <EmbeddedResource Include="Data\chr18a.sln" /> 355 <EmbeddedResource Include="Data\chr18b.sln" /> 356 <EmbeddedResource Include="Data\chr20a.sln" /> 357 <EmbeddedResource Include="Data\chr20b.sln" /> 358 <EmbeddedResource Include="Data\chr20c.sln" /> 359 <EmbeddedResource Include="Data\chr22a.sln" /> 360 <EmbeddedResource Include="Data\chr22b.sln" /> 361 <EmbeddedResource Include="Data\chr25a.sln" /> 362 <EmbeddedResource Include="Data\els19.sln" /> 363 <EmbeddedResource Include="Data\esc128.sln" /> 364 <EmbeddedResource Include="Data\esc16a.sln" /> 365 <EmbeddedResource Include="Data\esc16b.sln" /> 366 <EmbeddedResource Include="Data\esc16c.sln" /> 367 <EmbeddedResource Include="Data\esc16d.sln" /> 368 <EmbeddedResource Include="Data\esc16e.sln" /> 369 <EmbeddedResource Include="Data\esc16f.sln" /> 370 <EmbeddedResource Include="Data\esc16g.sln" /> 371 <EmbeddedResource Include="Data\esc16h.sln" /> 372 <EmbeddedResource Include="Data\esc16i.sln" /> 373 <EmbeddedResource Include="Data\esc16j.sln" /> 374 <EmbeddedResource Include="Data\esc32a.sln" /> 375 <EmbeddedResource Include="Data\esc32e.sln" /> 376 <EmbeddedResource Include="Data\esc32f.sln" /> 377 <EmbeddedResource Include="Data\esc32g.sln" /> 378 <EmbeddedResource Include="Data\had12.sln" /> 379 <EmbeddedResource Include="Data\had14.sln" /> 380 <EmbeddedResource Include="Data\had16.sln" /> 381 <EmbeddedResource Include="Data\had18.sln" /> 382 <EmbeddedResource Include="Data\had20.sln" /> 383 <EmbeddedResource Include="Data\kra30a.sln" /> 384 <EmbeddedResource Include="Data\kra30b.sln" /> 385 <EmbeddedResource Include="Data\kra32.sln" /> 386 <EmbeddedResource Include="Data\lipa20a.sln" /> 387 <EmbeddedResource Include="Data\lipa20b.sln" /> 388 <EmbeddedResource Include="Data\lipa30a.sln" /> 389 <EmbeddedResource Include="Data\lipa30b.sln" /> 390 <EmbeddedResource Include="Data\lipa40a.sln" /> 391 <EmbeddedResource Include="Data\lipa40b.sln" /> 392 <EmbeddedResource Include="Data\lipa50a.sln" /> 393 <EmbeddedResource Include="Data\lipa50b.sln" /> 394 <EmbeddedResource Include="Data\lipa60a.sln" /> 395 <EmbeddedResource Include="Data\lipa60b.sln" /> 396 <EmbeddedResource Include="Data\lipa70a.sln" /> 397 <EmbeddedResource Include="Data\lipa70b.sln" /> 398 <EmbeddedResource Include="Data\lipa80a.sln" /> 399 <EmbeddedResource Include="Data\lipa80b.sln" /> 400 <EmbeddedResource Include="Data\lipa90a.sln" /> 401 <EmbeddedResource Include="Data\lipa90b.sln" /> 402 <EmbeddedResource Include="Data\nug12.sln" /> 403 <EmbeddedResource Include="Data\nug14.sln" /> 404 <EmbeddedResource Include="Data\nug15.sln" /> 405 <EmbeddedResource Include="Data\nug16a.sln" /> 406 <EmbeddedResource Include="Data\nug16b.sln" /> 407 <EmbeddedResource Include="Data\nug17.sln" /> 408 <EmbeddedResource Include="Data\nug18.sln" /> 409 <EmbeddedResource Include="Data\nug20.sln" /> 410 <EmbeddedResource Include="Data\nug21.sln" /> 411 <EmbeddedResource Include="Data\nug22.sln" /> 412 <EmbeddedResource Include="Data\nug24.sln" /> 413 <EmbeddedResource Include="Data\nug25.sln" /> 414 <EmbeddedResource Include="Data\nug27.sln" /> 415 <EmbeddedResource Include="Data\nug28.sln" /> 416 <EmbeddedResource Include="Data\nug30.sln" /> 417 <EmbeddedResource Include="Data\rou12.sln" /> 418 <EmbeddedResource Include="Data\rou15.sln" /> 419 <EmbeddedResource Include="Data\rou20.sln" /> 420 <EmbeddedResource Include="Data\scr12.sln" /> 421 <EmbeddedResource Include="Data\scr15.sln" /> 422 <EmbeddedResource Include="Data\scr20.sln" /> 423 <EmbeddedResource Include="Data\sko100a.sln" /> 424 <EmbeddedResource Include="Data\sko100b.sln" /> 425 <EmbeddedResource Include="Data\sko100c.sln" /> 426 <EmbeddedResource Include="Data\sko100d.sln" /> 427 <EmbeddedResource Include="Data\sko100e.sln" /> 428 <EmbeddedResource Include="Data\sko100f.sln" /> 429 <EmbeddedResource Include="Data\sko49.sln" /> 430 <EmbeddedResource Include="Data\sko81.sln" /> 431 <EmbeddedResource Include="Data\sko90.sln" /> 432 <EmbeddedResource Include="Data\ste36a.sln" /> 433 <EmbeddedResource Include="Data\ste36b.sln" /> 434 <EmbeddedResource Include="Data\ste36c.sln" /> 435 <EmbeddedResource Include="Data\tai100a.sln" /> 436 <EmbeddedResource Include="Data\tai100b.sln" /> 437 <EmbeddedResource Include="Data\tai12a.sln" /> 438 <EmbeddedResource Include="Data\tai12b.sln" /> 439 <EmbeddedResource Include="Data\tai150b.sln" /> 440 <EmbeddedResource Include="Data\tai15a.sln" /> 441 <EmbeddedResource Include="Data\tai15b.sln" /> 442 <EmbeddedResource Include="Data\tai17a.sln" /> 443 <EmbeddedResource Include="Data\tai20a.sln" /> 444 <EmbeddedResource Include="Data\tai20b.sln" /> 445 <EmbeddedResource Include="Data\tai256c.sln" /> 446 <EmbeddedResource Include="Data\tai25a.sln" /> 447 <EmbeddedResource Include="Data\tai25b.sln" /> 448 <EmbeddedResource Include="Data\tai30b.sln" /> 449 <EmbeddedResource Include="Data\tai35b.sln" /> 450 <EmbeddedResource Include="Data\tai40b.sln" /> 451 <EmbeddedResource Include="Data\tai50a.sln" /> 452 <EmbeddedResource Include="Data\tai50b.sln" /> 453 <EmbeddedResource Include="Data\tai60a.sln" /> 454 <EmbeddedResource Include="Data\tai60b.sln" /> 455 <EmbeddedResource Include="Data\tai64c.sln" /> 456 <EmbeddedResource Include="Data\tai80a.sln" /> 457 <EmbeddedResource Include="Data\tai80b.sln" /> 458 <EmbeddedResource Include="Data\tho150.sln" /> 459 <EmbeddedResource Include="Data\tho30.sln" /> 460 <EmbeddedResource Include="Data\wil100.sln" /> 247 461 </ItemGroup> 248 462 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs
r6939 r6952 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Drawing; 24 25 using System.IO; 25 26 using System.Linq; 26 27 using System.Reflection; 27 using HeuristicLab.Collections;28 28 using HeuristicLab.Common; 29 29 using HeuristicLab.Core; … … 93 93 } 94 94 95 private ObservableList<string> instances = new ObservableList<string>(); 96 public ObservableList<string> Instances { 97 get { return instances; } 95 public IEnumerable<string> Instances { 96 get { 97 return Assembly.GetExecutingAssembly() 98 .GetManifestResourceNames() 99 .Where(x => x.EndsWith(".dat")) 100 .OrderBy(x => x) 101 .Select(x => x.Replace(".dat", String.Empty)) 102 .Select(x => x.Replace(InstancePrefix, String.Empty)); 103 } 98 104 } 99 105 #endregion … … 103 109 private QuadraticAssignmentProblem(QuadraticAssignmentProblem original, Cloner cloner) 104 110 : base(original, cloner) { 105 instances = new ObservableList<string>(original.instances);106 111 AttachEventHandlers(); 107 112 } … … 412 417 OnReset(); 413 418 } 419 420 public void LoadInstanceFromEmbeddedResource(string instance) { 421 using (Stream stream = Assembly.GetExecutingAssembly() 422 .GetManifestResourceStream(InstancePrefix + instance + ".dat")) { 423 QAPLIBParser datParser = new QAPLIBParser(); 424 datParser.Parse(stream); 425 if (datParser.Error != null) throw datParser.Error; 426 Distances = new DoubleMatrix(datParser.Distances); 427 Weights = new DoubleMatrix(datParser.Weights); 428 Name = instance; 429 Description = "Loaded embedded instance " + instance + " of plugin version " + Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).Cast<AssemblyFileVersionAttribute>().FirstOrDefault().Version + "."; 430 431 bool solutionExists = Assembly.GetExecutingAssembly() 432 .GetManifestResourceNames() 433 .Where(x => x.EndsWith(instance + ".sln")) 434 .Any(); 435 436 if (solutionExists) { 437 using (Stream solStream = Assembly.GetExecutingAssembly() 438 .GetManifestResourceStream(InstancePrefix + instance + ".sln")) { 439 QAPLIBSolutionParser slnParser = new QAPLIBSolutionParser(); 440 slnParser.Parse(solStream, true); 441 if (slnParser.Error != null) throw slnParser.Error; 442 443 BestKnownQuality = new DoubleValue(slnParser.Quality); 444 BestKnownSolution = new Permutation(PermutationTypes.Absolute, slnParser.Assignment); 445 BestKnownSolutions = new ItemSet<Permutation>(new PermutationEqualityComparer()); 446 BestKnownSolutions.Add((Permutation)BestKnownSolution.Clone()); 447 448 if (!BestKnownQuality.Value.IsAlmost(QAPEvaluator.Apply(BestKnownSolution, Weights, Distances))) { 449 // the solution doesn't result in the given quality, maybe indices and values are inverted 450 // try parsing again, this time inverting them 451 solStream.Seek(0, SeekOrigin.Begin); 452 slnParser.Reset(); 453 slnParser.Parse(solStream, false); 454 if (slnParser.Error != null) throw slnParser.Error; 455 456 BestKnownQuality = new DoubleValue(slnParser.Quality); 457 BestKnownSolution = new Permutation(PermutationTypes.Absolute, slnParser.Assignment); 458 BestKnownSolutions = new ItemSet<Permutation>(new PermutationEqualityComparer()); 459 BestKnownSolutions.Add((Permutation)BestKnownSolution.Clone()); 460 461 if (!BestKnownQuality.Value.IsAlmost(QAPEvaluator.Apply(BestKnownSolution, Weights, Distances))) { 462 // if the solution still doesn't result in the given quality, remove it and only take the quality 463 BestKnownSolution = null; 464 BestKnownSolutions = new ItemSet<Permutation>(new PermutationEqualityComparer()); 465 } 466 } 467 } 468 } 469 } 470 OnReset(); 471 } 414 472 } 415 473 }
Note: See TracChangeset
for help on using the changeset viewer.