$darkmode
DENOPTIM
denoptim.ga.GraphOperations Class Reference

Collection of operators meant to alter graphs and associated utilities. More...

Classes

class  FragForClosabChains
 Private class representing a selected closable chain of fragments. More...
 

Static Public Member Functions

static List< XoverSitelocateCompatibleXOverPoints (DGraph graphA, DGraph graphB, FragmentSpace fragSpace, int maxSizeXoverSubGraph) throws DENOPTIMException
 Identify crossover sites, i.e., subgraphs that can be swapped between two graphs (i.e., the parents). More...
 
static boolean extendLink (Vertex vertex, int chosenAPId, Monitor mnt, FragmentSpace fragSpace) throws DENOPTIMException
 Inserts a vertex in between two connected vertexes that are identified by the one vertex holding the "source" end of the edge, and the identifier of the attachment point used by that edge. More...
 
static boolean extendLink (Vertex vertex, int chosenAPId, int chosenNewVrtxId, Monitor mnt, FragmentSpace fragSpace) throws DENOPTIMException
 Inserts a vertex in between two connected vertexes that are identified by the one vertex holding the "source" end of the edge, and the identifier of the attachment point used by that edge. More...
 
static boolean extendLink (Edge edge, int chosenBBIdx, Monitor mnt, FragmentSpace fragSpace) throws DENOPTIMException
 Replace an edge with two edges with a new vertex in between, thus inserting a vertex in between two directly connected vertexes, which will no longer be directly connected. More...
 
static boolean performCrossover (XoverSite site, FragmentSpace fragSpace) throws DENOPTIMException
 Performs the crossover that swaps the two subgraphs defining the given XoverSite. More...
 
static boolean performMutation (DGraph graph, Monitor mnt, GAParameters settings) throws DENOPTIMException
 Tries to do mutate the given graph. More...
 
static boolean performMutation (Vertex vertex, Monitor mnt, GAParameters settings) throws DENOPTIMException
 Tries to do mutate the given vertex. More...
 
static boolean performMutation (Vertex vertex, MutationType mType, Monitor mnt, GAParameters settings) throws DENOPTIMException
 Mutates the given vertex according to the given mutation type, if possible. More...
 
static boolean performMutation (Vertex vertex, MutationType mType, boolean force, int chosenVrtxIdx, int chosenApId, Monitor mnt, GAParameters settings) throws DENOPTIMException
 Mutates the given vertex according to the given mutation type, if possible. More...
 

Static Protected Member Functions

static boolean deleteLink (Vertex vertex, int chosenVrtxIdx, Monitor mnt, FragmentSpace fragSpace) throws DENOPTIMException
 Removes a vertex while merging as many of the child branches into the parent vertex. More...
 
static boolean substituteLink (Vertex vertex, int chosenVrtxIdx, Monitor mnt, FragmentSpace fragSpace) throws DENOPTIMException
 Substitutes a vertex while keeping its surrounding. More...
 
static boolean rebuildBranch (Vertex vertex, boolean force, int chosenVrtxIdx, int chosenApId, GAParameters settings) throws DENOPTIMException
 Substitutes a vertex and any child branch. More...
 
static boolean deleteFragment (Vertex vertex) throws DENOPTIMException
 Deletion mutation removes the vertex and also the symmetric partners on its parent. More...
 
static boolean deleteChain (Vertex vertex, Monitor mnt, FragmentSpace fragSpace) throws DENOPTIMException
 Deletes the given vertex and all other vertexes that are not connected to more than 2 non-capping group vertexes. More...
 
static boolean addRing (Vertex vertex, Monitor mnt, boolean force, FragmentSpace fragSpace, GAParameters settings) throws DENOPTIMException
 Tries to use any free AP of the given vertex to close ring in the graph by adding a chord. More...
 
static boolean extendGraph (Vertex curVertex, boolean extend, boolean symmetryOnAps, GAParameters settings) throws DENOPTIMException
 function that will keep extending the graph according to the growth/substitution probability. More...
 
static boolean extendGraph (Vertex curVrtx, boolean extend, boolean symmetryOnAps, boolean force, int chosenVrtxIdx, int chosenApId, GAParameters settings) throws DENOPTIMException
 function that will keep extending the graph. More...
 
static IdFragmentAndAP getFrgApForSrcAp (Vertex curVertex, int dapidx, FragmentSpace fragSpace) throws DENOPTIMException
 Select a compatible fragment for the given attachment point. More...
 
static IdFragmentAndAP getFrgApForSrcAp (Vertex curVertex, int dapidx, int chosenVrtxIdx, int chosenApId, FragmentSpace fragSpace) throws DENOPTIMException
 Select a compatible fragment for the given attachment point. More...
 
static IdFragmentAndAP getRCVForSrcAp (Vertex curVertex, int dapidx, FragmentSpace fragSpace) throws DENOPTIMException
 Select a compatible ring-closing vertex for the given attachment point. More...
 
static boolean attachFragmentInClosableChain (Vertex curVertex, int dapidx, DGraph molGraph, ArrayList< Long > addedVertices, GAParameters settings) throws DENOPTIMException
 
static ArrayList< FragForClosabChainsgetFragmentForClosableChain (Vertex curVertex, int dapidx, DGraph molGraph) throws DENOPTIMException
 Method to select fragments that increase the likeliness of generating closable chains. More...
 
