$darkmode
DENOPTIM
IsomorphismParameters.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2019 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.isomorphism;
20
21import java.lang.reflect.Field;
22
23import denoptim.exception.DENOPTIMException;
24import denoptim.files.FileUtils;
25import denoptim.programs.RunTimeParameters;
26
27
35{
39 protected String inpFileGraphA;
40
44 protected String inpFileGraphB;
45
46//-----------------------------------------------------------------------------
47
52 {
54 }
55
56//-----------------------------------------------------------------------------
57
65 public void interpretKeyword(String key, String value)
67 {
68
69 String msg = "";
70 switch (key.toUpperCase())
71 {
72 case "INPGRAPHA=":
73 inpFileGraphA = value;
74 break;
75 case "INPGRAPHB=":
76 inpFileGraphB = value;
77 break;
78 default:
79 msg = "Keyword " + key + " is not a known Isomorphism-"
80 + "related keyword. Check input files.";
81 throw new DENOPTIMException(msg);
82 }
83 }
84
85//-----------------------------------------------------------------------------
86
93 {
94 String msg = "";
95
97 {
98 msg = "Input file '" + inpFileGraphA + "' not found.";
99 throw new DENOPTIMException(msg);
100 }
101
103 {
104 msg = "Input file '" + inpFileGraphB + "' not found.";
105 throw new DENOPTIMException(msg);
106 }
107
109 }
110
111//----------------------------------------------------------------------------
112
119 {
121 }
122
123//------------------------------------------------------------------------------
124
131 public String getPrintedList()
132 {
133 StringBuilder sb = new StringBuilder(1024);
134 sb.append(" " + paramTypeName() + " ").append(NL);
135 for (Field f : this.getClass().getDeclaredFields())
136 {
137 try
138 {
139 sb.append(f.getName()).append(" = ").append(
140 f.get(this)).append(NL);
141 }
142 catch (Throwable t)
143 {
144 sb.append("ERROR! Unable to print " + paramTypeName()
145 + " parameters. Cause: " + t);
146 break;
147 }
148 }
149 for (RunTimeParameters otherCollector : otherParameters.values())
150 {
151 sb.append(otherCollector.getPrintedList());
152 }
153 return sb.toString();
154 }
155
156//----------------------------------------------------------------------------
157
158}
static boolean checkExists(String fileName)
Definition: FileUtils.java:241
Collection of parameters controlling the behavior of the software.
Map< ParametersType, RunTimeParameters > otherParameters
Collection of other parameters by type.
String paramTypeName()
Returns a string defining the type the parameters collected here.
void checkOtherParameters()
Checks any of the parameter collections contained in this instance.
final String NL
New line character.
void processOtherParameters()
Processes any of the parameter collections contained in this instance.
Parameters controlling execution of Isomorphism main class.
String getPrintedList()
Returns the list of parameters in a string with newline characters as delimiters.
void checkParameters()
Evaluate consistency of input parameters.
void processParameters()
Processes all parameters and initialize related objects.
void interpretKeyword(String key, String value)
Processes a keyword/value pair and assign the related parameters.
ISO_PARAMS
Parameters controlling the stand-alone detection of graph isomorphism.