Changeset 7523
- Timestamp:
- 02/24/12 23:27:06 (13 years ago)
- 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 72 72 // instancesComboBox 73 73 // 74 this.instancesComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 75 | System.Windows.Forms.AnchorStyles.Right))); 74 76 this.instancesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 75 77 this.instancesComboBox.FormattingEnabled = true; -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ProblemView.cs
r7505 r7523 65 65 provider.SetConsumer((IProblemInstanceConsumer)Content); 66 66 problemInstanceProviderViewHost.Content = provider; 67 toolTip.SetToolTip(problemInstanceProviderComboBox, GetProviderToolTip(provider));68 67 } 69 68 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ToolTipComboBox.cs
r7484 r7523 51 51 protected override void OnDrawItem(DrawItemEventArgs e) { 52 52 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); 55 55 if (!e.State.HasFlag(DrawItemState.ComboBoxEdit) && !string.IsNullOrEmpty(args.ToolTip)) { 56 56 var ttRect = TextRenderer.MeasureText(args.ToolTip, Font); -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GeneralizedQuadraticAssignmentProblem.cs
r7480 r7523 38 38 [Creatable("Problems")] 39 39 [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> { 41 46 42 47 public override Image ItemImage { … … 208 213 } 209 214 215 #region Problem Instance Consumptions 210 216 public bool LoadFrom(IQAPInstance instance) { 211 217 try { … … 330 336 } 331 337 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 332 368 private void EvaluateAndLoadAssignment(int[] vector) { 333 369 EvaluateAndLoadAssignment(new IntegerVector(vector)); 334 370 } 335 371 private void EvaluateAndLoadAssignment(IntegerVector assignment) { 336 if (!IsConfigurationValid()) return; 372 if (!IsConfigurationValid()) { 373 BestKnownQuality = null; 374 BestKnownSolution = null; 375 BestKnownSolutions = null; 376 } 337 377 double flowDistanceQuality, installationQuality, overbookedCapacity; 338 378 GQAPEvaluator.Evaluate(assignment, Weights, Distances, InstallationCosts, Demands, Capacities, -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment-3.3.csproj
r7505 r7523 99 99 <Compile Include="Evaluators\GQAPNMoveEvaluator.cs" /> 100 100 <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" /> 101 106 <None Include="Plugin.cs.frame" /> 102 107 <Compile Include="Evaluators\GQAPEvaluator.cs" /> … … 140 145 <Compile Include="Moves\StochasticNMoveMultiMoveGenerator.cs" /> 141 146 <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" /> 159 160 <Compile Include="Plugin.cs" /> 160 161 <Compile Include="Properties\AssemblyInfo.cs" /> -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/CordeauGQAPInstance.cs
r7505 r7523 34 34 35 35 public double TransportationCosts { get; set; } 36 37 public int[] BestKnownAssignment { get; set; } 38 public double? BestKnownQuality { get; set; } 36 39 } 37 40 } -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/CordeauGQAPInstanceProvider.cs
r7505 r7523 61 61 using (var stream = Assembly.GetExecutingAssembly() 62 62 .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; 72 74 73 75 instance.Name = id.Name; -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBParser.cs
r7470 r7523 467 467 /// terminates the section. 468 468 /// 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 will469 /// is an E as in EOF or the stream ends, the parser ends. Otherwise it will 470 470 /// continue to read tours until a -1 is followed by a -1. 471 471 /// </remarks> -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances/3.3/Instances/IGQAPInstance.cs
r7505 r7523 20 20 #endregion 21 21 22 namespace HeuristicLab.Problems.Instances{ 22 namespace HeuristicLab.Problems.Instances { 23 /// <summary> 24 /// Describes an instance of the Generalized Quadratic Assignment Problem (GQAP). 25 /// </summary> 23 26 public interface IGQAPInstance { 24 27 /// <summary> 28 /// The name of the instance. 29 /// </summary> 25 30 string Name { get; } 31 /// <summary> 32 /// A description of the instance. 33 /// </summary> 26 34 string Description { get; } 27 35 36 /// <summary> 37 /// |E| = The number of equipments are to be assigned in this instance. 38 /// </summary> 28 39 int Equipments { get; } 40 /// <summary> 41 /// |L| = The number of locations that are available for the equipments. 42 /// </summary> 29 43 int Locations { get; } 44 /// <summary> 45 /// Vector of length |E| that describes the space demand for the equipments. 46 /// </summary> 30 47 double[] Demands { get; } 48 /// <summary> 49 /// Vector of length |L| that describes the space capacity for the locations. 50 /// </summary> 31 51 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> 32 55 double[,] Weights { get; } 56 /// <summary> 57 /// |L|x|L| matrix with the distances between the locations. 58 /// </summary> 33 59 double[,] Distances { get; } 60 /// <summary> 61 /// |E|x|L| matrix that describes the costs of installing equipment x at location y. 62 /// </summary> 34 63 double[,] InstallationCosts { get; } 64 /// <summary> 65 /// A factor that scales the weights. 66 /// </summary> 67 double TransportationCosts { get; } 35 68 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; } 37 77 } 38 78 } -
branches/GeneralizedQAP/UnitTests/QAPLIBInstanceProviderTest.cs
r7505 r7523 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Text; 24 25 using HeuristicLab.Problems.Instances.QAPLIB; … … 45 46 Assert.IsTrue(erroneousInstances.Length == 0, "Some instances could not be parsed: " + Environment.NewLine + erroneousInstances.ToString()); 46 47 } 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 } 47 67 } 48 68 } -
branches/GeneralizedQAP/UnitTests/UnitTests.csproj
r7505 r7523 97 97 </ItemGroup> 98 98 <ItemGroup> 99 <Compile Include="CordeauCrossoverTest.cs" /> 99 100 <Compile Include="CordeauGQAPInstanceProviderTest.cs" /> 100 101 <Compile Include="ElloumiCTAPInstanceProviderTest.cs" />
Note: See TracChangeset
for help on using the changeset viewer.