Changeset 15172 for trunk/sources
- Timestamp:
- 07/09/17 13:59:36 (7 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 added
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.GraphColoring/3.3/GraphColoringProblem.cs
r15050 r15172 38 38 [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 135)] 39 39 [StorableClass] 40 public sealed class GraphColoringProblem : SingleObjectiveBasicProblem<LinearLinkageEncoding>, IProblemInstanceConsumer<GCPData> {40 public sealed class GraphColoringProblem : SingleObjectiveBasicProblem<LinearLinkageEncoding>, IProblemInstanceConsumer<GCPData>, IProblemInstanceExporter<GCPData> { 41 41 42 42 public override bool Maximization { … … 115 115 private void FitnessFunctionParameterOnValueChanged(object sender, EventArgs eventArgs) { 116 116 fitnessFunctionParameter.Value.ValueChanged += FitnessFunctionOnValueChanged; 117 OnReset();117 FitnessFunctionOnValueChanged(sender, eventArgs); 118 118 } 119 119 120 120 private void FitnessFunctionOnValueChanged(object sender, EventArgs eventArgs) { 121 121 BestKnownQualityParameter.Value = null; 122 if (FitnessFunction == FitnessFunction.Prioritized 123 && BestKnownColorsParameter.Value != null 124 && Encoding.Length > 0) { 125 var mag = Math.Pow(10, -(int)Math.Ceiling(Math.Log10(Encoding.Length))); 126 // the value is e.g. 0.051 for 0 conflicts with 51 colors (and less than 1000 nodes) 127 BestKnownQuality = BestKnownColorsParameter.Value.Value * mag; 128 } else BestKnownQualityParameter.Value = null; 122 129 OnReset(); 123 130 } … … 242 249 Description = data.Description; 243 250 OnReset(); 251 } 252 253 public GCPData Export() { 254 var instance = new GCPData(); 255 instance.Name = Name; 256 instance.Description = Description; 257 instance.Nodes = Encoding.Length; 258 var adjList = AdjacencyListParameter.Value; 259 instance.Adjacencies = new int[adjList.Rows, 2]; 260 for (var r = 0; r < adjList.Rows; r++) { 261 instance.Adjacencies[r, 0] = adjList[r, 0]; 262 instance.Adjacencies[r, 1] = adjList[r, 1]; 263 } 264 if (BestKnownColorsParameter.Value != null) 265 instance.BestKnownColors = BestKnownColorsParameter.Value.Value; 266 return instance; 244 267 } 245 268 -
trunk/sources/HeuristicLab.Problems.GraphColoring/3.3/HeuristicLab.Problems.GraphColoring-3.3.csproj
r15050 r15172 125 125 </ProjectReference> 126 126 <ProjectReference Include="..\..\HeuristicLab.Encodings.LinearLinkageEncoding\3.4\HeuristicLab.Encodings.LinearLinkageEncoding-3.4.csproj"> 127 <Project>{ 166507c9-ef26-4370-bb80-699742a29d4f}</Project>127 <Project>{be698769-975a-429e-828c-72bb2b6182c8}</Project> 128 128 <Name>HeuristicLab.Encodings.LinearLinkageEncoding-3.4</Name> 129 129 <Private>False</Private> -
trunk/sources/HeuristicLab.Problems.Instances.DIMACS/3.3/GcolInstanceProvider.cs
r15050 r15172 69 69 70 70 using (var stream = entry.Open()) { 71 var parser = new Parser();71 var parser = new GcolParser(); 72 72 parser.Parse(stream); 73 73 var instance = Load(parser); 74 74 instance.Name = id.Name; 75 instance.Description =id.Description;75 instance.Description += Environment.NewLine + id.Description; 76 76 int bestknown; 77 77 if (bkq.TryGetValue(instance.Name, out bestknown)) … … 86 86 } 87 87 public override GCPData ImportData(string path) { 88 var parser = new Parser();88 var parser = new GcolParser(); 89 89 parser.Parse(path); 90 90 var instance = Load(parser); 91 91 instance.Name = Path.GetFileName(path); 92 instance.Description ="Loaded from file \"" + path + "\" on " + DateTime.Now.ToString();92 instance.Description += Environment.NewLine + "Loaded from file \"" + path + "\" on " + DateTime.Now.ToString(); 93 93 return instance; 94 94 } 95 95 96 private GCPData Load( Parser parser) {96 private GCPData Load(GcolParser parser) { 97 97 var instance = new GCPData(); 98 instance.Description = parser.Comments; 98 99 instance.Nodes = parser.Nodes; 99 100 var adjacencies = new int[parser.Edges, 2]; 100 101 var i = 0; 101 102 foreach (var a in parser.AdjacencyList) { 102 adjacencies[i, 0] = a.Item1 - 1;103 adjacencies[i, 1] = a.Item2 - 1;103 adjacencies[i, 0] = a.Item1; 104 adjacencies[i, 1] = a.Item2; 104 105 i++; 105 106 } 106 107 instance.Adjacencies = adjacencies; 107 108 return instance; 109 } 110 111 public override bool CanExportData { get { return true; } } 112 public override void ExportData(GCPData instance, string path) { 113 using (var stream = new StreamWriter(File.Create(path)) { AutoFlush = true }) { 114 stream.WriteLine("c " + instance.Name); 115 foreach (var comment in instance.Description.Split(new[] { Environment.NewLine }, StringSplitOptions.None)) { 116 var c = comment; 117 if (!c.StartsWith("c ")) c = "c " + comment; 118 stream.WriteLine(c); 119 } 120 var edges = instance.Adjacencies.GetLength(0); 121 stream.WriteLine("p edge " + instance.Nodes + " " + edges); 122 for (var i = 0; i < edges; i++) { 123 stream.WriteLine("e " + (instance.Adjacencies[i, 0]+1) + " " + (instance.Adjacencies[i, 1]+1)); 124 } 125 } 108 126 } 109 127 -
trunk/sources/HeuristicLab.Problems.Instances.DIMACS/3.3/HeuristicLab.Problems.Instances.DIMACS-3.3.csproj
r15050 r15172 87 87 <Compile Include="GcolDataDescriptor.cs" /> 88 88 <Compile Include="GcolInstanceProvider.cs" /> 89 <Compile Include=" Parser.cs" />89 <Compile Include="GcolParser.cs" /> 90 90 <EmbeddedResource Include="Data\col.zip" /> 91 91 <None Include="Plugin.cs.frame" /> -
trunk/sources/HeuristicLab.Tests/HeuristicLab.Tests.csproj
r15085 r15172 332 332 <Reference Include="HeuristicLab.Problems.Instances.DataAnalysis-3.3"> 333 333 <HintPath>..\bin\HeuristicLab.Problems.Instances.DataAnalysis-3.3.dll</HintPath> 334 <Private>False</Private> 335 </Reference> 336 <Reference Include="HeuristicLab.Problems.Instances.DIMACS-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 337 <SpecificVersion>False</SpecificVersion> 338 <HintPath>..\bin\HeuristicLab.Problems.Instances.DIMACS-3.3.dll</HintPath> 334 339 <Private>False</Private> 335 340 </Reference> … … 586 591 <Compile Include="HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4\SymbolicDataAnalysisExpressionTreeInterpreterTest.cs" /> 587 592 <Compile Include="HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4\Util.cs" /> 593 <Compile Include="HeuristicLab.Problems.Instances-3.3\DIMACSGcolInstanceProviderTest.cs" /> 588 594 <Compile Include="HeuristicLab.Problems.Instances.DataAnalysis-3.3\RegressionInstanceProviderTest.cs" /> 589 595 <Compile Include="HeuristicLab.Problems.Instances.DataAnalysis-3.3\TableFileParserTest.cs" />
Note: See TracChangeset
for help on using the changeset viewer.