static boolean applySymmetry (boolean apclassImposed, double symmetryProbability, Randomizer randomizer)
 Decides whether to apply constitutional symmetry or not. More...
 

Static Private Member Functions

static void processCombinationOfEndPoints (Vertex[] pair, List< Vertex[]> cominationOfEnds, List< XoverSite > collector, FragmentSpace fragSpace)
 Given a pair of seed vertexes that define where a pair of subgraphs stars in the corresponding original graphs, this method evaluates the use of a given list of candidate subgraph end points. More...
 
static void processPermutationOfEndPoints (Vertex[] pair, List< Vertex[]> chosenSequenceOfEndpoints, List< XoverSite > collector, FragmentSpace fragSpace)
 Given a pair of seed vertexes that define where a pair of subgraphs stars in the corresponding original graphs, this method evaluates the use of a given ordered list of candidate subgraph end points. More...
 
static void checkAndAddXoverSites (FragmentSpace fragSpace, List< Vertex > subGraphA, List< Vertex > subGraphB, CrossoverType xoverType, List< XoverSite > collector)
 Here we check that the given subgraphs have a mapping that allows to swap them, and full fill any other requirement other than not being isomorphic (which is done in parent methods calling this one). More...
 
static boolean isCrossoverPossible (Edge eA, Edge eB, FragmentSpace fragSpace)
 Evaluate AP class-compatibility of a pair of edges with respect to crossover. More...
 

Detailed Description

Collection of operators meant to alter graphs and associated utilities.

Definition at line 76 of file GraphOperations.java.

Member Function Documentation

◆ addRing()

static boolean denoptim.ga.GraphOperations.addRing ( Vertex  vertex,
Monitor  mnt,
boolean  force,
FragmentSpace  fragSpace,
GAParameters  settings 
) throws DENOPTIMException
staticprotected

Tries to use any free AP of the given vertex to close ring in the graph by adding a chord.

Parameters
vertexthe vertex on which we start to close a the ring.
mntmonitoring tool to keep count of events.
forceuse true to by-pass random decisions and force the creation of rings.
fragSpacethe fragment space controlling how we put together building blocks.
settingsthe GA settings controlling how we work.
Returns
true when at least one ring was added to the graph.
Exceptions
DENOPTIMException

Definition at line 966 of file GraphOperations.java.

References denoptim.graph.DGraph.addRing(), denoptim.graph.DGraph.appendVertexOnAP(), denoptim.graph.DGraph.clone(), denoptim.graph.Vertex.clone(), denoptim.molecularmodeling.ThreeDimTreeBuilder.convertGraphTo3DAtomContainer(), denoptim.graph.APClass.equals(), denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_NOADDRING_NOFREEAP, denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_NOADDRING_NORINGCOMB, denoptim.graph.Vertex.getAP(), denoptim.graph.AttachmentPoint.getAPClass(), denoptim.graph.DGraph.getAvailableAPsThroughout(), denoptim.graph.Vertex.getFreeAPThroughout(), denoptim.programs.RunTimeParameters.getParameters(), denoptim.utils.GraphUtils.getUniqueVertexIndex(), denoptim.graph.DGraph.getVertexAtPosition(), denoptim.graph.DGraph.indexOf(), denoptim.graph.rings.RandomCombOfRingsIterator.next(), denoptim.utils.Randomizer.randomlyChooseOne(), denoptim.programs.RunTimeParameters.ParametersType.RC_PARAMS, denoptim.graph.rings.RingClosingAttractor.RCAAPCMAP, denoptim.graph.DGraph.removeVertex(), denoptim.molecularmodeling.ThreeDimTreeBuilder.setAlignBBsIn3D(), and denoptim.graph.Vertex.setVertexId().

Referenced by denoptim.ga.GraphOperations.performMutation(), and denoptim.ga.GraphOperationsTest.testAddRing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applySymmetry()

static boolean denoptim.ga.GraphOperations.applySymmetry ( boolean  apclassImposed,
double  symmetryProbability,
Randomizer  randomizer 
)
staticprotected

Decides whether to apply constitutional symmetry or not.

Application of this type of symmetry implies that the operation on the graph/molecule is to be performed on all the attachment point/vertices related to each other by "constitutional symmetry". Such type symmetry is defined by getMatchingAP for a single fragment, and symmetric vertices in a graph are found by getSymmetricVertices. This method takes into account the effect of the symmetric substitution probability, and the symmetry-related keywords.

Returns
true if symmetry is to be applied

Definition at line 2110 of file GraphOperations.java.

References denoptim.utils.Randomizer.nextBoolean().

Referenced by denoptim.ga.GraphOperations.attachFragmentInClosableChain(), and denoptim.ga.GraphOperations.extendGraph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ attachFragmentInClosableChain()

static boolean denoptim.ga.GraphOperations.attachFragmentInClosableChain ( Vertex  curVertex,
int  dapidx,
DGraph  molGraph,
ArrayList< Long >  addedVertices,
GAParameters  settings 
) throws DENOPTIMException
staticprotected

◆ checkAndAddXoverSites()

static void denoptim.ga.GraphOperations.checkAndAddXoverSites ( FragmentSpace  fragSpace,
List< Vertex subGraphA,
List< Vertex subGraphB,
CrossoverType  xoverType,
List< XoverSite collector 
)
staticprivate

