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.graph.rings.RingClosureParameters;
41import denoptim.io.DenoptimIO;
42import denoptim.logging.Monitor;
43import denoptim.molecularmodeling.ThreeDimTreeBuilder;
44import denoptim.programs.RunTimeParameters.ParametersType;
45import denoptim.programs.denovo.GAParameters;
46import denoptim.task.ProgramTask;
47import denoptim.utils.CrossoverType;
48import denoptim.utils.MutationType;
105 this.settings = goParams;
144 }
catch (Exception e)
171 boolean done =
false;
175 graph,
"mutation " + mt);
180 if (mutable.size()==0)
182 logger.log(Level.INFO,
"Graph has no mutable site of type '"
183 + mt +
"'. Mutation aborted.");
187 logger.log(Level.INFO,
"Randomly choosed vertex as target "
188 +
"for mutation '" + mt +
"': " + v);
197 +
"For mutation " + mt +
" you should specify also "
198 +
"the index of the AP on the mutation target as "
199 +
"TESTGENOPS-APIDONTARGETVERTEX.");
208 logger.log(Level.INFO,
"Attempting mutation a random mutation on a "
236 }
catch (Exception e)
242 logger.log(Level.INFO,
"Initial graphs: "+
NL
253 female,
"crossover");
259 List<Vertex> subGraphA =
new ArrayList<Vertex>();
263 List<Vertex> subGraphB =
new ArrayList<Vertex>();
268 xos =
new XoverSite(subGraphA, subGraphB, xoverType);
274 logger.log(Level.INFO,
NL+
"Initial graphs now with unique vertexID: "
278 logger.log(Level.INFO,
"Attempting crossover on a site detected "
288 logger.log(Level.WARNING,
"No crossover site detected.");
291 logger.log(Level.INFO,
"Randombly choosing among "
292 + sites.size() +
" xover sites.");
300 logger.log(Level.INFO,
NL +
"Result of crossover:"
301 +
NL +
"MALE: " + male
302 +
NL +
"FEMALE: " + female);
316 List<
int[]> embeddingPaths, String operation)
318 Set<Vertex> result =
new HashSet<Vertex>();
319 for (
int[] embeddingPath : embeddingPaths)
329 DGraph graph, String operation)
332 if (embeddingPath !=
null && embeddingPath.length>1)
334 for (
int i=(embeddingPath.length-1); i>-1; i--)
336 if (i==embeddingPath.length-1)
338 str =
"[" + embeddingPath[i] +
"]";
340 str =
"[" + str +
" " + embeddingPath[i] +
"] ";
343 logger.log(Level.INFO,
"Attempting '" + operation +
"' on deep "
345 Vertex outerVertex =
null;
346 DGraph innerGraph = graph;
347 for (
int i=0; i<embeddingPath.length; i++)
349 if (outerVertex !=
null && outerVertex instanceof
Template)
351 innerGraph = ((
Template) outerVertex).getInnerGraph();
354 if (outerVertex ==
null)
356 logger.log(Level.INFO,
"VertexID '" + embeddingPath[i] +
357 "' not found in graph " + innerGraph);
363 if (embeddingPath==
null)
365 logger.log(Level.INFO,
"No mutation site specified.");
368 int vid = embeddingPath[0];
369 logger.log(Level.INFO,
"Attempting '" + operation +
"' on vertex "
374 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, int maxCompatibleVrtxPairs, int maxEndPointsCombinations, int maxEndPointsPermutations, int maxAPMappingCombinations)
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.
List< Vertex > getSelectedMutableSites(MutationType requestedType)
A list of mutation sites from within this graph.
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
void setProperty(Object key, Object property)
Parameters and setting related to handling ring closures.
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 maxXoverEndPointsCombinations
Limit to the number of combinations of subgraph end points considered when locating crossover sites.
int maxXOverableSubGraphSize
Limit to the size of subgraphs that are exchanged during crossover.
int maxCompatibleVrtxPairs
Limit to the number of compatible vertex pairs to consider for crossover.
int maxAPMappingCombinations
Limit to the number of AP-AP mapping combinations considered by denoptim.fragspace....
int maxXoverEndPointsPermutations
Limit to the number of permutations of subgraph end points considered for each combination when locat...
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.
RC_PARAMS
Parameters pertaining to ring closures in graphs.
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.