19package denoptim.programs.genetweeker;
22import java.util.ArrayList;
23import java.util.HashSet;
26import java.util.logging.Level;
27import java.util.logging.Logger;
29import org.openscience.cdk.interfaces.IAtomContainer;
31import denoptim.constants.DENOPTIMConstants;
32import denoptim.exception.DENOPTIMException;
33import denoptim.fragspace.FragmentSpace;
34import denoptim.fragspace.FragmentSpaceParameters;
35import denoptim.ga.GraphOperations;
36import denoptim.ga.XoverSite;
37import denoptim.graph.DGraph;
38import denoptim.graph.Template;
39import denoptim.graph.Vertex;
40import denoptim.io.DenoptimIO;
41import denoptim.logging.Monitor;
42import denoptim.molecularmodeling.ThreeDimTreeBuilder;
43import denoptim.programs.RunTimeParameters.ParametersType;
44import denoptim.programs.denovo.GAParameters;
45import denoptim.task.ProgramTask;
46import denoptim.utils.CrossoverType;
47import denoptim.utils.MutationType;
104 this.settings = goParams;
143 }
catch (Exception e)
168 graph,
"mutation " + mt);
181 +
"For mutation " + mt +
" you should specify also "
182 +
"the index of the AP on the mutation target as "
183 +
"TESTGENOPS-APIDONTARGETVERTEX.");
192 logger.log(Level.INFO,
"Attempting mutation a random mutation on a "
217 }
catch (Exception e)
223 logger.log(Level.INFO,
"Initial graphs: "+
NL
234 female,
"crossover");
240 List<Vertex> subGraphA =
new ArrayList<Vertex>();
244 List<Vertex> subGraphB =
new ArrayList<Vertex>();
249 xos =
new XoverSite(subGraphA, subGraphB, xoverType);
255 logger.log(Level.INFO,
NL+
"Initial graphs now with unique vertexID: "
259 logger.log(Level.INFO,
"Attempting crossover on a site detected "
265 logger.log(Level.WARNING,
"No crossover site detected.");
268 logger.log(Level.INFO,
"Randombly choosing among "
269 + sites.size() +
" xover sites.");
276 logger.log(Level.INFO,
NL +
"Result of crossover:"
277 +
NL +
"MALE: " + male
278 +
NL +
"FEMALE: " + female);
292 List<
int[]> embeddingPaths, String operation)
294 Set<Vertex> result =
new HashSet<Vertex>();
295 for (
int[] embeddingPath : embeddingPaths)
305 DGraph graph, String operation)
308 if (embeddingPath !=
null && embeddingPath.length>1)
310 for (
int i=(embeddingPath.length-1); i>-1; i--)
312 if (i==embeddingPath.length-1)
314 str =
"[" + embeddingPath[i] +
"]";
316 str =
"[" + str +
" " + embeddingPath[i] +
"] ";
319 logger.log(Level.INFO,
"Attempting '" + operation +
"' on deep "
321 Vertex outerVertex =
null;
322 DGraph innerGraph = graph;
323 for (
int i=0; i<embeddingPath.length; i++)
325 if (outerVertex !=
null && outerVertex instanceof
Template)
327 innerGraph = ((
Template) outerVertex).getInnerGraph();
330 if (outerVertex ==
null)
332 logger.log(Level.INFO,
"VertexID '" + embeddingPath[i] +
333 "' not found in graph " + innerGraph);
339 int vid = embeddingPath[0];
340 logger.log(Level.INFO,
"Attempting '" + operation +
"' on vertex "
345 logger.log(Level.INFO,
"VertexID '" + vid +
"' not found in "
General set of constants used in DENOPTIM.
static final Object STOREDVID
Key of the property remembering vertex IDs.
Class defining a space of building blocks.
Parameters defining the fragment space.
FragmentSpace getFragmentSpace()
Collection of operators meant to alter graphs and associated utilities.
static List< XoverSite > locateCompatibleXOverPoints(DGraph graphA, DGraph graphB, FragmentSpace fragSpace, int maxSizeXoverSubGraph)
Identify crossover sites, i.e., subgraphs that can be swapped between two graphs (i....
static boolean performMutation(DGraph graph, Monitor mnt, GAParameters settings)
Tries to do mutate the given graph.
static boolean performCrossover(XoverSite site, FragmentSpace fragSpace)
Performs the crossover that swaps the two subgraphs defining the given XoverSite.
This class collects the data identifying the subgraphs that would be swapped by a crossover event.
Container for the list of vertices and the edges that connect them.
Vertex getVertexWithId(long vid)
Searches for a vertex with the given identifier.
void renumberGraphVertices()
Reassign vertex IDs to all vertices of this graph.
void getChildTreeLimited(Vertex vertex, List< Vertex > children, boolean stopBeforeRCVs)
Gets all the children of the current vertex recursively.
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
void setProperty(Object key, Object property)
Utility methods for input/output.
static void writeSDFFile(String fileName, IAtomContainer mol)
Writes IAtomContainer to SDF file.
static ArrayList< DGraph > readDENOPTIMGraphsFromFile(File inFile)
Reads a list of <DGraphs from file.
A collection of counters user to count actions taken by the evolutionary algorithm.
Tool to build build three-dimensional (3D) tree-like molecular structures from DGraph.
IAtomContainer convertGraphTo3DAtomContainer(DGraph graph)
Created a three-dimensional molecular representation from a given DGraph.
Logger startProgramSpecificLogger(String loggerIdentifier)
Starts a logger with the given name.
boolean containsParameters(ParametersType type)
void setParameters(RunTimeParameters otherParams)
RunTimeParameters getParameters(ParametersType type)
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.
Randomizer getRandomizer()
Returns the current program-specific randomizer.
Parameters for genetic algorithm.
int maxXOverableSubGraphSize
Limit to the size of subgraphs that are exchanged during crossover.
Tool to run genetic operations in a stand-alone fashion, i.e., outside of a genetic algorithm run.
Set< Vertex > getSubGraphEnds(DGraph graph, List< int[]> embeddingPaths, String operation)
GeneOpsRunnerParameters settings
Settings from input parameters.
Vertex getEmbeddedVertex(int[] embeddingPath, DGraph graph, String operation)
FragmentSpace fragSpace
Fragment space in use.
GeneOpsRunner(File configFile, File workDir)
Creates and configures the program task.
GAParameters gaParams
Parameters for genetic algorithm.
Logger logger
Program-specific logger.
Parameters controlling execution of TestOperator.
List< int[]> xoverSubGraphEndFemale
Female VertedID (not index) that represent the end of the subgraph that is swapped by crossover.
List< int[]> xoverSubGraphEndMale
Male VertedID (not index) that represent the end of the subgraph that is swapped by crossover.
String outFileF
Output file female.
int[] xoverSrcFemale
Female VertexID (not index) on which perform xover.
int idNewAP
The given attachment point index.
int idTargetAP
Target attachment point ID for mutation (AP belonging already to the graph).
String inpFileM
Input File male.
void checkParameters()
Evaluate consistency of input parameters.
void processParameters()
Processes all parameters and initialize related objects.
MutationType mutationType
Type of mutation to perform.
String inpFileF
Input File female.
int[] xoverSrcMale
Male VertedID (not index) on which perform xover.
String outFileM
Output file male.
int idNewVrt
The given vertex index.
int[] mutationTarget
Target vertex ID for mutation.
Operator operatorToTest
Chosen operator.
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.
final String NL
System-dependent line separator (newline)
public< T > T randomlyChooseOne(Collection< T > c)
Chooses one member among the given collection.
Identifier of the type of parameters.
FS_PARAMS
Parameters pertaining the definition of the fragment space.
GA_PARAMS
Parameters pertaining the genetic algorithm.
Types of crossover defined.
SUBGRAPH
Swaps a portion of a branch trying to retain cyclicity.
BRANCH
Swaps the entire branch starting from a given vertex.
Types of mutation defined in relation to what happens to the target vertex (i.e., the actual mutation...
ADDLINK
Adds a vertex between two previously connected vertexes.