Here we check that the given subgraphs have a mapping that allows to swap them, and full fill any other requirement other than not being isomorphic (which is done in parent methods calling this one).

Then, we create the corresponding crossover site and place it in the collector of such sites.

NB: This method assumes that no crossover can involve seed of the spanning tree (whether scaffold, of anything else).

Definition at line 493 of file GraphOperations.java.

References denoptim.utils.CrossoverType.BRANCH, denoptim.graph.DGraph.extractSubgraph(), denoptim.graph.Template.ContractLevel.FIXED_STRUCT, denoptim.fragspace.APMapFinder.foundMapping(), denoptim.graph.Template.getContractLevel(), denoptim.graph.DGraph.getDeepestAmongThese(), denoptim.graph.Vertex.getEdgeToParent(), denoptim.graph.DGraph.getInterfaceAPs(), denoptim.graph.DGraph.getRingsInvolvingVertex(), denoptim.graph.DGraph.getSubgraphAPs(), denoptim.graph.DGraph.getTemplateJacket(), denoptim.graph.Edge.getTrgAP(), and denoptim.graph.DGraph.isIsostructuralTo().

Referenced by denoptim.ga.GraphOperations.locateCompatibleXOverPoints(), and denoptim.ga.GraphOperations.processPermutationOfEndPoints().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ deleteChain()

static boolean denoptim.ga.GraphOperations.deleteChain ( Vertex  vertex,
Monitor  mnt,
FragmentSpace  fragSpace 
) throws DENOPTIMException
staticprotected

Deletes the given vertex and all other vertexes that are not connected to more than 2 non-capping group vertexes.

Effectively, it removes an entire branch (in acyclic graphs) or the part of a cyclic graph between two branching points (in a ring, thus opening the ring wide). The same is done on symmetric partners on its parent.

Parameters
vertexthe vertex at which the deletion begins.
mntmonitoring tool to keep count of events.
Returns
true if deletion is successful
Exceptions
DENOPTIMException

Definition at line 921 of file GraphOperations.java.

References denoptim.utils.MutationType.DELETECHAIN, denoptim.graph.DGraph.getSymSetForVertex(), denoptim.graph.DGraph.getVertexCount(), denoptim.graph.DGraph.getVertexWithId(), denoptim.graph.DGraph.hasSymmetryInvolvingVertex(), and denoptim.graph.DGraph.removeChainUpToBranching().

Referenced by denoptim.ga.GraphOperations.performMutation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ deleteFragment()

static boolean denoptim.ga.GraphOperations.deleteFragment ( Vertex  vertex) throws DENOPTIMException
staticprotected

Deletion mutation removes the vertex and also the symmetric partners on its parent.

Parameters
vertex
Returns
true if deletion is successful
Exceptions
DENOPTIMException

Definition at line 881 of file GraphOperations.java.

References denoptim.graph.DGraph.getSymSetForVertex(), denoptim.graph.DGraph.getVertexCount(), denoptim.graph.DGraph.getVertexWithId(), denoptim.graph.DGraph.hasSymmetryInvolvingVertex(), and denoptim.graph.DGraph.removeBranchStartingAt().

Referenced by denoptim.ga.GraphOperations.performMutation(), and denoptim.ga.GraphOperations.rebuildBranch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ deleteLink()

static boolean denoptim.ga.GraphOperations.deleteLink ( Vertex  vertex,
int  chosenVrtxIdx,
Monitor  mnt,
FragmentSpace  fragSpace 
) throws DENOPTIMException
staticprotected

Removes a vertex while merging as many of the child branches into the parent vertex.

Parameters
vertexthe vertex to remove.
mntthe monitor keeping track of what happens in EA operations. This does not affect the mutation. It only measures how many attempts and failures occur.
Returns
true if the mutation is successful.
Exceptions
DENOPTIMException

Definition at line 626 of file GraphOperations.java.

References denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_NODELLINK_EDIT, and denoptim.graph.DGraph.removeVertexAndWeld().

Referenced by denoptim.ga.GraphOperations.performMutation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extendGraph() [1/2]

static boolean denoptim.ga.GraphOperations.extendGraph ( Vertex  curVertex,
boolean  extend,
boolean  symmetryOnAps,
GAParameters  settings 
) throws DENOPTIMException
staticprotected

function that will keep extending the graph according to the growth/substitution probability.

Parameters
curVertexvertex to which further fragments will be appended
extendif true, then the graph will be grown further (recursive mode)
symmetryOnApsif true, then symmetry will be applied on the APs, no matter what. This is mostly needed to retain symmetry when performing mutations on the root vertex of a symmetric graph.
Exceptions
DENOPTIMException
Returns
true if the graph has been modified

Definition at line 1180 of file GraphOperations.java.

References denoptim.ga.GraphOperations.extendGraph().

Referenced by denoptim.ga.EAUtils.buildGraph(), denoptim.ga.GraphOperations.extendGraph(), denoptim.ga.GraphOperations.performMutation(), denoptim.ga.GraphOperations.rebuildBranch(), and denoptim.ga.GraphOperationsTest.testExtendGraph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extendGraph() [2/2]

static boolean denoptim.ga.GraphOperations.extendGraph ( Vertex  curVrtx,
boolean  extend,
boolean  symmetryOnAps,
boolean  force,
int  chosenVrtxIdx,
int  chosenApId,
GAParameters  settings 
) throws DENOPTIMException
staticprotected

function that will keep extending the graph.

