19package denoptim.combinatorial;
22import java.util.ArrayList;
23import java.util.regex.Pattern;
25import org.apache.commons.io.FileUtils;
27import com.google.gson.Gson;
28import com.google.gson.GsonBuilder;
30import denoptim.constants.DENOPTIMConstants;
31import denoptim.exception.DENOPTIMException;
32import denoptim.files.SingletonFileAccess;
33import denoptim.graph.DGraph;
34import denoptim.io.DenoptimIO;
35import denoptim.programs.combinatorial.CEBLParameters;
57 + DENOPTIMConstants.FSEP
58 + DENOPTIMConstants.FSEIDXNAMEROOT
74 && fileName.contains(Pattern.quote(
".")))
76 msg =
"Failed attempt to extract a graphId from String '"
80 String[] p1 = fileName.split(Pattern.quote(
82 String[] p2 = p1[1].split(Pattern.quote(
"."));
86 graphId = Integer.parseInt(p2[0]);
103 String baseName = DENOPTIMConstants.SERGFILENAMEROOT
119 + DENOPTIMConstants.FSEP
120 + DENOPTIMConstants.FSEIDXNAMEROOT
122 + DENOPTIMConstants.FSEP
137 + DENOPTIMConstants.FSEP
138 + DENOPTIMConstants.FSEIDXNAMEROOT
140 + DENOPTIMConstants.FSEP
141 + DENOPTIMConstants.FSEIDXNAMEROOT
159 for (
DGraph g : lstGraphs)
188 DGraph graph,
int level,
int rootId,
192 if (!denoptim.files.FileUtils.checkExists(outDir))
196 FileUtils.forceMkdir(
new File(outDir));
200 String msg =
"Cannot create folder " + outDir;
208 String indexLine = graph.toString() +
" => " + graph.getGraphId() +
" "
209 + rootId +
" " + nextIds;
225 Gson writer =
new GsonBuilder().setPrettyPrinting().create();
227 settings.getCheckPoint()),
false);
241 Gson writer =
new GsonBuilder().create();
Helper methods for the exploration of the fragment space.
static CheckPoint deserializeCheckpoint(String file)
Converts a text file into the corresponding checkpoint object.
static String getNameOfStorageFile(CEBLParameters settings, int level, int graphId)
static void storeAllGraphsOfLevel(CEBLParameters settings, ArrayList< DGraph > lstGraphs, int level)
Serialize all DENOPTIMGraphs to file.
static String getNameOfStorageIndexFile(CEBLParameters settings, int level)
static String getBaseNameOfStorageFile(int graphId)
static String getNameOfStorageDir(CEBLParameters settings, int level)
static void serializeCheckPoint(CEBLParameters settings)
Store the checkpoint in a text file with json format.
static void storeGraphOfLevel(CEBLParameters settings, DGraph graph, int level, int rootId, ArrayList< Integer > nextIds)
Serialize a DENOPTIMGraph to a file.
static int getGraphIdFromStorageFile(String fileName)
Object collecting information needed to restart a FragSpaceExplorer job.
General set of constants used in DENOPTIM.
static final String SERGFILENAMEEXT
Extension filenames of serialized graphs.
static final String SERGFILENAMEROOT
Prefix filenames of serialized graphs.
Singleton for synchronizing multi-thread safe file access.
static SingletonFileAccess getInstance()
Returns the single instance of this class.
synchronized void writeData(String fileName, String data, boolean append)
Write data as an unformatted string to a text file.
Container for the list of vertices and the edges that connect them.
DGraph clone()
Returns almost "deep-copy" of this graph.
Utility methods for input/output.
static String readText(String fileName)
Read text from file.
static void writeData(String fileName, String data, boolean append)
Write text-like data file.
Parameters controlling execution of the combinatorial algorithm for exploration of a fragment space b...