$darkmode
DENOPTIM
GraphListsHandler.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2022 Marco Foscato <marco.foscato@uib.no>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package denoptim.programs.graphlisthandler;
20
21import java.io.File;
22import java.util.HashSet;
23import java.util.Set;
24import java.util.logging.Level;
25
26import denoptim.graph.DGraph;
27import denoptim.task.ProgramTask;
28
29
36public class GraphListsHandler extends ProgramTask
37{
38
39//------------------------------------------------------------------------------
40
46 public GraphListsHandler(File configFile, File workDir)
47 {
48 super(configFile,workDir);
49 }
50
51//------------------------------------------------------------------------------
52
53 @Override
54 public void runProgram() throws Throwable
55 {
57 glhParams.readParameterFile(configFilePathName.getAbsolutePath());
58 glhParams.checkParameters();
59 glhParams.processParameters();
60 glhParams.startProgramSpecificLogger(loggerIdentifier,false); //to STDOUT
61 glhParams.printParameters();
62
63 Set<DGraph> matchedA = new HashSet<DGraph>();
64 Set<DGraph> matchedB = new HashSet<DGraph>();
65
66 int i = -1;
67 for (DGraph gA : glhParams.inGraphsA)
68 {
69 i++;
70 int j = -1;
71 for (DGraph gB : glhParams.inGraphsB)
72 {
73 j++;
74 glhParams.getLogger().log(Level.INFO, NL + "-> Comparing " + i
75 + " and "+j);
76 if (gA.isIsomorphicTo(gB))
77 {
78 glhParams.getLogger().log(Level.INFO, " SAME!");
79 matchedA.add(gA);
80 matchedB.add(gB);
81 break;
82 } else {
83 glhParams.getLogger().log(Level.INFO, " Different");
84 }
85 }
86 }
87
88 glhParams.getLogger().log(Level.INFO, NL + " #Matches in list A: "
89 + matchedA.size()+"/"
90 + glhParams.inGraphsA.size());
91 glhParams.getLogger().log(Level.INFO, " #Matches in list B: "
92 + matchedB.size()+"/"
93 + glhParams.inGraphsB.size());
94
95 glhParams.getLogger().log(Level.INFO, NL + " ===> Un-matches in list A");
96 int ii = -1;
97 for (DGraph gA : glhParams.inGraphsA)
98 {
99 ii++;
100 if (matchedA.contains(gA))
101 {
102 continue;
103 }
104 glhParams.getLogger().log(Level.INFO, NL + "Entry in original list "
105 + "#" + ii);
106 glhParams.getLogger().log(Level.INFO, gA.toString());
107 }
108
109 glhParams.getLogger().log(Level.INFO, NL + " ===> Un-matches in list B");
110 int jj = -1;
111 for (DGraph gB : glhParams.inGraphsB)
112 {
113 jj++;
114 if (matchedB.contains(gB))
115 {
116 continue;
117 }
118 glhParams.getLogger().log(Level.INFO, NL + "Entry in original list"
119 + " #" + jj);
120 glhParams.getLogger().log(Level.INFO, gB.toString());
121 }
122 }
123
124//------------------------------------------------------------------------------
125
126}
Container for the list of vertices and the edges that connect them.
Definition: DGraph.java:102
boolean isIsomorphicTo(DGraph other)
Checks if this graph is "DENOPTIM-isomorphic" to the other one given.
Definition: DGraph.java:3453
Logger startProgramSpecificLogger(String loggerIdentifier)
Starts a logger with the given name.
void readParameterFile(String infile)
Read the parameter TXT file line by line and interpret its content.
Logger getLogger()
Get the name of the program specific logger.
void printParameters()
Print all parameters.
GraphListsHandler(File configFile, File workDir)
Creates and configures the program task.
void processParameters()
Processes all parameters and initialize related objects.
Task structure for any of the main programs in the denoptim project, such as genetic algorithm and co...
String loggerIdentifier
Identifier of this program's logger.
File configFilePathName
File containing configuration parameters for the program task.
File workDir
The file system location where we want to be placed when doing the work.
Definition: Task.java:78
final String NL
System-dependent line separator (newline)
Definition: Task.java:93