The probability of addition depends on the growth probability scheme.

Parameters
curVrtxvertex to which further fragments will be appended
extendif true, then the graph will be grown further (recursive mode)
symmetryOnApsif true, then symmetry will be applied on the APs, no matter what. This is mostly needed to retain symmetry when performing mutations on the root vertex of a symmetric graph.
forceset to true to ignore growth probability.
chosenVrtxIdxif greater than or equals to zero, sets the choice of the vertex to the given index. This selection applies only to the first extension, not to further recursions.
chosenApIdif greater than or equals to zero, sets the choice of the AP to the given index. This selection applies only to the first extension, not to further recursions.
maxHeavyAtomsmaximum number of heavy atoms.
Exceptions
DENOPTIMException
Returns
true if the graph has been modified

Definition at line 1215 of file GraphOperations.java.

References denoptim.graph.SymmetricSet< T >.add(), denoptim.graph.DGraph.addSymmetricSetOfVertices(), denoptim.graph.rings.RingClosureParameters.allowRingClosures(), denoptim.graph.DGraph.appendVertexOnAP(), denoptim.ga.GraphOperations.applySymmetry(), denoptim.ga.GraphOperations.attachFragmentInClosableChain(), denoptim.utils.GraphUtils.ensureVertexIDConsistency(), denoptim.ga.GraphOperations.extendGraph(), denoptim.graph.Vertex.BBType.FRAGMENT, denoptim.programs.RunTimeParameters.ParametersType.FS_PARAMS, denoptim.graph.Vertex.getAP(), denoptim.graph.AttachmentPoint.getAPClass(), denoptim.fragspace.IdFragmentAndAP.getApId(), denoptim.ga.EAUtils.getCrowdedness(), denoptim.ga.EAUtils.getCrowdingProbability(), denoptim.fragspace.FragmentSpaceParameters.getFragmentSpace(), denoptim.ga.GraphOperations.getFrgApForSrcAp(), denoptim.ga.EAUtils.getGrowthByLevelProbability(), denoptim.graph.Vertex.getHeavyAtomsCount(), denoptim.graph.AttachmentPoint.getIndexInOwner(), denoptim.graph.DGraph.getLevel(), denoptim.fragspace.FragmentSpaceParameters.getMaxHeavyAtom(), denoptim.graph.DGraph.getMaxVertexId(), denoptim.ga.EAUtils.getMolSizeProbability(), denoptim.programs.RunTimeParameters.getParameters(), denoptim.programs.RunTimeParameters.getRandomizer(), denoptim.ga.GraphOperations.getRCVForSrcAp(), denoptim.graph.DGraph.getSymSetForVertex(), denoptim.utils.GraphUtils.getUniqueVertexIndex(), denoptim.fragspace.IdFragmentAndAP.getVertexMolId(), denoptim.graph.DGraph.getVertexWithId(), denoptim.graph.DGraph.hasSymmetryInvolvingVertex(), denoptim.fragspace.FragmentSpace.imposeSymmetryOnAPsOfClass(), denoptim.graph.AttachmentPoint.isAvailable(), denoptim.graph.Vertex.newVertexFromLibrary(), denoptim.programs.RunTimeParameters.ParametersType.RC_PARAMS, and denoptim.graph.rings.RingClosureParameters.selectFragmentsFromClosableChains().

Here is the call graph for this function:

◆ extendLink() [1/3]

static boolean denoptim.ga.GraphOperations.extendLink ( Edge  edge,
int  chosenBBIdx,
Monitor  mnt,
FragmentSpace  fragSpace 
) throws DENOPTIMException
static

Replace an edge with two edges with a new vertex in between, thus inserting a vertex in between two directly connected vertexes, which will no longer be directly connected.

Parameters
vertexholding the "source" end of the edge to
chosenBBIdxthe identifier of the building block to insert.
mntthe monitor keeping track of what happens in EA operations. This does not affect the mutation. It only measures how many attempts and failures occur.
Returns
true if the mutation is successful.
Exceptions
DENOPTIMException

Definition at line 774 of file GraphOperations.java.

References denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_NOADDLINK_EDIT, denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_NOADDLINK_FIND, denoptim.fragspace.GraphLinkFinder.foundAlternativeLink(), denoptim.graph.Vertex.getBuildingBlockId(), denoptim.graph.Vertex.getBuildingBlockType(), denoptim.fragspace.GraphLinkFinder.getChosenAlternativeLink(), denoptim.fragspace.GraphLinkFinder.getChosenAPMapping(), and denoptim.graph.DGraph.insertVertex().

Here is the call graph for this function:

◆ extendLink() [2/3]

static boolean denoptim.ga.GraphOperations.extendLink ( Vertex  vertex,
int  chosenAPId,
int  chosenNewVrtxId,
Monitor  mnt,
FragmentSpace  fragSpace 
) throws DENOPTIMException
static

Inserts a vertex in between two connected vertexes that are identified by the one vertex holding the "source" end of the edge, and the identifier of the attachment point used by that edge.

Effectively, this method asks to replace an edge with two edges with a new vertex in between.

Parameters
vertexholding the "source" end of the edge to
chosenAPIdthe identifier of the AP on the vertex.
chosenNewVrtxIdthe identifier of the new building block to insert in the list.
mntthe monitor keeping track of what happens in EA operations. This does not affect the mutation. It only measures how many attempts and failures occur.
Returns
true if the mutation is successful.
Exceptions
DENOPTIMExceptionif the request cannot be performed because the vertex is not the source of an edge at the given AP, or because such AP does not exist on the given vertex.

