Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/01/12 15:15:22 (12 years ago)
Author:
abeham
Message:

#1614

  • Fixed plugin dependencies
  • Updated GQAP view
  • Changed instances infrastructure
    • Changed interface types into classes
    • Removed the library specific instance classes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/CordeauGQAPInstanceProvider.cs

    r7523 r7538  
    2222using System;
    2323using System.Collections.Generic;
     24using System.IO;
    2425using System.Linq;
    2526using System.Reflection;
     
    2728
    2829namespace HeuristicLab.Problems.Instances.CordeauGQAP {
    29   public class CordeauGQAPInstanceProvider : ProblemInstanceProvider<IGQAPInstance> {
     30  public class CordeauGQAPInstanceProvider : ProblemInstanceProvider<GQAPInstance> {
    3031    public override string Name {
    3132      get { return "Cordeau et al. GQAP instances"; }
     
    5657    }
    5758
    58     public override IGQAPInstance GetInstance(IInstanceDescriptor id) {
     59    public override GQAPInstance LoadInstance(IInstanceDescriptor id) {
    5960      var descriptor = (CordeauGQAPInstanceDescriptor)id;
    60       var instance = new CordeauGQAPInstance();
    6161      using (var stream = Assembly.GetExecutingAssembly()
    6262        .GetManifestResourceStream(descriptor.InstanceIdentifier)) {
    6363        var parser = new CordeauGQAPParser();
    6464        parser.Parse(stream);
    65         if (parser.Error != null) throw parser.Error;
    66         instance.Equipments = parser.Equipments;
    67         instance.Locations = parser.Locations;
    68         instance.Demands = parser.Demands;
    69         instance.Capacities = parser.Capacities;
    70         instance.Weights = parser.Weights;
    71         instance.Distances = parser.Distances;
    72         instance.InstallationCosts = parser.InstallationCosts;
    73         instance.TransportationCosts = parser.TransportationCosts;
     65        var instance = Load(parser);
    7466
    7567        instance.Name = id.Name;
    7668        instance.Description = id.Description;
     69
     70        return instance;
    7771      }
     72    }
     73
     74    public override GQAPInstance LoadInstance(string path) {
     75      var parser = new CordeauGQAPParser();
     76      parser.Parse(path);
     77      var instance = Load(parser);
     78
     79      instance.Name = Path.GetFileName(path);
     80      instance.Description = "Loaded from file \"" + path + "\" on " + DateTime.Now.ToString();
     81
     82      return instance;
     83    }
     84
     85    public override void SaveInstance(GQAPInstance instance, string path) {
     86      throw new NotSupportedException();
     87    }
     88
     89    private GQAPInstance Load(CordeauGQAPParser parser) {
     90      var instance = new GQAPInstance();
     91      instance.Equipments = parser.Equipments;
     92      instance.Locations = parser.Locations;
     93      instance.Demands = parser.Demands;
     94      instance.Capacities = parser.Capacities;
     95      instance.Weights = parser.Weights;
     96      instance.Distances = parser.Distances;
     97      instance.InstallationCosts = parser.InstallationCosts;
     98      instance.TransportationCosts = parser.TransportationCosts;
    7899      return instance;
    79100    }
Note: See TracChangeset for help on using the changeset viewer.