Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7548


Ignore:
Timestamp:
03/05/12 16:30:27 (12 years ago)
Author:
abeham
Message:

#1614: changed according to architects review

Location:
branches/GeneralizedQAP
Files:
13 added
11 deleted
26 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views-3.3.csproj

    r7483 r7548  
    8989  </ItemGroup>
    9090  <ItemGroup>
    91     <Compile Include="ToolTipComboBox.cs">
    92       <SubType>Component</SubType>
    93     </Compile>
    94     <Compile Include="ToolTipComboBox.Designer.cs">
    95       <DependentUpon>ToolTipComboBox.cs</DependentUpon>
    96     </Compile>
    97     <Compile Include="ToolTipRequiredEventArgs.cs" />
    9891    <Compile Include="ProblemInstanceProviderView.cs">
    9992      <SubType>UserControl</SubType>
     
    139132  </ItemGroup>
    140133  <ItemGroup>
    141     <EmbeddedResource Include="ToolTipComboBox.resx">
    142       <DependentUpon>ToolTipComboBox.cs</DependentUpon>
    143     </EmbeddedResource>
    144134    <EmbeddedResource Include="ProblemInstanceProviderView.resx">
    145135      <DependentUpon>ProblemInstanceProviderView.cs</DependentUpon>
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ProblemInstanceProviderView.Designer.cs

    r7538 r7548  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.components = new System.ComponentModel.Container();
    4748      this.loadButton = new System.Windows.Forms.Button();
    4849      this.label2 = new System.Windows.Forms.Label();
     
    5051      this.importButton = new System.Windows.Forms.Button();
    5152      this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
     53      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    5254      this.SuspendLayout();
    5355      //
     
    5557      //
    5658      this.loadButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    57       this.loadButton.Location = new System.Drawing.Point(451, -1);
     59      this.loadButton.Location = new System.Drawing.Point(549, -1);
    5860      this.loadButton.Name = "loadButton";
    59       this.loadButton.Size = new System.Drawing.Size(75, 23);
     61      this.loadButton.Size = new System.Drawing.Size(26, 23);
    6062      this.loadButton.TabIndex = 6;
    6163      this.loadButton.Text = "Load";
     
    8082      this.instancesComboBox.Location = new System.Drawing.Point(54, 0);
    8183      this.instancesComboBox.Name = "instancesComboBox";
    82       this.instancesComboBox.Size = new System.Drawing.Size(391, 21);
     84      this.instancesComboBox.Size = new System.Drawing.Size(489, 21);
    8385      this.instancesComboBox.TabIndex = 7;
    8486      this.instancesComboBox.DataSourceChanged += new System.EventHandler(this.comboBox_DataSourceChanged);
     
    8789      //
    8890      this.importButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    89       this.importButton.Location = new System.Drawing.Point(532, -1);
     91      this.importButton.Location = new System.Drawing.Point(581, -1);
    9092      this.importButton.Name = "importButton";
    91       this.importButton.Size = new System.Drawing.Size(75, 23);
     93      this.importButton.Size = new System.Drawing.Size(26, 23);
    9294      this.importButton.TabIndex = 6;
    9395      this.importButton.Text = "Import";
     
    122124    private System.Windows.Forms.Button importButton;
    123125    private System.Windows.Forms.OpenFileDialog openFileDialog;
     126    private System.Windows.Forms.ToolTip toolTip;
    124127
    125128  }
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ProblemInstanceProviderView.cs

    r7538 r7548  
    2121
    2222using System;
     23using System.IO;
    2324using System.Linq;
    2425using System.Windows.Forms;
     
    4041    public ProblemInstanceProviderView() {
    4142      InitializeComponent();
     43      importButton.Text = String.Empty;
    4244      importButton.Image = VSImageLibrary.Open;
     45      toolTip.SetToolTip(importButton, "Import a " + GetProblemType() + " instance from file.");
     46      loadButton.Text = String.Empty;
     47      loadButton.Image = VSImageLibrary.Checkout;
     48      toolTip.SetToolTip(loadButton, "Load the selected instance.");
    4349    }
    4450
     
    4955      } else {
    5056        instancesComboBox.DisplayMember = "Name";
    51         instancesComboBox.DataSource = Content.GetInstanceDescriptors().ToList();
     57        instancesComboBox.DataSource = Content.GetDataDescriptors().ToList();
    5258      }
    5359    }
     
    6066
    6167    private void loadButton_Click(object sender, EventArgs e) {
    62       var descriptor = (IInstanceDescriptor)instancesComboBox.SelectedItem;
    63       var instance = Content.LoadInstance(descriptor);
    64       if (!Content.Consumer.LoadFrom(instance)) {
    65         MessageBox.Show("This problem does not support loading the instance " + descriptor.Name + ".", "Cannot load instance");
     68      var descriptor = (IDataDescriptor)instancesComboBox.SelectedItem;
     69      var instance = Content.LoadData(descriptor);
     70      try {
     71        Content.Consumer.Load(instance);
     72      } catch (Exception ex) {
     73        MessageBox.Show(String.Format("This problem does not support loading the instance {0}: {1}", descriptor.Name, Environment.NewLine + ex.Message), "Cannot load instance");
    6674      }
    6775    }
    6876
    6977    private void importButton_Click(object sender, EventArgs e) {
     78      openFileDialog.FileName = GetProblemType() + " instance";
    7079      if (openFileDialog.ShowDialog() == DialogResult.OK) {
    7180        T instance = default(T);
    7281        try {
    73           instance = Content.LoadInstance(openFileDialog.FileName);
    74         } catch {
    75           MessageBox.Show("There was an error parsing the file.", "Error while parsing", MessageBoxButtons.OK, MessageBoxIcon.Error);
     82          instance = Content.LoadData(openFileDialog.FileName);
     83        } catch (Exception ex) {
     84          MessageBox.Show(String.Format("There was an error parsing the file: {0}", Environment.NewLine + ex.Message), "Error while parsing", MessageBoxButtons.OK, MessageBoxIcon.Error);
    7685          return;
    7786        }
    7887        try {
    79           if (!Content.Consumer.LoadFrom(instance)) {
    80             MessageBox.Show("This problem does not support loading the instance in the file.", "Cannot load instance", MessageBoxButtons.OK, MessageBoxIcon.Error);
    81           }
    82         } catch {
    83           MessageBox.Show("There was an error while importing the file.");
     88          Content.Consumer.Load(instance);
     89        } catch (Exception ex) {
     90          MessageBox.Show(String.Format("This problem does not support loading the instance {0}: {1}", Path.GetFileName(openFileDialog.FileName), Environment.NewLine + ex.Message), "Cannot load instance");
    8491        }
    8592      }
     
    9198        comboBox.Items.Clear();
    9299    }
     100
     101    private string GetProblemType() {
     102      string dataTypeName = typeof(T).Name.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Last();
     103      if (dataTypeName.EndsWith("Data"))
     104        return dataTypeName.Substring(0, dataTypeName.Length - "Data".Length);
     105      else return dataTypeName;
     106    }
    93107  }
    94108}
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ProblemInstanceProviderView.resx

    r7538 r7548  
    121121    <value>17, 17</value>
    122122  </metadata>
     123  <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     124    <value>150, 17</value>
     125  </metadata>
    123126</root>
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ProblemView.Designer.cs

    r7538 r7548  
    4747      this.label1 = new System.Windows.Forms.Label();
    4848      this.problemInstanceProviderViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    49       this.problemInstanceProviderComboBox = new HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views.ToolTipComboBox();
     49      this.problemInstanceProviderComboBox = new System.Windows.Forms.ComboBox();
     50      this.libraryInfoButton = new System.Windows.Forms.Button();
    5051      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5152      this.SuspendLayout();
     
    9394      this.problemInstanceProviderViewHost.Content = null;
    9495      this.problemInstanceProviderViewHost.Enabled = false;
    95       this.problemInstanceProviderViewHost.Location = new System.Drawing.Point(229, 5);
     96      this.problemInstanceProviderViewHost.Location = new System.Drawing.Point(259, 5);
    9697      this.problemInstanceProviderViewHost.Name = "problemInstanceProviderViewHost";
    9798      this.problemInstanceProviderViewHost.ReadOnly = false;
    98       this.problemInstanceProviderViewHost.Size = new System.Drawing.Size(421, 21);
     99      this.problemInstanceProviderViewHost.Size = new System.Drawing.Size(391, 21);
    99100      this.problemInstanceProviderViewHost.TabIndex = 6;
    100101      this.problemInstanceProviderViewHost.ViewsLabelVisible = false;
     
    103104      // problemInstanceProviderComboBox
    104105      //
    105       this.problemInstanceProviderComboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
    106106      this.problemInstanceProviderComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    107       this.problemInstanceProviderComboBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    108107      this.problemInstanceProviderComboBox.FormattingEnabled = true;
    109108      this.problemInstanceProviderComboBox.Location = new System.Drawing.Point(50, 5);
    110       this.problemInstanceProviderComboBox.MaxDropDownItems = 16;
    111109      this.problemInstanceProviderComboBox.Name = "problemInstanceProviderComboBox";
    112       this.problemInstanceProviderComboBox.Size = new System.Drawing.Size(173, 21);
     110      this.problemInstanceProviderComboBox.Size = new System.Drawing.Size(171, 21);
    113111      this.problemInstanceProviderComboBox.TabIndex = 7;
    114       this.problemInstanceProviderComboBox.ToolTipRequired += new System.EventHandler<HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views.ToolTipRequiredEventArgs>(this.problemInstanceProviderComboBox_ToolTipRequired);
    115112      this.problemInstanceProviderComboBox.SelectedIndexChanged += new System.EventHandler(this.problemInstanceProviderComboBox_SelectedIndexChanged);
    116113      this.problemInstanceProviderComboBox.DataSourceChanged += new System.EventHandler(this.comboBox_DataSourceChanged);
     114      //
     115      // libraryInfoButton
     116      //
     117      this.libraryInfoButton.Location = new System.Drawing.Point(227, 4);
     118      this.libraryInfoButton.Name = "libraryInfoButton";
     119      this.libraryInfoButton.Size = new System.Drawing.Size(26, 23);
     120      this.libraryInfoButton.TabIndex = 8;
     121      this.libraryInfoButton.Text = "Info";
     122      this.libraryInfoButton.UseVisualStyleBackColor = true;
     123      this.libraryInfoButton.Click += new System.EventHandler(this.libraryInfoButton_Click);
    117124      //
    118125      // ProblemView
     
    123130      this.Controls.Add(this.problemInstanceProviderComboBox);
    124131      this.Controls.Add(this.label1);
     132      this.Controls.Add(this.libraryInfoButton);
    125133      this.Name = "ProblemView";
    126134      this.Size = new System.Drawing.Size(653, 455);
     135      this.Controls.SetChildIndex(this.libraryInfoButton, 0);
     136      this.Controls.SetChildIndex(this.label1, 0);
     137      this.Controls.SetChildIndex(this.problemInstanceProviderComboBox, 0);
     138      this.Controls.SetChildIndex(this.problemInstanceProviderViewHost, 0);
    127139      this.Controls.SetChildIndex(this.infoLabel, 0);
    128       this.Controls.SetChildIndex(this.label1, 0);
    129140      this.Controls.SetChildIndex(this.nameTextBox, 0);
    130141      this.Controls.SetChildIndex(this.nameLabel, 0);
    131       this.Controls.SetChildIndex(this.problemInstanceProviderComboBox, 0);
    132       this.Controls.SetChildIndex(this.problemInstanceProviderViewHost, 0);
    133142      this.Controls.SetChildIndex(this.parameterCollectionView, 0);
    134143      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
     
    142151    private System.Windows.Forms.Label label1;
    143152    private MainForm.WindowsForms.ViewHost problemInstanceProviderViewHost;
    144     private ToolTipComboBox problemInstanceProviderComboBox;
     153    private System.Windows.Forms.ComboBox problemInstanceProviderComboBox;
     154    private System.Windows.Forms.Button libraryInfoButton;
    145155
    146156  }
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ProblemView.cs

    r7539 r7548  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Diagnostics;
    2425using System.Linq;
    2526using System.Reflection;
    2627using System.Windows.Forms;
     28using HeuristicLab.Common.Resources;
    2729using HeuristicLab.Core.Views;
    2830using HeuristicLab.MainForm;
     
    4244    }
    4345
     46    private IProblemInstanceProvider SelectedProvider {
     47      get { return (problemInstanceProviderComboBox.SelectedIndex >= 0 ? (IProblemInstanceProvider)problemInstanceProviderComboBox.SelectedItem : null); }
     48    }
     49
    4450    public ProblemView() {
    4551      InitializeComponent();
     52      libraryInfoButton.Text = String.Empty;
     53      libraryInfoButton.Image = VSImageLibrary.Information;
    4654    }
    4755
     
    5462        problemInstanceProviderComboBox.DataSource = GetProblemInstanceProviders().ToList();
    5563      }
     64      SetEnabledStateOfControls();
    5665    }
    5766
    5867    protected override void SetEnabledStateOfControls() {
    5968      base.SetEnabledStateOfControls();
    60       problemInstanceProviderComboBox.Enabled = !ReadOnly && !Locked && Content != null;
     69      problemInstanceProviderComboBox.Enabled = !ReadOnly && !Locked && Content != null && problemInstanceProviderComboBox.Items.Count > 0;
     70      libraryInfoButton.Enabled = SelectedProvider != null && SelectedProvider.WebLink != null;
    6171    }
    6272
    6373    private void problemInstanceProviderComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
    6474      if (problemInstanceProviderComboBox.SelectedIndex >= 0) {
    65         var provider = (IProblemInstanceProvider)problemInstanceProviderComboBox.SelectedItem;
    66         var genericType = provider.GetType().GetInterfaces().Single(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IProblemInstanceProvider<>)).GetGenericArguments().First();
     75        var genericType = SelectedProvider.GetType().GetInterfaces().Single(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IProblemInstanceProvider<>)).GetGenericArguments().First();
    6776        this.GetType().GetMethod("SetConsumable", BindingFlags.NonPublic | BindingFlags.Instance)
    68           .MakeGenericMethod(genericType).Invoke(this, new object[] { provider, Content });
    69         problemInstanceProviderViewHost.Content = provider;
     77          .MakeGenericMethod(genericType).Invoke(this, new object[] { SelectedProvider, Content });
     78        problemInstanceProviderViewHost.Content = SelectedProvider;
     79        SetTooltip();
    7080      }
     81      SetEnabledStateOfControls();
    7182    }
    7283
    73     /// <summary>
    74     /// Do not change method name without changing the string reference above
    75     /// </summary>
    76     private void SetConsumable<T>(IProblemInstanceProvider<T> producer, IConsumable<T> consumer) {
     84    // Do not change method without changing the reflection call above
     85    [Obsolete]
     86    private void SetConsumable<T>(IProblemInstanceProvider<T> producer, IProblemInstanceConsumer<T> consumer) {
    7787      producer.Consumer = consumer;
    7888    }
     
    8494    }
    8595
     96    private void libraryInfoButton_Click(object sender, EventArgs e) {
     97      if (problemInstanceProviderComboBox.SelectedIndex >= 0) {
     98        if (SelectedProvider != null && SelectedProvider.WebLink != null)
     99          Process.Start(SelectedProvider.WebLink.ToString());
     100      }
     101    }
     102
    86103    protected virtual IEnumerable<IProblemInstanceProvider> GetProblemInstanceProviders() {
    87104      var consumerTypes = Content.GetType().GetInterfaces()
    88105        .Where(x => x.IsGenericType
    89           && x.GetGenericTypeDefinition() == typeof(IConsumable<>));
     106          && x.GetGenericTypeDefinition() == typeof(IProblemInstanceConsumer<>));
    90107
    91108      if (consumerTypes.Any()) {
     
    101118    }
    102119
    103     protected virtual string GetProviderToolTip(IProblemInstanceProvider provider) {
    104       if (provider.WebLink != null) {
    105         return provider.Name
    106             + Environment.NewLine
    107             + provider.WebLink.ToString()
    108             + Environment.NewLine + Environment.NewLine
    109             + provider.ReferencePublication;
    110       } else {
    111         return provider.Name
     120    private void SetTooltip() {
     121      toolTip.SetToolTip(problemInstanceProviderComboBox, GetProviderToolTip());
     122      if (SelectedProvider.WebLink != null)
     123        toolTip.SetToolTip(libraryInfoButton, "Browse to " + SelectedProvider.WebLink.ToString());
     124      else toolTip.SetToolTip(libraryInfoButton, "Library does not have a web reference.");
     125    }
     126
     127    protected virtual string GetProviderToolTip() {
     128      var provider = SelectedProvider;
     129      string toolTip = provider.Name;
     130
     131      if (!String.IsNullOrEmpty(provider.ReferencePublication)) {
     132        toolTip = toolTip
    112133            + Environment.NewLine + Environment.NewLine
    113134            + provider.ReferencePublication;
    114135      }
    115     }
     136      if (provider.WebLink != null) {
     137        toolTip = toolTip
     138            + Environment.NewLine
     139            + provider.WebLink.ToString();
     140      }
    116141
    117     private void problemInstanceProviderComboBox_ToolTipRequired(object sender, ToolTipRequiredEventArgs e) {
    118       e.ToolTip = GetProviderToolTip((IProblemInstanceProvider)e.Item);
     142      return toolTip;
    119143    }
    120144  }
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ProblemView.resx

    r7482 r7548  
    121121    <value>107, 17</value>
    122122  </metadata>
     123  <metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     124    <value>107, 17</value>
     125  </metadata>
    123126  <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    124127    <value>17, 17</value>
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GeneralizedQuadraticAssignmentProblem.cs

    r7538 r7548  
    3939  [StorableClass]
    4040  public sealed class GeneralizedQuadraticAssignmentProblem : SingleObjectiveHeuristicOptimizationProblem<IGQAPEvaluator, IGQAPSolutionCreator>, IStorableContent,
    41     IConsumable<QAPInstance>,
    42     IConsumable<CTAPInstance>,
    43     IConsumable<TSPInstance>,
    44     IConsumable<ATSPInstance>,
    45     IConsumable<GQAPInstance> {
     41    IProblemInstanceConsumer<QAPData>,
     42    IProblemInstanceConsumer<CTAPData>,
     43    IProblemInstanceConsumer<TSPData>,
     44    IProblemInstanceConsumer<ATSPData>,
     45    IProblemInstanceConsumer<GQAPData> {
    4646
    4747    public override Image ItemImage {
     
    169169      Parameters.Add(new ValueParameter<DoubleMatrix>("InstallationCosts", InstallationCostsDescription, new DoubleMatrix(), false));
    170170      Parameters.Add(new FixedValueParameter<DoubleValue>("TransportationCosts", TransportationCostsDescription, new DoubleValue(1)));
    171       Parameters.Add(new FixedValueParameter<DoubleValue>("OverbookedCapacityPenalty", OverbookedCapacityPenaltyDescription, new DoubleValue(1000)));
     171      Parameters.Add(new FixedValueParameter<DoubleValue>("OverbookedCapacityPenalty", OverbookedCapacityPenaltyDescription, new DoubleValue(100000)));
    172172      Parameters.Add(new ValueParameter<DoubleArray>("Demands", DemandsDescription, new DoubleArray(), false));
    173173      Parameters.Add(new ValueParameter<DoubleArray>("Capacities", CapacitiesDescription, new DoubleArray(), false));
     
    213213    }
    214214
    215     #region Problem Instance Consumptions
    216     public bool LoadFrom(QAPInstance instance) {
    217       try {
    218         Name = instance.Name;
    219         Description = instance.Description;
    220 
    221         Weights = new DoubleMatrix(instance.Weights);
    222         Distances = new DoubleMatrix(instance.Distances);
    223         InstallationCosts = new DoubleMatrix(Weights.Rows, Distances.Columns); // all zero
    224         Capacities = new DoubleArray(Enumerable.Range(0, Distances.Rows).Select(x => 1.0).ToArray());
    225         Demands = new DoubleArray(Enumerable.Range(0, Weights.Rows).Select(x => 1.0).ToArray());
    226 
    227         TransportationCosts.Value = 1;
    228 
    229         if (instance.BestKnownAssignment != null) {
    230           EvaluateAndLoadAssignment(instance.BestKnownAssignment);
    231         } else {
    232           BestKnownQuality = null;
    233           BestKnownSolution = null;
    234           BestKnownSolutions = null;
     215    #region Problem Instance Loading
     216    public void Load(QAPData data) {
     217      Name = data.Name;
     218      Description = data.Description;
     219
     220      var weights = new DoubleMatrix(data.Weights);
     221      var distances = new DoubleMatrix(data.Distances);
     222      var installationCosts = new DoubleMatrix(weights.Rows, distances.Columns); // all zero
     223      var capacities = new DoubleArray(Enumerable.Range(0, distances.Rows).Select(x => 1.0).ToArray());
     224      var demands = new DoubleArray(Enumerable.Range(0, weights.Rows).Select(x => 1.0).ToArray());
     225
     226      Load(demands, capacities, weights, distances, installationCosts, new DoubleValue(1));
     227      EvaluateAndLoadAssignment(data.BestKnownAssignment);
     228    }
     229
     230    public void Load(CTAPData data) {
     231      Name = data.Name;
     232      Description = data.Description;
     233
     234      var capacities = new DoubleArray(data.MemoryCapacities);
     235      var demands = new DoubleArray(data.MemoryRequirements);
     236      var weights = new DoubleMatrix(data.CommunicationCosts);
     237      var installationCosts = new DoubleMatrix(data.ExecutionCosts.Transpose());
     238      var distances = new DoubleMatrix(capacities.Length, capacities.Length);
     239      for (int i = 0; i < capacities.Length - 1; i++)
     240        for (int j = i + 1; j < capacities.Length; j++) {
     241          distances[i, j] = 1;
    235242        }
    236       } catch {
    237         return false;
    238       }
    239       return true;
    240     }
    241 
    242     public bool LoadFrom(CTAPInstance instance) {
    243       try {
    244         Name = instance.Name;
    245         Description = instance.Description;
    246 
    247         Capacities = new DoubleArray(instance.MemoryCapacities);
    248         Demands = new DoubleArray(instance.MemoryRequirements);
    249         Weights = new DoubleMatrix(instance.CommunicationCosts);
    250         InstallationCosts = new DoubleMatrix(instance.ExecutionCosts.Transpose());
    251         Distances = new DoubleMatrix(Capacities.Length, Capacities.Length);
    252         for (int i = 0; i < Capacities.Length - 1; i++)
    253           for (int j = i + 1; j < Capacities.Length; j++) {
    254             Distances[i, j] = 1;
    255           }
    256 
    257         TransportationCosts.Value = 1;
    258 
    259         if (instance.BestKnownAssignment != null) {
    260           EvaluateAndLoadAssignment(instance.BestKnownAssignment);
    261         } else {
    262           BestKnownQuality = null;
    263           BestKnownSolution = null;
    264           BestKnownSolutions = null;
    265         }
    266       } catch {
    267         return false;
    268       }
    269       return true;
    270     }
    271 
    272     public bool LoadFrom(TSPInstance instance) {
    273       try {
    274         if (instance.Dimension > 1000) return false;
    275 
    276         Name = instance.Name;
    277         Description = instance.Description;
    278 
    279         Capacities = new DoubleArray(instance.Dimension);
    280         Demands = new DoubleArray(instance.Dimension);
    281         for (int i = 0; i < instance.Dimension; i++) {
    282           Capacities[i] = 1;
    283           Demands[i] = 1;
    284         }
    285         InstallationCosts = new DoubleMatrix(instance.Dimension, instance.Dimension);
    286         Weights = new DoubleMatrix(instance.Dimension, instance.Dimension);
    287         for (int i = 0; i < instance.Dimension; i++)
    288           Weights[i, (i + 1) % instance.Dimension] = 1;
    289         Distances = new DoubleMatrix(instance.GetDistanceMatrix());
    290 
    291         TransportationCosts.Value = 1;
    292 
    293         if (instance.BestKnownTour != null) {
    294           EvaluateAndLoadAssignment(instance.BestKnownTour);
    295         } else {
    296           BestKnownQuality = null;
    297           BestKnownSolution = null;
    298           BestKnownSolutions = null;
    299         }
    300       } catch {
    301         return false;
    302       }
    303       return true;
    304     }
    305 
    306     public bool LoadFrom(ATSPInstance instance) {
    307       try {
    308         Name = instance.Name;
    309         Description = instance.Description;
    310 
    311         Capacities = new DoubleArray(instance.Dimension);
    312         Demands = new DoubleArray(instance.Dimension);
    313         for (int i = 0; i < instance.Dimension; i++) {
    314           Capacities[i] = 1;
    315           Demands[i] = 1;
    316         }
    317         InstallationCosts = new DoubleMatrix(instance.Dimension, instance.Dimension);
    318         Weights = new DoubleMatrix(instance.Dimension, instance.Dimension);
    319         for (int i = 0; i < instance.Dimension; i++)
    320           Weights[i, (i + 1) % instance.Dimension] = 1;
    321         Distances = new DoubleMatrix(instance.Distances);
    322 
    323         TransportationCosts.Value = 1;
    324 
    325         if (instance.BestKnownTour != null) {
    326           EvaluateAndLoadAssignment(instance.BestKnownTour);
    327         } else {
    328           BestKnownQuality = null;
    329           BestKnownSolution = null;
    330           BestKnownSolutions = null;
    331         }
    332       } catch {
    333         return false;
    334       }
    335       return true;
    336     }
    337 
    338     public bool LoadFrom(GQAPInstance instance) {
    339       try {
    340         Name = instance.Name;
    341         Description = instance.Description;
    342 
    343         Capacities = new DoubleArray(instance.Capacities);
    344         Demands = new DoubleArray(instance.Demands);
    345         InstallationCosts = new DoubleMatrix(instance.InstallationCosts);
    346         Weights = new DoubleMatrix(instance.Weights);
    347         Distances = new DoubleMatrix(instance.Distances);
    348         TransportationCosts.Value = instance.TransportationCosts;
    349 
    350         if (instance.BestKnownAssignment != null) {
    351           EvaluateAndLoadAssignment(instance.BestKnownAssignment);
    352         } else if (instance.BestKnownQuality.HasValue) {
    353           BestKnownQuality = new DoubleValue(instance.BestKnownQuality.Value);
    354           BestKnownSolution = null;
    355           BestKnownSolutions = null;
    356         } else {
    357           BestKnownQuality = null;
    358           BestKnownSolution = null;
    359           BestKnownSolutions = null;
    360         }
    361       } catch {
    362         return false;
    363       }
    364       return true;
    365     }
    366     #endregion
     243
     244      Load(demands, capacities, weights, distances, installationCosts, new DoubleValue(1));
     245      EvaluateAndLoadAssignment(data.BestKnownAssignment);
     246    }
     247
     248    public void Load(TSPData data) {
     249      if (data.Dimension > 1000)
     250        throw new System.IO.InvalidDataException("Instances with more than 1000 cities are not supported.");
     251
     252      Name = data.Name;
     253      Description = data.Description;
     254
     255      var capacities = new DoubleArray(data.Dimension);
     256      var demands = new DoubleArray(data.Dimension);
     257      for (int i = 0; i < data.Dimension; i++) {
     258        capacities[i] = 1;
     259        demands[i] = 1;
     260      }
     261      var installationCosts = new DoubleMatrix(data.Dimension, data.Dimension);
     262      var weights = new DoubleMatrix(data.Dimension, data.Dimension);
     263      for (int i = 0; i < data.Dimension; i++)
     264        weights[i, (i + 1) % data.Dimension] = 1;
     265      var distances = new DoubleMatrix(data.GetDistanceMatrix());
     266
     267      Load(demands, capacities, weights, distances, installationCosts, new DoubleValue(1));
     268      EvaluateAndLoadAssignment(data.BestKnownTour);
     269    }
     270
     271    public void Load(ATSPData data) {
     272      Name = data.Name;
     273      Description = data.Description;
     274
     275      var capacities = new DoubleArray(data.Dimension);
     276      var demands = new DoubleArray(data.Dimension);
     277      for (int i = 0; i < data.Dimension; i++) {
     278        capacities[i] = 1;
     279        demands[i] = 1;
     280      }
     281      var installationCosts = new DoubleMatrix(data.Dimension, data.Dimension);
     282      var weights = new DoubleMatrix(data.Dimension, data.Dimension);
     283      for (int i = 0; i < data.Dimension; i++)
     284        weights[i, (i + 1) % data.Dimension] = 1;
     285      var distances = new DoubleMatrix(data.Distances);
     286
     287      Load(demands, capacities, weights, distances, installationCosts, new DoubleValue(1));
     288      EvaluateAndLoadAssignment(data.BestKnownTour);
     289    }
     290
     291    public void Load(GQAPData data) {
     292      Name = data.Name;
     293      Description = data.Description;
     294
     295      var capacities = new DoubleArray(data.Capacities);
     296      var demands = new DoubleArray(data.Demands);
     297      var installationCosts = new DoubleMatrix(data.InstallationCosts);
     298      var weights = new DoubleMatrix(data.Weights);
     299      var distances = new DoubleMatrix(data.Distances);
     300      var transportationCosts = new DoubleValue(data.TransportationCosts);
     301
     302      Load(demands, capacities, weights, distances, installationCosts, transportationCosts);
     303      EvaluateAndLoadAssignment(data.BestKnownAssignment);
     304
     305      if (data.BestKnownAssignment == null && data.BestKnownQuality.HasValue) {
     306        BestKnownQuality = new DoubleValue(data.BestKnownQuality.Value);
     307      }
     308    }
     309
     310    public void Load(DoubleArray demands, DoubleArray capacities,
     311      DoubleMatrix weights, DoubleMatrix distances, DoubleMatrix installationCosts,
     312      DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty = null) {
     313      if (weights == null || weights.Rows == 0)
     314        throw new System.IO.InvalidDataException(
     315@"The given instance does not contain weights!");
     316      if (weights.Rows != weights.Columns)
     317        throw new System.IO.InvalidDataException(
     318@"The weights matrix of the given instance contains an unequal number of rows
     319and columns.");
     320      Weights = weights;
     321
     322      if (distances == null || distances.Rows == 0)
     323        throw new System.IO.InvalidDataException(
     324@"The given instance does not contain distances!");
     325      if (distances.Rows != distances.Columns)
     326        throw new System.IO.InvalidDataException(
     327@"The distances matrix of the given instance contains an unequal number of rows
     328and columns.");
     329      Distances = distances;
     330
     331      if (installationCosts == null || installationCosts.Rows == 0)
     332        throw new System.IO.InvalidDataException(
     333@"The given instance does not contain installation costs!");
     334      if (installationCosts.Rows != weights.Rows
     335        || installationCosts.Columns != distances.Columns)
     336        throw new System.IO.InvalidDataException(
     337@"The installation costs matrix of the given instance contains different number
     338of rows than given in the weights matrix and a different number of columns than
     339given in the distances matrix.");
     340      InstallationCosts = installationCosts;
     341
     342      if (capacities == null || capacities.Length == 0)
     343        throw new System.IO.InvalidDataException(
     344@"The given instance does not contain capacities!");
     345      if (capacities.Length != distances.Rows)
     346        throw new System.IO.InvalidDataException(
     347@"The given instance contains a different number of capacities than rows given in
     348the distances matrix.");
     349      Capacities = capacities;
     350
     351      if (demands == null || demands.Length == 0)
     352        throw new System.IO.InvalidDataException(
     353@"The given instance does not contain demands!");
     354      if (demands.Length != weights.Rows)
     355        throw new System.IO.InvalidDataException(
     356@"The given instance contains a different number of demands than rows given in
     357the weights matrix.");
     358      Demands = demands;
     359
     360      if (transportationCosts == null)
     361        throw new System.IO.InvalidDataException(
     362@"The given instance does not contain transportation costs.");
     363      TransportationCosts.Value = transportationCosts.Value;
     364
     365      if (overbookedCapacityPenalty != null)
     366        OverbookedCapacityPenalty.Value = overbookedCapacityPenalty.Value;
     367
     368      BestKnownQuality = null;
     369      BestKnownSolution = null;
     370      BestKnownSolutions = null;
     371    }
    367372
    368373    private void EvaluateAndLoadAssignment(int[] vector) {
     374      if (vector == null || vector.Length == 0) return;
    369375      EvaluateAndLoadAssignment(new IntegerVector(vector));
    370376    }
    371     private void EvaluateAndLoadAssignment(IntegerVector assignment) {
     377    public void EvaluateAndLoadAssignment(IntegerVector assignment) {
    372378      if (!IsConfigurationValid()) {
    373379        BestKnownQuality = null;
     
    387393      BestKnownSolutions.Solutions.Add(new GQAPSolution((IntegerVector)assignment.Clone(), new DoubleValue(quality), new DoubleValue(flowDistanceQuality), new DoubleValue(installationQuality), new DoubleValue(overbookedCapacity)));
    388394    }
     395    #endregion
    389396
    390397    #region Events
     
    525532    #endregion
    526533
    527     private bool IsConfigurationValid() {
     534    public bool IsConfigurationValid() {
    528535      return Weights != null && Distances != null && Demands != null && Capacities != null && InstallationCosts != null
    529536        && Weights.Rows == Weights.Columns && Weights.Rows == InstallationCosts.Rows
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/CordeauGQAPInstanceProvider.cs

    r7538 r7548  
    2828
    2929namespace HeuristicLab.Problems.Instances.CordeauGQAP {
    30   public class CordeauGQAPInstanceProvider : ProblemInstanceProvider<GQAPInstance> {
     30  public class CordeauGQAPInstanceProvider : ProblemInstanceProvider<GQAPData> {
    3131    public override string Name {
    3232      get { return "Cordeau et al. GQAP instances"; }
     
    4949    }
    5050
    51     public override IEnumerable<IInstanceDescriptor> GetInstanceDescriptors() {
     51    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
    5252      return Assembly.GetExecutingAssembly()
    5353          .GetManifestResourceNames()
    5454          .Where(x => x.EndsWith(".txt"))
    5555          .OrderBy(x => x)
    56           .Select(x => new CordeauGQAPInstanceDescriptor(GetPrettyName(x), GetDescription(), x));
     56          .Select(x => new CordeauGQAPDataDescriptor(GetPrettyName(x), GetDescription(), x));
    5757    }
    5858
    59     public override GQAPInstance LoadInstance(IInstanceDescriptor id) {
    60       var descriptor = (CordeauGQAPInstanceDescriptor)id;
     59    public override GQAPData LoadData(IDataDescriptor id) {
     60      var descriptor = (CordeauGQAPDataDescriptor)id;
    6161      using (var stream = Assembly.GetExecutingAssembly()
    6262        .GetManifestResourceStream(descriptor.InstanceIdentifier)) {
     
    7272    }
    7373
    74     public override GQAPInstance LoadInstance(string path) {
     74    public override GQAPData LoadData(string path) {
    7575      var parser = new CordeauGQAPParser();
    7676      parser.Parse(path);
     
    8383    }
    8484
    85     public override void SaveInstance(GQAPInstance instance, string path) {
     85    public override void SaveData(GQAPData instance, string path) {
    8686      throw new NotSupportedException();
    8787    }
    8888
    89     private GQAPInstance Load(CordeauGQAPParser parser) {
    90       var instance = new GQAPInstance();
     89    private GQAPData Load(CordeauGQAPParser parser) {
     90      var instance = new GQAPData();
    9191      instance.Equipments = parser.Equipments;
    9292      instance.Locations = parser.Locations;
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/HeuristicLab.Problems.Instances.CordeauGQAP-3.3.csproj

    r7538 r7548  
    112112    <Compile Include="CordeauGQAPParser.cs" />
    113113    <Compile Include="CordeauGQAPInstanceProvider.cs" />
    114     <Compile Include="CordeauGQAPInstanceDescriptor.cs" />
     114    <Compile Include="CordeauGQAPDataDescriptor.cs" />
    115115    <Compile Include="Plugin.cs" />
    116116    <Compile Include="Properties\AssemblyInfo.cs" />
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.ElloumiCTAP/3.3/ElloumiCTAPInstanceProvider.cs

    r7538 r7548  
    2828
    2929namespace HeuristicLab.Problems.Instances.ElloumiCTAP {
    30   public class ElloumiCTAPInstanceProvider : ProblemInstanceProvider<CTAPInstance> {
     30  public class ElloumiCTAPInstanceProvider : ProblemInstanceProvider<CTAPData> {
    3131    public override string Name {
    3232      get { return "Elloumi's CTAP instances"; }
     
    4949    }
    5050
    51     public override IEnumerable<IInstanceDescriptor> GetInstanceDescriptors() {
     51    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
    5252      var solutions = Assembly.GetExecutingAssembly()
    5353        .GetManifestResourceNames()
     
    5959          .Where(x => x.EndsWith(".dat"))
    6060          .OrderBy(x => x)
    61           .Select(x => new ElloumiCTAPInstanceDescriptor(GetPrettyName(x), GetDescription(), x, solutions.ContainsKey(x) ? solutions[x] : String.Empty));
     61          .Select(x => new ElloumiCTAPDataDescriptor(GetPrettyName(x), GetDescription(), x, solutions.ContainsKey(x) ? solutions[x] : String.Empty));
    6262    }
    6363
    64     public override CTAPInstance LoadInstance(IInstanceDescriptor id) {
    65       var descriptor = (ElloumiCTAPInstanceDescriptor)id;
     64    public override CTAPData LoadData(IDataDescriptor id) {
     65      var descriptor = (ElloumiCTAPDataDescriptor)id;
    6666      using (var stream = Assembly.GetExecutingAssembly()
    6767        .GetManifestResourceStream(descriptor.InstanceIdentifier)) {
     
    8888    }
    8989
    90     public override CTAPInstance LoadInstance(string path) {
     90    public override CTAPData LoadData(string path) {
    9191      var parser = new ElloumiCTAPParser();
    9292      parser.Parse(path);
     
    9797    }
    9898
    99     public override void SaveInstance(CTAPInstance instance, string path) {
     99    public override void SaveData(CTAPData instance, string path) {
    100100      throw new NotSupportedException();
    101101    }
    102102
    103     private CTAPInstance Load(ElloumiCTAPParser parser) {
    104       var instance = new CTAPInstance();
     103    private CTAPData Load(ElloumiCTAPParser parser) {
     104      var instance = new CTAPData();
    105105      instance.Processors = parser.Processors;
    106106      instance.Tasks = parser.Tasks;
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.ElloumiCTAP/3.3/HeuristicLab.Problems.Instances.ElloumiCTAP-3.3.csproj

    r7538 r7548  
    133133    <EmbeddedResource Include="Data\tassc2005De.dat" />
    134134    <None Include="Plugin.cs.frame" />
    135     <Compile Include="ElloumiCTAPInstanceDescriptor.cs" />
     135    <Compile Include="ElloumiCTAPDataDescriptor.cs" />
    136136    <Compile Include="ElloumiCTAPInstanceProvider.cs" />
    137137    <Compile Include="ElloumiCTAPParser.cs" />
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.QAPLIB/3.3/HeuristicLab.Problems.Instances.QAPLIB-3.3.csproj

    r7538 r7548  
    5151  <ItemGroup>
    5252    <Compile Include="QAPLIBParser.cs" />
    53     <Compile Include="QAPLIBInstanceDescriptor.cs" />
     53    <Compile Include="QAPLIBDataDescriptor.cs" />
    5454    <Compile Include="QAPLIBSolutionParser.cs" />
    5555    <Compile Include="QAPLIBInstanceProvider.cs" />
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.QAPLIB/3.3/QAPLIBInstanceProvider.cs

    r7538 r7548  
    2828
    2929namespace HeuristicLab.Problems.Instances.QAPLIB {
    30   public class QAPLIBInstanceProvider : ProblemInstanceProvider<QAPInstance> {
     30  public class QAPLIBInstanceProvider : ProblemInstanceProvider<QAPData> {
    3131    public override string Name {
    3232      get { return "QAPLIB"; }
     
    4949    }
    5050
    51     public override IEnumerable<IInstanceDescriptor> GetInstanceDescriptors() {
     51    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
    5252      var solutions = Assembly.GetExecutingAssembly()
    5353        .GetManifestResourceNames()
     
    5959          .Where(x => x.EndsWith(".dat"))
    6060          .OrderBy(x => x)
    61           .Select(x => new QAPLIBInstanceDescriptor(GetPrettyName(x), GetDescription(), x, solutions.ContainsKey(x) ? solutions[x] : String.Empty));
     61          .Select(x => new QAPLIBDataDescriptor(GetPrettyName(x), GetDescription(), x, solutions.ContainsKey(x) ? solutions[x] : String.Empty));
    6262    }
    6363
    64     public override QAPInstance LoadInstance(IInstanceDescriptor id) {
    65       var descriptor = (QAPLIBInstanceDescriptor)id;
     64    public override QAPData LoadData(IDataDescriptor id) {
     65      var descriptor = (QAPLIBDataDescriptor)id;
    6666      using (var stream = Assembly.GetExecutingAssembly()
    6767        .GetManifestResourceStream(descriptor.InstanceIdentifier)) {
     
    8787    }
    8888
    89     public override QAPInstance LoadInstance(string path) {
     89    public override QAPData LoadData(string path) {
    9090      var parser = new QAPLIBParser();
    9191      parser.Parse(path);
     
    9696    }
    9797
    98     public override void SaveInstance(QAPInstance instance, string path) {
     98    public override void SaveData(QAPData instance, string path) {
    9999      throw new NotSupportedException();
    100100    }
    101101
    102     private QAPInstance Load(QAPLIBParser parser) {
    103       var instance = new QAPInstance();
     102    private QAPData Load(QAPLIBParser parser) {
     103      var instance = new QAPData();
    104104      instance.Dimension = parser.Size;
    105105      instance.Distances = parser.Distances;
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.TSPLIB/3.3/HeuristicLab.Problems.Instances.TSPLIB-3.3.csproj

    r7538 r7548  
    4747    <Compile Include="TSPLIBATSPInstanceProvider.cs" />
    4848    <Compile Include="TSPLIBCVRPInstanceProvider.cs" />
    49     <Compile Include="TSPLIBInstanceDescriptor.cs" />
     49    <Compile Include="TSPLIBDataDescriptor.cs" />
    5050    <Compile Include="TSPLIBTSPInstanceProvider.cs" />
    5151    <Compile Include="TSPLIBParser.cs" />
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBATSPInstanceProvider.cs

    r7538 r7548  
    2828
    2929namespace HeuristicLab.Problems.Instances.TSPLIB {
    30   public class TSPLIBATSPInstanceProvider : ProblemInstanceProvider<ATSPInstance> {
     30  public class TSPLIBATSPInstanceProvider : ProblemInstanceProvider<ATSPData> {
    3131
    3232    public override string Name {
     
    5050    }
    5151
    52     public override IEnumerable<IInstanceDescriptor> GetInstanceDescriptors() {
     52    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
    5353      var solutions = Assembly.GetExecutingAssembly()
    5454        .GetManifestResourceNames()
     
    6262          .Where(x => x.EndsWith(".atsp"))
    6363          .OrderBy(x => x)
    64           .Select(x => new TSPLIBInstanceDescriptor(GetPrettyName(x), GetDescription(), x, solutions.ContainsKey(x) ? solutions[x] : String.Empty));
     64          .Select(x => new TSPLIBDataDescriptor(GetPrettyName(x), GetDescription(), x, solutions.ContainsKey(x) ? solutions[x] : String.Empty));
    6565    }
    6666
    67     public override ATSPInstance LoadInstance(IInstanceDescriptor id) {
    68       var descriptor = (TSPLIBInstanceDescriptor)id;
     67    public override ATSPData LoadData(IDataDescriptor id) {
     68      var descriptor = (TSPLIBDataDescriptor)id;
    6969      using (var stream = Assembly.GetExecutingAssembly()
    7070        .GetManifestResourceStream(descriptor.InstanceIdentifier)) {
     
    8383    }
    8484
    85     public override ATSPInstance LoadInstance(string path) {
     85    public override ATSPData LoadData(string path) {
    8686      return Load(new TSPLIBParser(path));
    8787    }
    8888
    89     public override void SaveInstance(ATSPInstance instance, string path) {
     89    public override void SaveData(ATSPData instance, string path) {
    9090      throw new NotSupportedException();
    9191    }
    9292
    93     private ATSPInstance Load(TSPLIBParser parser) {
    94       var instance = new ATSPInstance();
     93    private ATSPData Load(TSPLIBParser parser) {
     94      var instance = new ATSPData();
    9595
    9696      parser.Parse();
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBCVRPInstanceProvider.cs

    r7538 r7548  
    2828
    2929namespace HeuristicLab.Problems.Instances.TSPLIB {
    30   public class TSPLIBCVRPInstanceProvider : ProblemInstanceProvider<CVRPInstance> {
     30  public class TSPLIBCVRPInstanceProvider : ProblemInstanceProvider<CVRPData> {
    3131
    3232    public override string Name {
     
    5050    }
    5151
    52     public override IEnumerable<IInstanceDescriptor> GetInstanceDescriptors() {
     52    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
    5353      var solutions = Assembly.GetExecutingAssembly()
    5454        .GetManifestResourceNames()
     
    6161          .Where(x => Regex.Match(x, @".*\.Data\.CVRP\..*").Success)
    6262          .OrderBy(x => x)
    63           .Select(x => new TSPLIBInstanceDescriptor(GetPrettyName(x), GetDescription(), x, solutions.ContainsKey(x) ? solutions[x] : String.Empty));
     63          .Select(x => new TSPLIBDataDescriptor(GetPrettyName(x), GetDescription(), x, solutions.ContainsKey(x) ? solutions[x] : String.Empty));
    6464    }
    6565
    66     public override CVRPInstance LoadInstance(IInstanceDescriptor id) {
    67       var descriptor = (TSPLIBInstanceDescriptor)id;
     66    public override CVRPData LoadData(IDataDescriptor id) {
     67      var descriptor = (TSPLIBDataDescriptor)id;
    6868      using (var stream = Assembly.GetExecutingAssembly()
    6969        .GetManifestResourceStream(descriptor.InstanceIdentifier)) {
     
    8282    }
    8383
    84     public override CVRPInstance LoadInstance(string path) {
     84    public override CVRPData LoadData(string path) {
    8585      return Load(new TSPLIBParser(path));
    8686    }
    8787
    88     public override void SaveInstance(CVRPInstance instance, string path) {
     88    public override void SaveData(CVRPData instance, string path) {
    8989      throw new NotSupportedException();
    9090    }
    9191
    92     private CVRPInstance Load(TSPLIBParser parser) {
     92    private CVRPData Load(TSPLIBParser parser) {
    9393      parser.Parse();
    94       var instance = new CVRPInstance();
     94      var instance = new CVRPData();
    9595      instance.Dimension = parser.Dimension;
    9696      instance.Coordinates = parser.Vertices != null ? parser.Vertices : parser.DisplayVertices;
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBTSPInstanceProvider.cs

    r7538 r7548  
    2828
    2929namespace HeuristicLab.Problems.Instances.TSPLIB {
    30   public class TSPLIBTSPInstanceProvider : ProblemInstanceProvider<TSPInstance> {
     30  public class TSPLIBTSPInstanceProvider : ProblemInstanceProvider<TSPData> {
    3131
    3232    public override string Name {
     
    5050    }
    5151
    52     public override IEnumerable<IInstanceDescriptor> GetInstanceDescriptors() {
     52    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
    5353      var solutions = Assembly.GetExecutingAssembly()
    5454        .GetManifestResourceNames()
     
    6262        .Where(x => x.EndsWith(".tsp"))
    6363        .OrderBy(x => x)
    64         .Select(x => new TSPLIBInstanceDescriptor(GetPrettyName(x), GetDescription(), x, solutions.ContainsKey(x) ? solutions[x] : String.Empty));
     64        .Select(x => new TSPLIBDataDescriptor(GetPrettyName(x), GetDescription(), x, solutions.ContainsKey(x) ? solutions[x] : String.Empty));
    6565    }
    6666
    67     public override TSPInstance LoadInstance(IInstanceDescriptor id) {
    68       var descriptor = (TSPLIBInstanceDescriptor)id;
     67    public override TSPData LoadData(IDataDescriptor id) {
     68      var descriptor = (TSPLIBDataDescriptor)id;
    6969      using (var stream = Assembly.GetExecutingAssembly()
    7070        .GetManifestResourceStream(descriptor.InstanceIdentifier)) {
     
    8484    }
    8585
    86     public override TSPInstance LoadInstance(string path) {
     86    public override TSPData LoadData(string path) {
    8787      return Load(new TSPLIBParser(path));
    8888    }
    8989
    90     public override void SaveInstance(TSPInstance instance, string path) {
     90    public override void SaveData(TSPData instance, string path) {
    9191      throw new NotSupportedException();
    9292    }
    9393
    94     private TSPInstance Load(TSPLIBParser parser) {
     94    private TSPData Load(TSPLIBParser parser) {
    9595      parser.Parse();
    9696      if (parser.FixedEdges != null) throw new InvalidDataException("TSP instance " + parser.Name + " contains fixed edges which are not supported by HeuristicLab.");
    97       var instance = new TSPInstance();
     97      var instance = new TSPData();
    9898      instance.Dimension = parser.Dimension;
    9999      instance.Coordinates = parser.Vertices != null ? parser.Vertices : parser.DisplayVertices;
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances/3.3/HeuristicLab.Problems.Instances-3.3.csproj

    r7538 r7548  
    5454    <None Include="Plugin.cs.frame" />
    5555    <Compile Include="IExportable.cs" />
    56     <Compile Include="Instances\ATSPInstance.cs" />
    57     <Compile Include="Instances\CTAPInstance.cs" />
    58     <Compile Include="IInstanceDescriptor.cs" />
    59     <Compile Include="Instances\CVRPInstance.cs" />
    60     <Compile Include="Instances\GQAPInstance.cs" />
    61     <Compile Include="Instances\QAPInstance.cs" />
    62     <Compile Include="Instances\TSPInstance.cs" />
    63     <Compile Include="IConsumable.cs" />
     56    <Compile Include="Types\ATSPData.cs" />
     57    <Compile Include="Types\CTAPData.cs" />
     58    <Compile Include="IDataDescriptor.cs" />
     59    <Compile Include="Types\CVRPData.cs" />
     60    <Compile Include="Types\GQAPData.cs" />
     61    <Compile Include="Types\QAPData.cs" />
     62    <Compile Include="Types\TSPData.cs" />
     63    <Compile Include="IProblemInstanceConsumer.cs" />
    6464    <Compile Include="IProblemInstanceProvider.cs" />
    6565    <Compile Include="Plugin.cs" />
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances/3.3/IProblemInstanceProvider.cs

    r7538 r7548  
    3232  }
    3333
    34   public interface IProblemInstanceProvider<TInstance> : IProblemInstanceProvider {
    35     IConsumable<TInstance> Consumer { get; set; }
     34  public interface IProblemInstanceProvider<TData> : IProblemInstanceProvider {
     35    IProblemInstanceConsumer<TData> Consumer { get; set; }
    3636
    37     IEnumerable<IInstanceDescriptor> GetInstanceDescriptors();
    38     TInstance LoadInstance(IInstanceDescriptor descriptor);
    39     TInstance LoadInstance(string path);
    40 
    41     void SaveInstance(TInstance instance, string path);
     37    IEnumerable<IDataDescriptor> GetDataDescriptors();
     38    TData LoadData(IDataDescriptor descriptor);
     39    TData LoadData(string path);
     40   
     41    void SaveData(TData instance, string path);
    4242  }
    4343}
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances/3.3/ProblemInstanceProvider.cs

    r7538 r7548  
    2424
    2525namespace HeuristicLab.Problems.Instances {
    26   public abstract class ProblemInstanceProvider<TInstance> : IProblemInstanceProvider<TInstance> {
    27     public virtual IConsumable<TInstance> Consumer { get; set; }
     26  public abstract class ProblemInstanceProvider<TData> : IProblemInstanceProvider<TData> {
     27    public virtual IProblemInstanceConsumer<TData> Consumer { get; set; }
    2828
    2929    public abstract string Name { get; }
     
    3232    public abstract string ReferencePublication { get; }
    3333
    34     public abstract IEnumerable<IInstanceDescriptor> GetInstanceDescriptors();
     34    public abstract IEnumerable<IDataDescriptor> GetDataDescriptors();
    3535
    36     public abstract TInstance LoadInstance(IInstanceDescriptor descriptor);
    37     public abstract TInstance LoadInstance(string path);
     36    public abstract TData LoadData(IDataDescriptor descriptor);
     37    public abstract TData LoadData(string path);
    3838
    39     public abstract void SaveInstance(TInstance instance, string path);
     39    public abstract void SaveData(TData instance, string path);
    4040  }
    4141}
  • branches/GeneralizedQAP/UnitTests/CordeauCrossoverTest.cs

    r7538 r7548  
    3434    public void CordeauCrossoverFunctionalityTest() {
    3535      var provider = new CordeauGQAPInstanceProvider();
    36       var instance = provider.LoadInstance(provider.GetInstanceDescriptors().First());
     36      var instance = provider.LoadData(provider.GetDataDescriptors().First());
    3737      var gqap = new GeneralizedQuadraticAssignmentProblem();
    38       gqap.LoadFrom(instance);
     38      gqap.Load(instance);
    3939
    4040      var random = new MersenneTwister();
  • branches/GeneralizedQAP/UnitTests/CordeauGQAPInstanceProviderTest.cs

    r7538 r7548  
    3434      StringBuilder erroneousInstances = new StringBuilder();
    3535      int count = 0;
    36       foreach (var id in target.GetInstanceDescriptors()) {
     36      foreach (var id in target.GetDataDescriptors()) {
    3737        try {
    38           target.LoadInstance(id);
     38          target.LoadData(id);
    3939        } catch (Exception ex) {
    4040          erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
  • branches/GeneralizedQAP/UnitTests/ElloumiCTAPInstanceProviderTest.cs

    r7538 r7548  
    3434      StringBuilder erroneousInstances = new StringBuilder();
    3535      int count = 0;
    36       foreach (var id in target.GetInstanceDescriptors()) {
     36      foreach (var id in target.GetDataDescriptors()) {
    3737        try {
    38           target.LoadInstance(id);
     38          target.LoadData(id);
    3939        } catch (Exception ex) {
    4040          erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
  • branches/GeneralizedQAP/UnitTests/QAPLIBInstanceProviderTest.cs

    r7538 r7548  
    3535      StringBuilder erroneousInstances = new StringBuilder();
    3636      int count = 0;
    37       foreach (var id in target.GetInstanceDescriptors()) {
     37      foreach (var id in target.GetDataDescriptors()) {
    3838        try {
    39           target.LoadInstance(id);
     39          target.LoadData(id);
    4040        } catch (Exception ex) {
    4141          erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
     
    5454      List<string> nonZeroDiagonalInstances = new List<string>();
    5555      var target = new QAPLIBInstanceProvider();
    56       foreach (var id in target.GetInstanceDescriptors()) {
    57         var instance = target.LoadInstance(id);
     56      foreach (var id in target.GetDataDescriptors()) {
     57        var instance = target.LoadData(id);
    5858        for (int i = 0; i < instance.Dimension; i++)
    5959          if (instance.Distances[i, i] != 0 || instance.Weights[i, i] != 0) {
  • branches/GeneralizedQAP/UnitTests/TSPLIBInstanceProviderTest.cs

    r7538 r7548  
    3434      StringBuilder erroneousInstances = new StringBuilder();
    3535      int count = 0;
    36       foreach (var id in target.GetInstanceDescriptors()) {
     36      foreach (var id in target.GetDataDescriptors()) {
    3737        try {
    38           target.LoadInstance(id);
     38          target.LoadData(id);
    3939        } catch (Exception ex) {
    4040          erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
     
    5151      StringBuilder erroneousInstances = new StringBuilder();
    5252      int count = 0;
    53       foreach (var id in target.GetInstanceDescriptors()) {
     53      foreach (var id in target.GetDataDescriptors()) {
    5454        try {
    55           target.LoadInstance(id);
     55          target.LoadData(id);
    5656        } catch (Exception ex) {
    5757          erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
     
    6868      StringBuilder erroneousInstances = new StringBuilder();
    6969      int count = 0;
    70       foreach (var id in target.GetInstanceDescriptors()) {
     70      foreach (var id in target.GetDataDescriptors()) {
    7171        try {
    72           target.LoadInstance(id);
     72          target.LoadData(id);
    7373        } catch (Exception ex) {
    7474          erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
Note: See TracChangeset for help on using the changeset viewer.