Definition at line 735 of file GraphOperations.java.

References denoptim.ga.GraphOperations.extendLink(), denoptim.graph.AttachmentPoint.getEdgeUserThroughout(), denoptim.graph.AttachmentPoint.getOwner(), and denoptim.graph.Edge.getSrcAP().

Here is the call graph for this function:

◆ extendLink() [3/3]

static boolean denoptim.ga.GraphOperations.extendLink ( Vertex  vertex,
int  chosenAPId,
Monitor  mnt,
FragmentSpace  fragSpace 
) throws DENOPTIMException
static

Inserts a vertex in between two connected vertexes that are identified by the one vertex holding the "source" end of the edge, and the identifier of the attachment point used by that edge.

Effectively, this method asks to replace an edge with two edges with a new vertex in between.

Parameters
vertexholding the "source" end of the edge to
chosenAPIdthe identifier of the AP on the vertex.
mntthe monitor keeping track of what happens in EA operations. This does not affect the mutation. It only measures how many attempts and failures occur.
Returns
true if the mutation is successful.
Exceptions
DENOPTIMExceptionif the request cannot be performed because the vertex is not the source of an edge at the given AP, or because such AP does not exist on the given vertex.

Definition at line 709 of file GraphOperations.java.

References denoptim.ga.GraphOperations.extendLink().

Referenced by denoptim.ga.GraphOperations.extendLink(), and denoptim.ga.GraphOperations.performMutation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFragmentForClosableChain()

static ArrayList< FragForClosabChains > denoptim.ga.GraphOperations.getFragmentForClosableChain ( Vertex  curVertex,
int  dapidx,
DGraph  molGraph 
) throws DENOPTIMException
staticprotected

Method to select fragments that increase the likeliness of generating closable chains.

Only works for scaffold.

Definition at line 1758 of file GraphOperations.java.

References denoptim.ga.GraphOperations.FragForClosabChains.addCompatibleCC(), denoptim.graph.rings.ChainLink.getApIdToLeft(), denoptim.graph.rings.ChainLink.getApIdToRight(), denoptim.graph.Vertex.getBuildingBlockId(), denoptim.graph.Vertex.getBuildingBlockType(), denoptim.graph.rings.ChainLink.getFragType(), denoptim.graph.rings.ChainLink.getIdx(), denoptim.graph.Vertex.getParent(), denoptim.graph.Edge.getSrcAPID(), denoptim.graph.Edge.getTrgAPID(), denoptim.graph.Vertex.BBType.parseInt(), denoptim.graph.Vertex.BBType.SCAFFOLD, denoptim.graph.Vertex.BBType.toOldInt(), and denoptim.graph.Vertex.BBType.UNDEFINED.

Referenced by denoptim.ga.GraphOperations.attachFragmentInClosableChain().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFrgApForSrcAp() [1/2]

static IdFragmentAndAP denoptim.ga.GraphOperations.getFrgApForSrcAp ( Vertex  curVertex,
int  dapidx,
FragmentSpace  fragSpace 
) throws DENOPTIMException
staticprotected

Select a compatible fragment for the given attachment point.

Compatibility can either be class based or based on the free connections

Parameters
curVertexthe source graph vertex
dapidxthe attachment point index on the src vertex
Returns
the vector of indexes identifying the molId (fragment index) of a fragment with a compatible attachment point, and the index of such attachment point.
Exceptions
DENOPTIMException

Definition at line 1521 of file GraphOperations.java.

References denoptim.ga.GraphOperations.getFrgApForSrcAp().

Referenced by denoptim.ga.GraphOperations.extendGraph(), and denoptim.ga.GraphOperations.getFrgApForSrcAp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFrgApForSrcAp() [2/2]

static IdFragmentAndAP denoptim.ga.GraphOperations.getFrgApForSrcAp ( Vertex  curVertex,
int  dapidx,
int  chosenVrtxIdx,
int  chosenApId,
FragmentSpace  fragSpace 
) throws DENOPTIMException
staticprotected

Select a compatible fragment for the given attachment point.

Compatibility can either be class based or based on the free connections

Parameters
curVertexthe source graph vertex
dapidxthe attachment point index on the src vertex
chosenVrtxIdxif greater than or equals to zero, sets the choice of the incoming vertex to the given index.
chosenApIdif greater than or equals to zero, sets the choice of the AP (of the incoming vertex) to the given index.
Returns
the vector of indeces identifying the molId (fragment index) of a fragment with a compatible attachment point, and the index of such attachment point.
Exceptions
DENOPTIMException

Definition at line 1546 of file GraphOperations.java.

References denoptim.graph.Vertex.BBType.FRAGMENT, and denoptim.graph.AttachmentPoint.getAPClass().

Here is the call graph for this function:

◆ getRCVForSrcAp()

static IdFragmentAndAP denoptim.ga.GraphOperations.getRCVForSrcAp ( Vertex  curVertex,
int  dapidx,
FragmentSpace  fragSpace 
) throws DENOPTIMException
staticprotected

Select a compatible ring-closing vertex for the given attachment point.

