Changeset 7448
- Timestamp:
- 02/03/12 18:22:41 (13 years ago)
- Location:
- branches/GeneralizedQAP
- Files:
-
- 7 added
- 3 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common/3.3/ExtensionMethods.cs
r7432 r7448 331 331 } 332 332 #endregion 333 334 #region Matrix operations 335 public static double[,] Transpose(this double[,] matrix) { 336 var result = new double[matrix.GetLength(1), matrix.GetLength(0)]; 337 for (int i = 0; i < matrix.GetLength(0); i++) 338 for (int j = 0; j < matrix.GetLength(1); j++) 339 result[j, i] = matrix[i, j]; 340 return result; 341 } 342 #endregion 333 343 } 334 344 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/GQAPAssignmentView.cs
r7438 r7448 210 210 kvp.Key.BackColor = assignmentTreeView.BackColor; 211 211 kvp.Key.ForeColor = assignmentTreeView.ForeColor; 212 } 213 int colorComponent = (int)(255 * Math.Pow((max - kvp.Value) / max, 2)); 214 kvp.Key.BackColor = Color.FromArgb(255, colorComponent, colorComponent); 215 if (kvp.Key.BackColor.GetBrightness() < BrightnessLevel) kvp.Key.ForeColor = Color.White; 216 else kvp.Key.ForeColor = Color.Black; 212 } else { 213 int colorComponent = (int)(255 * Math.Pow((max - kvp.Value) / max, 2)); 214 kvp.Key.BackColor = Color.FromArgb(255, colorComponent, colorComponent); 215 if (kvp.Key.BackColor.GetBrightness() < BrightnessLevel) kvp.Key.ForeColor = Color.White; 216 else kvp.Key.ForeColor = Color.Black; 217 } 217 218 } 218 219 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views-3.3.csproj
r7445 r7448 88 88 </ItemGroup> 89 89 <ItemGroup> 90 <Compile Include=" GQAPProblemView.cs">90 <Compile Include="ProblemInstanceProviderView.cs"> 91 91 <SubType>UserControl</SubType> 92 92 </Compile> 93 <Compile Include="GQAPProblemView.Designer.cs"> 94 <DependentUpon>GQAPProblemView.cs</DependentUpon> 93 <Compile Include="ProblemInstanceProviderView.Designer.cs"> 94 <DependentUpon>ProblemInstanceProviderView.cs</DependentUpon> 95 </Compile> 96 <Compile Include="ProblemView.cs"> 97 <SubType>UserControl</SubType> 98 </Compile> 99 <Compile Include="ProblemView.Designer.cs"> 100 <DependentUpon>ProblemView.cs</DependentUpon> 95 101 </Compile> 96 102 <Compile Include="GQAPAssignmentArchiveView.cs"> … … 125 131 </ItemGroup> 126 132 <ItemGroup> 127 <EmbeddedResource Include="GQAPProblemView.resx"> 128 <DependentUpon>GQAPProblemView.cs</DependentUpon> 133 <EmbeddedResource Include="ProblemInstanceProviderView.resx"> 134 <DependentUpon>ProblemInstanceProviderView.cs</DependentUpon> 135 </EmbeddedResource> 136 <EmbeddedResource Include="ProblemView.resx"> 137 <DependentUpon>ProblemView.cs</DependentUpon> 129 138 </EmbeddedResource> 130 139 <EmbeddedResource Include="GQAPAssignmentArchiveView.resx"> -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Analyzers/GQAPSolutionArchiveUpdater.cs
r7438 r7448 31 31 for (int i = 0; i < front.Count - 1; i++) { 32 32 for (int j = i + 1; j < front.Count; j++) { 33 if (front[i].FlowDistanceQuality.Value < front[j].FlowDistanceQuality.Value34 && front[i].InstallationQuality.Value < front[j].InstallationQuality.Value) {33 if (front[i].FlowDistanceQuality.Value <= front[j].FlowDistanceQuality.Value 34 && front[i].InstallationQuality.Value <= front[j].InstallationQuality.Value) { 35 35 front.RemoveAt(j); 36 36 j--; 37 } else if (front[i].FlowDistanceQuality.Value > front[j].FlowDistanceQuality.Value38 && front[i].InstallationQuality.Value > front[j].InstallationQuality.Value) {37 } else if (front[i].FlowDistanceQuality.Value >= front[j].FlowDistanceQuality.Value 38 && front[i].InstallationQuality.Value >= front[j].InstallationQuality.Value) { 39 39 front.RemoveAt(i); 40 40 j = i; -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GeneralizedQuadraticAssignmentProblem.cs
r7445 r7448 31 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 32 using HeuristicLab.PluginInfrastructure; 33 using HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common; 33 34 using HeuristicLab.Problems.Instances; 34 35 … … 37 38 [Creatable("Problems")] 38 39 [StorableClass] 39 public sealed class GeneralizedQuadraticAssignmentProblem : SingleObjectiveHeuristicOptimizationProblem<IGQAPEvaluator, IGQAPSolutionCreator>, IStorableContent {40 public sealed class GeneralizedQuadraticAssignmentProblem : SingleObjectiveHeuristicOptimizationProblem<IGQAPEvaluator, IGQAPSolutionCreator>, IStorableContent, IProblemInstanceConsumer<IQAPInstance>, IProblemInstanceConsumer<ICTAPInstance> { 40 41 41 42 public override Image ItemImage { … … 138 139 set { BestKnownSolutionParameter.Value = value; } 139 140 } 141 public GQAPAssignmentArchive BestKnownSolutions { 142 get { return BestKnownSolutionsParameter.Value; } 143 set { BestKnownSolutionsParameter.Value = value; } 144 } 140 145 #endregion 141 146 … … 202 207 203 208 public void LoadFrom(IQAPInstance instance) { 209 Name = instance.Name; 210 Description = instance.Description; 211 204 212 Weights = new DoubleMatrix(instance.Weights); 205 213 Distances = new DoubleMatrix(instance.Distances); … … 212 220 if (instance.BestKnownAssignment != null) { 213 221 EvaluateAndLoadAssignment(instance.BestKnownAssignment); 222 } else { 223 BestKnownQuality = null; 224 BestKnownSolution = null; 225 BestKnownSolutions = null; 214 226 } 215 227 } 216 228 217 229 public void LoadFrom(ICTAPInstance instance) { 230 Name = instance.Name; 231 Description = instance.Description; 232 218 233 Capacities = new DoubleArray(instance.MemoryCapacities); 219 234 Demands = new DoubleArray(instance.MemoryRequirements); 220 235 Weights = new DoubleMatrix(instance.CommunicationCosts); 221 InstallationCosts = new DoubleMatrix(instance.ExecutionCosts );236 InstallationCosts = new DoubleMatrix(instance.ExecutionCosts.Transpose()); 222 237 Distances = new DoubleMatrix(Capacities.Length, Capacities.Length); // all one, except diagonal 223 238 for (int i = 0; i < Capacities.Length - 1; i++) … … 231 246 if (instance.BestKnownAssignment != null) { 232 247 EvaluateAndLoadAssignment(instance.BestKnownAssignment); 248 } else { 249 BestKnownQuality = null; 250 BestKnownSolution = null; 251 BestKnownSolutions = null; 233 252 } 234 253 } … … 242 261 BestKnownSolution = new GQAPSolution(assignment, new DoubleValue(quality), new DoubleValue(flowDistanceQuality), new DoubleValue(installationQuality), new DoubleValue(overbookedCapacity)); 243 262 BestKnownQuality = new DoubleValue(quality); 263 BestKnownSolutions = new GQAPAssignmentArchive(EquipmentNames, LocationNames, Distances, Weights, InstallationCosts, Demands, Capacities, TransportationCosts, OverbookedCapacityPenalty); 264 BestKnownSolutions.Solutions.Add((GQAPSolution)BestKnownSolution.Clone()); 244 265 } 245 266 -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.ElloumiCTAP/3.3/ElloumiCTAPInstanceProvider.cs
r7445 r7448 29 29 namespace HeuristicLab.Problems.Instances.ElloumiCTAP { 30 30 public class ElloumiCTAPInstanceProvider : IProblemInstanceProvider<ICTAPInstance> { 31 private IProblemInstanceConsumer<ICTAPInstance> consumer; 32 31 33 public string Name { 32 34 get { return "Elloumi's CTAP instances"; } … … 39 41 public Uri Link { 40 42 get { return new Uri("http://cedric.cnam.fr/oc/TAP/TAP.html"); } 43 } 44 45 public bool ConsumerCanBeFed { 46 get { return consumer != null; } 47 } 48 49 public void SetConsumer(IProblemInstanceConsumer consumer) { 50 if (consumer is IProblemInstanceConsumer<ICTAPInstance>) 51 this.consumer = (IProblemInstanceConsumer<ICTAPInstance>)consumer; 52 else this.consumer = null; 53 } 54 55 public void FeedConsumer(IInstanceDescriptor descriptor) { 56 consumer.LoadFrom(GetInstance(descriptor)); 41 57 } 42 58 -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.ElloumiCTAP/3.3/ElloumiCTAPParser.cs
r7445 r7448 89 89 string[] costsTaskToTasks = line.Split(separator, StringSplitOptions.RemoveEmptyEntries); 90 90 for (int j = i + 1; j < Tasks; j++) { 91 CommunicationCosts[i, j] = double.Parse(costsTaskToTasks[j ], CultureInfo.InvariantCulture.NumberFormat);91 CommunicationCosts[i, j] = double.Parse(costsTaskToTasks[j - i - 1], CultureInfo.InvariantCulture.NumberFormat); 92 92 CommunicationCosts[j, i] = CommunicationCosts[i, j]; 93 93 } -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.ElloumiCTAP/3.3/ElloumiCTAPSolutionParser.cs
r7445 r7448 56 56 for (int i = 0; i < tasks; i++) { 57 57 string[] assign = line.Split(delim, StringSplitOptions.RemoveEmptyEntries); 58 Assignment[int.Parse(assign[0]) ] = int.Parse(assign[1]);58 Assignment[int.Parse(assign[0]) - 1] = int.Parse(assign[1]) - 1; 59 59 line = Continue(reader); 60 60 } -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.ElloumiCTAP/3.3/HeuristicLab.Problems.Instances.ElloumiCTAP-3.3.csproj
r7445 r7448 38 38 </PropertyGroup> 39 39 <ItemGroup> 40 <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 41 <Private>False</Private> 42 </Reference> 40 43 <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 41 44 <Private>False</Private> -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.QAPLIB/3.3/HeuristicLab.Problems.Instances.QAPLIB-3.3.csproj
r7445 r7448 38 38 </PropertyGroup> 39 39 <ItemGroup> 40 <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 41 <Private>False</Private> 42 </Reference> 40 43 <Reference Include="HeuristicLab.PluginInfrastructure-3.3"> 41 44 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath> -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.QAPLIB/3.3/Plugin.cs
r7445 r7448 23 23 24 24 namespace HeuristicLab.Problems.Instances { 25 [Plugin("HeuristicLab.Problems.Instances.QAPLIB", "3.3.6.744 4")]25 [Plugin("HeuristicLab.Problems.Instances.QAPLIB", "3.3.6.7445")] 26 26 [PluginFile("HeuristicLab.Problems.Instances.QAPLIB-3.3.dll", PluginFileType.Assembly)] 27 27 public class HeuristicLabProblemsInstancesQAPLIBPlugin : PluginBase { -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.QAPLIB/3.3/QAPLIBInstanceProvider.cs
r7445 r7448 29 29 namespace HeuristicLab.Problems.Instances.QAPLIB { 30 30 public class QAPLIBInstanceProvider : IProblemInstanceProvider<IQAPInstance> { 31 IProblemInstanceConsumer<IQAPInstance> consumer; 32 31 33 public string Name { 32 34 get { return "QAPLIB"; } … … 39 41 public Uri Link { 40 42 get { return new Uri("http://www.seas.upenn.edu/qaplib/"); } 43 } 44 45 public bool ConsumerCanBeFed { 46 get { return consumer != null; } 47 } 48 49 public void SetConsumer(IProblemInstanceConsumer consumer) { 50 if (consumer is IProblemInstanceConsumer<IQAPInstance>) 51 this.consumer = (IProblemInstanceConsumer<IQAPInstance>)consumer; 52 else this.consumer = null; 53 } 54 55 public void FeedConsumer(IInstanceDescriptor descriptor) { 56 consumer.LoadFrom(GetInstance(descriptor)); 41 57 } 42 58 -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances/3.3/HeuristicLab.Problems.Instances-3.3.csproj
r7445 r7448 55 55 <Compile Include="IInstanceDescriptor.cs" /> 56 56 <Compile Include="Instances\IQAPInstance.cs" /> 57 <Compile Include="IProblemInstanceConsumer.cs" /> 57 58 <Compile Include="IProblemInstanceProvider.cs" /> 58 59 <Compile Include="Plugin.cs" /> -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances/3.3/IProblemInstanceProvider.cs
r7445 r7448 22 22 using System; 23 23 using System.Collections.Generic; 24 using HeuristicLab.Common; 24 25 25 26 namespace HeuristicLab.Problems.Instances { 26 public interface IProblemInstanceProvider {27 public interface IProblemInstanceProvider : IContent { 27 28 string Name { get; } 28 29 string Description { get; } 29 30 Uri Link { get; } 31 32 bool ConsumerCanBeFed { get; } 33 34 void SetConsumer(IProblemInstanceConsumer consumer); 35 void FeedConsumer(IInstanceDescriptor descriptor); 30 36 31 37 IEnumerable<IInstanceDescriptor> GetInstanceDescriptors(); -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances/3.3/Plugin.cs
r7445 r7448 23 23 24 24 namespace HeuristicLab.Problems.Instances { 25 [Plugin("HeuristicLab.Problems.Instances", "3.3.6.744 4")]25 [Plugin("HeuristicLab.Problems.Instances", "3.3.6.7445")] 26 26 [PluginFile("HeuristicLab.Problems.Instances-3.3.dll", PluginFileType.Assembly)] 27 27 public class HeuristicLabProblemsInstancesPlugin : PluginBase {
Note: See TracChangeset
for help on using the changeset viewer.