Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7523


Ignore:
Timestamp:
02/24/12 23:27:06 (12 years ago)
Author:
abeham
Message:

#1614

  • sorted operators
  • added crossover defined by Cordeau et al.
  • fixed a few bugs
Location:
branches/GeneralizedQAP
Files:
8 added
11 edited
17 moved

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ProblemInstanceProviderView.Designer.cs

    r7505 r7523  
    7272      // instancesComboBox
    7373      //
     74      this.instancesComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     75            | System.Windows.Forms.AnchorStyles.Right)));
    7476      this.instancesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    7577      this.instancesComboBox.FormattingEnabled = true;
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ProblemView.cs

    r7505 r7523  
    6565        provider.SetConsumer((IProblemInstanceConsumer)Content);
    6666        problemInstanceProviderViewHost.Content = provider;
    67         toolTip.SetToolTip(problemInstanceProviderComboBox, GetProviderToolTip(provider));
    6867      }
    6968    }
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ToolTipComboBox.cs

    r7484 r7523  
    5151    protected override void OnDrawItem(DrawItemEventArgs e) {
    5252      base.OnDrawItem(e);
    53       var args = new ToolTipRequiredEventArgs(e.Index, Items[e.Index]);
    54       OnToolTipRequired(args);
     53      var args = new ToolTipRequiredEventArgs(e.Index, e.Index >= 0 ? Items[e.Index] : null);
     54      if (e.Index >= 0) OnToolTipRequired(args);
    5555      if (!e.State.HasFlag(DrawItemState.ComboBoxEdit) && !string.IsNullOrEmpty(args.ToolTip)) {
    5656        var ttRect = TextRenderer.MeasureText(args.ToolTip, Font);
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GeneralizedQuadraticAssignmentProblem.cs

    r7480 r7523  
    3838  [Creatable("Problems")]
    3939  [StorableClass]
    40   public sealed class GeneralizedQuadraticAssignmentProblem : SingleObjectiveHeuristicOptimizationProblem<IGQAPEvaluator, IGQAPSolutionCreator>, IStorableContent, IProblemInstanceConsumer<IQAPInstance>, IProblemInstanceConsumer<ICTAPInstance>, IProblemInstanceConsumer<ITSPInstance>, IProblemInstanceConsumer<IATSPInstance> {
     40  public sealed class GeneralizedQuadraticAssignmentProblem : SingleObjectiveHeuristicOptimizationProblem<IGQAPEvaluator, IGQAPSolutionCreator>, IStorableContent,
     41    IProblemInstanceConsumer<IQAPInstance>,
     42    IProblemInstanceConsumer<ICTAPInstance>,
     43    IProblemInstanceConsumer<ITSPInstance>,
     44    IProblemInstanceConsumer<IATSPInstance>,
     45    IProblemInstanceConsumer<IGQAPInstance> {
    4146
    4247    public override Image ItemImage {
     
    208213    }
    209214
     215    #region Problem Instance Consumptions
    210216    public bool LoadFrom(IQAPInstance instance) {
    211217      try {
     
    330336    }
    331337
     338    public bool LoadFrom(IGQAPInstance 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
     367
    332368    private void EvaluateAndLoadAssignment(int[] vector) {
    333369      EvaluateAndLoadAssignment(new IntegerVector(vector));
    334370    }
    335371    private void EvaluateAndLoadAssignment(IntegerVector assignment) {
    336       if (!IsConfigurationValid()) return;
     372      if (!IsConfigurationValid()) {
     373        BestKnownQuality = null;
     374        BestKnownSolution = null;
     375        BestKnownSolutions = null;
     376      }
    337377      double flowDistanceQuality, installationQuality, overbookedCapacity;
    338378      GQAPEvaluator.Evaluate(assignment, Weights, Distances, InstallationCosts, Demands, Capacities,
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment-3.3.csproj

    r7505 r7523  
    9999    <Compile Include="Evaluators\GQAPNMoveEvaluator.cs" />
    100100    <Compile Include="GQAPAssignment.cs" />
     101    <Compile Include="Operators\Crossovers\CordeauCrossover.cs" />
     102    <Compile Include="SolutionCreators\GQAPSolutionCreator.cs" />
     103    <Compile Include="SolutionCreators\GQAPStochasticSolutionCreator.cs" />
     104    <Compile Include="SolutionCreators\GreedyRandomizedSolutionCreator.cs" />
     105    <Compile Include="SolutionCreators\RandomSolutionCreator.cs" />
    101106    <None Include="Plugin.cs.frame" />
    102107    <Compile Include="Evaluators\GQAPEvaluator.cs" />
     
    140145    <Compile Include="Moves\StochasticNMoveMultiMoveGenerator.cs" />
    141146    <Compile Include="Moves\StochasticNMoveSingleMoveGenerator.cs" />
    142     <Compile Include="Operators\ApproximateLocalSearch.cs" />
    143     <Compile Include="Operators\MultiGQAPCrossover.cs" />
    144     <Compile Include="Operators\GQAPPathRelinking.cs" />
    145     <Compile Include="Operators\GQAPStochasticSolutionCreator.cs" />
    146     <Compile Include="Operators\DemandEquivalentSwapEquipmentManipluator.cs" />
    147     <Compile Include="Operators\GQAPCrossover.cs" />
    148     <Compile Include="Operators\DiscreteLocationCrossover.cs" />
    149     <Compile Include="Operators\GQAPSolutionCreator.cs" />
    150     <Compile Include="Operators\GreedyRandomizedSolutionCreator.cs" />
    151     <Compile Include="Operators\MultiGQAPManipulator.cs" />
    152     <Compile Include="Operators\NMoveShakingOperator.cs" />
    153     <Compile Include="Operators\GQAPQualitySimilarityReducer.cs" />
    154     <Compile Include="Operators\RandomSolutionCreator.cs" />
    155     <Compile Include="Operators\RelocateEquipmentManipluator.cs" />
    156     <Compile Include="Operators\GQAPManipulator.cs" />
    157     <Compile Include="Operators\SwapEquipmentManipluator.cs" />
    158     <Compile Include="Operators\SwapLocationManipulator.cs" />
     147    <Compile Include="Operators\Crossovers\DiscreteLocationCrossover.cs" />
     148    <Compile Include="Operators\Crossovers\GQAPCrossover.cs" />
     149    <Compile Include="Operators\Crossovers\GQAPPathRelinking.cs" />
     150    <Compile Include="Operators\Crossovers\MultiGQAPCrossover.cs" />
     151    <Compile Include="Operators\LocalImprovers\ApproximateLocalSearch.cs" />
     152    <Compile Include="Operators\Manipulators\DemandEquivalentSwapEquipmentManipluator.cs" />
     153    <Compile Include="Operators\Manipulators\GQAPManipulator.cs" />
     154    <Compile Include="Operators\Manipulators\MultiGQAPManipulator.cs" />
     155    <Compile Include="Operators\Manipulators\RelocateEquipmentManipluator.cs" />
     156    <Compile Include="Operators\Manipulators\SwapEquipmentManipluator.cs" />
     157    <Compile Include="Operators\Manipulators\SwapLocationManipulator.cs" />
     158    <Compile Include="Operators\PopulationReducers\GQAPQualitySimilarityReducer.cs" />
     159    <Compile Include="Operators\Shakers\NMoveShakingOperator.cs" />
    159160    <Compile Include="Plugin.cs" />
    160161    <Compile Include="Properties\AssemblyInfo.cs" />
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/CordeauGQAPInstance.cs

    r7505 r7523  
    3434
    3535    public double TransportationCosts { get; set; }
     36
     37    public int[] BestKnownAssignment { get; set; }
     38    public double? BestKnownQuality { get; set; }
    3639  }
    3740}
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/CordeauGQAPInstanceProvider.cs

    r7505 r7523  
    6161      using (var stream = Assembly.GetExecutingAssembly()
    6262        .GetManifestResourceStream(descriptor.InstanceIdentifier)) {
    63         var datParser = new CordeauGQAPParser();
    64         datParser.Parse(stream);
    65         if (datParser.Error != null) throw datParser.Error;
    66         instance.Equipments = datParser.Equipments;
    67         instance.Locations = datParser.Locations;
    68         instance.Weights = datParser.Weights;
    69         instance.Distances = datParser.Distances;
    70         instance.InstallationCosts = datParser.InstallationCosts;
    71         instance.TransportationCosts = datParser.TransportationCosts;
     63        var parser = new CordeauGQAPParser();
     64        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;
    7274
    7375        instance.Name = id.Name;
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBParser.cs

    r7470 r7523  
    467467    /// terminates the section.
    468468    /// So the parser peeks at the next character after a -1. If the next character
    469     /// is an E as in EOF or the stream ends, the parser breaks. Otherwise it will
     469    /// is an E as in EOF or the stream ends, the parser ends. Otherwise it will
    470470    /// continue to read tours until a -1 is followed by a -1.
    471471    /// </remarks>
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances/3.3/Instances/IGQAPInstance.cs

    r7505 r7523  
    2020#endregion
    2121
    22 namespace HeuristicLab.Problems.Instances{
     22namespace HeuristicLab.Problems.Instances {
     23  /// <summary>
     24  /// Describes an instance of the Generalized Quadratic Assignment Problem (GQAP).
     25  /// </summary>
    2326  public interface IGQAPInstance {
    24 
     27    /// <summary>
     28    /// The name of the instance.
     29    /// </summary>
    2530    string Name { get; }
     31    /// <summary>
     32    /// A description of the instance.
     33    /// </summary>
    2634    string Description { get; }
    2735
     36    /// <summary>
     37    /// |E| = The number of equipments are to be assigned in this instance.
     38    /// </summary>
    2839    int Equipments { get; }
     40    /// <summary>
     41    /// |L| = The number of locations that are available for the equipments.
     42    /// </summary>
    2943    int Locations { get; }
     44    /// <summary>
     45    /// Vector of length |E| that describes the space demand for the equipments.
     46    /// </summary>
    3047    double[] Demands { get; }
     48    /// <summary>
     49    /// Vector of length |L| that describes the space capacity for the locations.
     50    /// </summary>
    3151    double[] Capacities { get; }
     52    /// <summary>
     53    /// |E|x|E| matrix with the weights (flows) between the equipments. These describe the strength of the respective bonding.
     54    /// </summary>
    3255    double[,] Weights { get; }
     56    /// <summary>
     57    /// |L|x|L| matrix with the distances between the locations.
     58    /// </summary>
    3359    double[,] Distances { get; }
     60    /// <summary>
     61    /// |E|x|L| matrix that describes the costs of installing equipment x at location y.
     62    /// </summary>
    3463    double[,] InstallationCosts { get; }
     64    /// <summary>
     65    /// A factor that scales the weights.
     66    /// </summary>
     67    double TransportationCosts { get; }
    3568
    36     double TransportationCosts { get; }
     69    /// <summary>
     70    /// Optional! The best-known assignment is a vector of length |E| with numbers ranging from 0 to |L| - 1
     71    /// </summary>
     72    int[] BestKnownAssignment { get; }
     73    /// <summary>
     74    /// Optional! The quality of the best-known assignment.
     75    /// </summary>
     76    double? BestKnownQuality { get; }
    3777  }
    3878}
  • branches/GeneralizedQAP/UnitTests/QAPLIBInstanceProviderTest.cs

    r7505 r7523  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Text;
    2425using HeuristicLab.Problems.Instances.QAPLIB;
     
    4546      Assert.IsTrue(erroneousInstances.Length == 0, "Some instances could not be parsed: " + Environment.NewLine + erroneousInstances.ToString());
    4647    }
     48
     49    /// <summary>
     50    ///A test for GetInstance
     51    ///</summary>
     52    [TestMethod()]
     53    public void GetInstanceTest() {
     54      List<string> nonZeroDiagonalInstances = new List<string>();
     55      var target = new QAPLIBInstanceProvider();
     56      foreach (var id in target.GetInstanceDescriptors()) {
     57        var instance = target.GetInstance(id);
     58        for (int i = 0; i < instance.Dimension; i++)
     59          if (instance.Distances[i, i] != 0 || instance.Weights[i, i] != 0) {
     60            nonZeroDiagonalInstances.Add(instance.Name);
     61            break;
     62          }
     63      }
     64
     65      Assert.IsTrue(nonZeroDiagonalInstances.Count == 0, string.Join(Environment.NewLine, nonZeroDiagonalInstances));
     66    }
    4767  }
    4868}
  • branches/GeneralizedQAP/UnitTests/UnitTests.csproj

    r7505 r7523  
    9797  </ItemGroup>
    9898  <ItemGroup>
     99    <Compile Include="CordeauCrossoverTest.cs" />
    99100    <Compile Include="CordeauGQAPInstanceProviderTest.cs" />
    100101    <Compile Include="ElloumiCTAPInstanceProviderTest.cs" />
Note: See TracChangeset for help on using the changeset viewer.