Parameters
curVertexthe source graph vertex
dapidxthe attachment point index on the src vertex
fragSpacethe space of building blocks with all the settings.
Returns
the vector of indeces identifying the molId (fragment index) of a fragment with a compatible attachment point, and the index of such attachment point.
Exceptions
DENOPTIMException

Definition at line 1595 of file GraphOperations.java.

References denoptim.graph.AttachmentPoint.getAPClass(), denoptim.graph.Vertex.getBuildingBlockId(), denoptim.graph.Vertex.getBuildingBlockType(), and denoptim.utils.Randomizer.randomlyChooseOne().

Referenced by denoptim.ga.GraphOperations.extendGraph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isCrossoverPossible()

static boolean denoptim.ga.GraphOperations.isCrossoverPossible ( Edge  eA,
Edge  eB,
FragmentSpace  fragSpace 
)
staticprivate

Evaluate AP class-compatibility of a pair of edges with respect to crossover.

The condition for performing AP class-compatible crossover is that the AP class on source vertex of edge A is compatible with the AP class on target vertex of edge B, and that AP class on source vertex of edgeB is compatible with the AP class on target vertex of edge A.

Parameters
eAfirst edge of the pair.
eBsecond edge of the pair.
Returns
true if the condition is satisfied.

Definition at line 595 of file GraphOperations.java.

References denoptim.graph.Edge.getSrcAPClass(), denoptim.graph.Edge.getTrgAPClass(), and denoptim.graph.APClass.isCPMapCompatibleWith().

Referenced by denoptim.ga.GraphOperations.locateCompatibleXOverPoints().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ locateCompatibleXOverPoints()

static List< XoverSite > denoptim.ga.GraphOperations.locateCompatibleXOverPoints ( DGraph  graphA,
DGraph  graphB,
FragmentSpace  fragSpace,
int  maxSizeXoverSubGraph 
) throws DENOPTIMException
static

Identify crossover sites, i.e., subgraphs that can be swapped between two graphs (i.e., the parents).

This method will try to locate as many as possible crossover sites without falling into combinatorial explosion.

Parameters
gAone of the parent graphs.
gBthe other of the parent graphs.
fragSpacethe space of building blocks defining how to generate graphs.
maxSizeXoverSubGraphthe limit to the size of subgraphs that can can be exchanged by crossover.
Returns
the list of pairs of crossover sites.
Exceptions
DENOPTIMException

Definition at line 94 of file GraphOperations.java.

References denoptim.utils.CrossoverType.BRANCH, denoptim.graph.Vertex.BBType.CAP, denoptim.ga.GraphOperations.checkAndAddXoverSites(), denoptim.graph.DGraph.clone(), denoptim.graph.DGraph.extractSubgraph(), denoptim.graph.Template.ContractLevel.FIXED, denoptim.graph.Template.ContractLevel.FIXED_STRUCT, denoptim.graph.DGraph.getBranchIdOfVertexAsStr(), denoptim.graph.Vertex.getBuildingBlockType(), denoptim.graph.DGraph.getChildrenTree(), denoptim.graph.Template.getContractLevel(), denoptim.graph.Vertex.getGraphOwner(), denoptim.graph.Template.getInnerGraph(), denoptim.graph.Vertex.getParent(), denoptim.graph.rings.PathSubGraph.getPathLength(), denoptim.graph.DGraph.getTemplateJacket(), denoptim.graph.DGraph.getVertexCount(), denoptim.graph.DGraph.indexOf(), denoptim.ga.GraphOperations.isCrossoverPossible(), denoptim.graph.DGraph.isIsomorphicTo(), denoptim.ga.GraphOperations.locateCompatibleXOverPoints(), and denoptim.ga.GraphOperations.processCombinationOfEndPoints().

Referenced by denoptim.ga.Population.getXoverPartners(), denoptim.ga.GraphOperations.locateCompatibleXOverPoints(), denoptim.programs.genetweeker.GeneOpsRunner.runXOver(), and denoptim.ga.GraphOperationsTest.testLocateCompatibleXOverPoints().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ performCrossover()

static boolean denoptim.ga.GraphOperations.performCrossover ( XoverSite  site,
FragmentSpace  fragSpace 
) throws DENOPTIMException
static

Performs the crossover that swaps the two subgraphs defining the given XoverSite.

The operation is performed on the graphs that own the vertexes referred in the XoverSite, so the original version of the graphs is lost. We expect the graphs to have an healthy set of vertex IDs. This can be ensured by running DGraph#renumberGraphVertices().

Parameters
sitethe definition of the crossover site.
Exceptions
DENOPTIMException

Definition at line 1985 of file GraphOperations.java.

References denoptim.graph.DGraph.extractSubgraph(), denoptim.fragspace.APMapFinder.foundMapping(), denoptim.graph.Vertex.getAP(), denoptim.fragspace.APMapFinder.getChosenAPMapping(), denoptim.graph.AttachmentPoint.getIndexInOwner(), denoptim.graph.AttachmentPoint.getOwner(), denoptim.graph.DGraph.getSubgraphAPs(), denoptim.graph.Vertex.getVertexId(), denoptim.graph.DGraph.getVertexWithId(), and denoptim.graph.DGraph.replaceSubGraph().

Referenced by denoptim.ga.EAUtils.buildCandidatesByXOver(), and denoptim.programs.genetweeker.GeneOpsRunner.runXOver().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ performMutation() [1/4]

static boolean denoptim.ga.GraphOperations.performMutation ( DGraph  graph,
Monitor  mnt,
GAParameters  settings 
) throws DENOPTIMException
static

Tries to do mutate the given graph.

The mutation site and type are chosen randomly according to the possibilities declared by the graph. The graph that owns the vertex will be altered and the original structure and content of the graph will be lost.

Parameters
graphthe graph to mutate.
mntthe monitor keeping track of what happens in EA operations. This does not affect the mutation. It only measures how many attempts and failures occur.
Returns
true if the mutation is successful.
Exceptions
DENOPTIMException

Definition at line 2139 of file GraphOperations.java.

References denoptim.ga.EAUtils.chooseNumberOfSitesToMutate(), denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_NOMUTSITE, and denoptim.ga.GraphOperations.performMutation().

Referenced by denoptim.ga.EAUtils.buildCandidateByMutation(), denoptim.ga.EAUtils.buildGraph(), denoptim.ga.GraphOperations.performMutation(), and denoptim.programs.genetweeker.GeneOpsRunner.runMutation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ performMutation() [2/4]

static boolean denoptim.ga.GraphOperations.performMutation ( Vertex  vertex,
Monitor  mnt,
GAParameters  settings 
) throws DENOPTIMException
static

Tries to do mutate the given vertex.

We assume the vertex belongs to a graph, if not no mutation is done. The mutation type is chosen randomly according to the possibilities declared by the vertex. The graph that owns the vertex will be altered and the original structure and content of the graph will be lost.

Parameters
vertexthe vertex to mutate.
mntthe monitor keeping track of what happens in EA operations. This does not affect the mutation. It only measures how many attempts and failures occur.
Returns
true if the mutation is successful.
Exceptions
DENOPTIMException

Definition at line 2188 of file GraphOperations.java.

References denoptim.ga.GraphOperations.performMutation().

Here is the call graph for this function:

◆ performMutation() [3/4]

static boolean denoptim.ga.GraphOperations.performMutation ( Vertex  vertex,
MutationType  mType,
boolean  force,
int  chosenVrtxIdx,
int  chosenApId,
Monitor  mnt,
GAParameters  settings 
) throws DENOPTIMException
static

Mutates the given vertex according to the given mutation type, if possible.

Vertex that do not belong to any graph or that do not allow the requested kind of mutation, are not mutated. The graph that owns the vertex will be altered and the original structure and content of the graph will be lost.

Parameters
vertexthe vertex to mutate.
mTypethe type of mutation to perform.
forceset to true to ignore growth probability.
chosenVrtxIdxif greater than or equals to zero, sets the choice of the incoming vertex to the given index. This parameter is ignored for mutation types that do not define an incoming vertex (i.e., MutationType#DELETE).
chosenApIdif greater than or equals to zero, sets the choice of the AP to the given index. Depending on the type of mutation, the AP can be on the incoming vertex (i.e., the vertex that will be added to the graph) or on the target vertex (i.e., the vertex that already belongs to the graph and that is the focus of the mutation). This parameter is ignored for mutation types that do not define an incoming vertex (i.e., MutationType#DELETE).
Returns
true if the mutation is successful.
Exceptions
DENOPTIMException

Definition at line 2264 of file GraphOperations.java.

References denoptim.ga.GraphOperations.addRing(), denoptim.graph.Template.clearIAtomContainer(), denoptim.ga.GraphOperations.deleteChain(), denoptim.ga.GraphOperations.deleteFragment(), denoptim.ga.GraphOperations.deleteLink(), denoptim.ga.GraphOperations.extendGraph(), denoptim.ga.GraphOperations.extendLink(), denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_BADMUTTYPE, denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_NOADDLINK, denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_NOADDRING, denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_NOCHANGEBRANCH, denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_NOCHANGELINK, denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_NODELETE, denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_NODELETECHAIN, denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_NOEXTEND, denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_NOOWNER, denoptim.programs.RunTimeParameters.ParametersType.FS_PARAMS, denoptim.graph.Vertex.getChilddren(), denoptim.fragspace.FragmentSpaceParameters.getFragmentSpace(), denoptim.graph.DGraph.getGraphId(), denoptim.graph.DGraph.getLocalMsg(), denoptim.programs.RunTimeParameters.getParameters(), denoptim.graph.DGraph.getTemplateJacket(), denoptim.graph.DGraph.indexOf(), denoptim.ga.GraphOperations.rebuildBranch(), denoptim.graph.DGraph.setLocalMsg(), denoptim.constants.DENOPTIMConstants.STOREDVID, and denoptim.ga.GraphOperations.substituteLink().

Here is the call graph for this function:

◆ performMutation() [4/4]

static boolean denoptim.ga.GraphOperations.performMutation ( Vertex  vertex,
MutationType  mType,
Monitor  mnt,
GAParameters  settings 
) throws DENOPTIMException
static

Mutates the given vertex according to the given mutation type, if possible.

Vertex that do not belong to any graph or that do not allow the requested kind of mutation, are not mutated. The graph that owns the vertex ill be altered and the original structure and content of the graph will be lost.

Parameters
vertexthe vertex to mutate.
mTypethe type of mutation to perform.
Returns
true if the mutation is successful.
Exceptions
DENOPTIMException

Definition at line 2214 of file GraphOperations.java.

References denoptim.graph.DGraph.clone(), denoptim.graph.DGraph.indexOf(), denoptim.ga.GraphOperations.performMutation(), and denoptim.io.DenoptimIO.writeGraphToSDF().

Here is the call graph for this function:

◆ processCombinationOfEndPoints()

static void denoptim.ga.GraphOperations.processCombinationOfEndPoints ( Vertex[]  pair,
List< Vertex[]>  cominationOfEnds,
List< XoverSite collector,
FragmentSpace  fragSpace 
)
staticprivate

Given a pair of seed vertexes that define where a pair of subgraphs stars in the corresponding original graphs, this method evaluates the use of a given list of candidate subgraph end points.

When it finds a pair of subgraphs that can be used to do crossover it stores them as a XoverSite in the given collector.

Parameters
pairthe seed vertexes in each of the graph
cominationOfEndsthe combination of subgraph end points to be evaluated. The order of the entries does not matter as we will consider the permutations of this list.
collectorthis is where the crossover sites are stored.

Definition at line 356 of file GraphOperations.java.

References denoptim.ga.GraphOperations.processPermutationOfEndPoints().

Referenced by denoptim.ga.GraphOperations.locateCompatibleXOverPoints().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processPermutationOfEndPoints()

static void denoptim.ga.GraphOperations.processPermutationOfEndPoints ( Vertex[]  pair,
List< Vertex[]>  chosenSequenceOfEndpoints,
List< XoverSite collector,
FragmentSpace  fragSpace 
)
staticprivate

Given a pair of seed vertexes that define where a pair of subgraphs stars in the corresponding original graphs, this method evaluates the use of a given ordered list of candidate subgraph end points.

When it finds a pair of subgraphs that can be used to do crossover it stores them as a XoverSite in the given collector.

Parameters
pairthe seed vertexes in each of the graph
chosenSequenceOfEndpointsthe specific permutation of subgraph end points to be evaluated.
collectorthis is where the crossover sites are stored.

Definition at line 405 of file GraphOperations.java.

References denoptim.ga.GraphOperations.checkAndAddXoverSites(), denoptim.graph.DGraph.extractSubgraph(), denoptim.graph.DGraph.getChildTreeLimited(), denoptim.graph.Vertex.getGraphOwner(), denoptim.graph.rings.PathSubGraph.getVertecesPath(), denoptim.graph.DGraph.isIsomorphicTo(), and denoptim.utils.CrossoverType.SUBGRAPH.

Referenced by denoptim.ga.GraphOperations.processCombinationOfEndPoints().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rebuildBranch()

static boolean denoptim.ga.GraphOperations.rebuildBranch ( Vertex  vertex,
boolean  force,
int  chosenVrtxIdx,
int  chosenApId,
GAParameters  settings 
) throws DENOPTIMException
staticprotected

Substitutes a vertex and any child branch.

Deletes the given vertex from the graph that owns it, and removes any child vertex (i.e., reachable from the given vertex by a directed path). Then it tries to extent the graph from the parent vertex (i.e., the one that was originally holding the given vertex). Moreover, additional extension may occur on any available attachment point of the parent vertex.

Parameters
vertexto mutate (the given vertex).
forceset to true to ignore growth probability.
chosenVrtxIdxif greater than or equals to zero, sets the choice of the vertex to the given index.
chosenApIdif greater than or equals to zero, sets the choice of the AP to the given index.
maxHeavyAtomsmaximum number of heavy atoms.
Returns
true if substitution is successful
Exceptions
DENOPTIMException

Definition at line 840 of file GraphOperations.java.

References denoptim.ga.GraphOperations.deleteFragment(), denoptim.ga.GraphOperations.extendGraph(), denoptim.graph.Edge.getSrcVertex(), denoptim.graph.DGraph.getVertexWithId(), and denoptim.graph.DGraph.hasSymmetryInvolvingVertex().

Referenced by denoptim.ga.GraphOperations.performMutation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ substituteLink()

static boolean denoptim.ga.GraphOperations.substituteLink ( Vertex  vertex,
int  chosenVrtxIdx,
Monitor  mnt,
FragmentSpace  fragSpace 
) throws DENOPTIMException
staticprotected

Substitutes a vertex while keeping its surrounding.

Does not replace with same vertex (i.e., new vertex will have different building block ID, but might look the same wrt content and properties).

Parameters
vertexthe vertex to replace with another one.
chosenVrtxIdxif greater than or equals to zero, sets the choice of the incoming vertex to the given index. AP mapping between old and new vertex is not controllable in this method.
mntthe monitor keeping track of what happens in EA operations. This does not affect the mutation. It only measures how many attempts and failures occur.
Returns
true if the mutation is successful.
Exceptions
DENOPTIMException

Definition at line 657 of file GraphOperations.java.

References denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_NOCHANGELINK_EDIT, denoptim.logging.CounterID.FAILEDMUTATTEMTS_PERFORM_NOCHANGELINK_FIND, denoptim.fragspace.GraphLinkFinder.foundAlternativeLink(), denoptim.graph.Vertex.getBuildingBlockId(), denoptim.graph.Vertex.getBuildingBlockType(), denoptim.fragspace.GraphLinkFinder.getChosenAlternativeLink(), denoptim.fragspace.GraphLinkFinder.getChosenAPMapping(), denoptim.graph.DGraph.replaceVertex(), and denoptim.graph.APMapping.toIntMappig().

Referenced by denoptim.ga.GraphOperations.performMutation().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: