19package denoptim.fragspace;
21import java.util.ArrayList;
22import java.util.LinkedHashMap;
25import denoptim.exception.DENOPTIMException;
26import denoptim.graph.APClass;
27import denoptim.graph.APMapping;
28import denoptim.graph.AttachmentPoint;
29import denoptim.graph.Edge;
30import denoptim.graph.Vertex;
31import denoptim.graph.Vertex.BBType;
71 new LinkedHashMap<Vertex,List<APMapping>>();
104 this(fragSpace, originalLink, -1,
false);
120 Vertex originalLink,
int newBuildingBlockID)
123 this(fragSpace, originalLink, newBuildingBlockID,
false);
142 Vertex originalLink,
int newBuildingBlockID,
145 this.fragmentSpace = fragSpace;
148 originalLink.getBuildingBlockType(), newBuildingBlockID);
150 int candidatesOrigSize = candidates.size();
151 for (
int i=0; i<candidatesOrigSize; i++)
156 Vertex originalBB = fragSpace.getRandomizer().randomlyChooseOne(
158 candidates.remove(originalBB);
172 originalLink.getBuildingBlockId())
178 originalLink.getFreeAPCountThroughout()))
189 this.chosenNewLink =
null;
192 this.foundNewLink =
true;
209 ArrayList<Vertex> candidates =
new ArrayList<Vertex>();
226 candidates.add(chosenOne);
248 this(fragSpace, originalEdge,-1,
false);
268 this(fragSpace, originalEdge,newBuildingBlockID,
false);
289 Edge originalEdge,
int newBuildingBlockID,
292 this.fragmentSpace = fragSpace;
294 originalEdge.getTrgAP().getOwner().getBuildingBlockType(),
297 int candidatesOrigSize = candidates.size();
298 for (
int i=0; i<candidatesOrigSize; i++)
303 Vertex originalBB = fragSpace.getRandomizer().randomlyChooseOne(
305 candidates.remove(originalBB);
323 LinkedHashMap<AttachmentPoint,List<AttachmentPoint>> apCompatilities =
324 new LinkedHashMap<AttachmentPoint,List<AttachmentPoint>>();
326 List<AttachmentPoint> needeAPs =
new ArrayList<AttachmentPoint>();
327 needeAPs.add(originalEdge.getSrcAP());
328 needeAPs.add(originalEdge.getTrgAP());
329 for (
int j=0; j<2;j++)
335 boolean compatible =
false;
344 && cAP.getAPClass().isCPMapCompatibleWith(
352 if (apCompatilities.containsKey(oAP))
354 apCompatilities.get(oAP).add(cAP);
356 List<AttachmentPoint> lst =
357 new ArrayList<AttachmentPoint>();
359 apCompatilities.put(oAP,lst);
366 List<AttachmentPoint> keys =
367 new ArrayList<AttachmentPoint>(
368 apCompatilities.keySet());
375 List<APMapping> apMappings =
new ArrayList<APMapping>();
381 currentKey, apCompatilities, currentMapping, apMappings,
384 if (apMappings.isEmpty())
386 this.chosenNewLink =
null;
389 this.foundNewLink =
true;
392 this.chosenAPMap = fragSpace.getRandomizer().randomlyChooseOne(
An utility class to encapsulate the search for an AttachmentPoint-AttachmentPoint mapping.
APMapping getChosenAPMapping()
Returns the AttachmentPoint-AttachmentPoint mapping chosen among the possible mappings.
boolean foundMapping()
Returns true if any mapping has been found.
List< APMapping > getAllAPMappings()
Returns all AttachmentPoint-AttachmentPoint mapping found.
Class defining a space of building blocks.
boolean useAPclassBasedApproach()
Check usage of APClass-based approach, i.e., uses attachment points with annotated data (i....
Vertex getVertexFromLibrary(Vertex.BBType bbType, int bbIdx)
Returns a clone of the requested building block.
ArrayList< Vertex > getScaffoldLibrary()
ArrayList< Vertex > getFragmentLibrary()
Utility class for the fragment space.
static boolean recursiveCombiner(List< AttachmentPoint > keys, int currentKey, Map< AttachmentPoint, List< AttachmentPoint > > possibilities, APMapping combination, List< APMapping > completeCombinations, boolean screenAll, int maxCombs)
Search for all possible combinations of compatible APs.
An utility class to encapsulate the search for vertexes that satisfy constraints.
ArrayList< Vertex > getCandidateBBs(BBType bbt, int bbId)
GraphLinkFinder(FragmentSpace fragSpace, Vertex originalLink, int newBuildingBlockID)
Constructor that specifies which vertex has to be replaced and which building block ID to use as repl...
GraphLinkFinder(FragmentSpace fragSpace, Vertex originalLink)
Constructor that specifies which vertex has to be replaced.
LinkedHashMap< Vertex, List< APMapping > > getAllAlternativesFound()
Returns all the AP mapping that were identified for any candidate vertex that could be used either as...
static int maxCombs
Maximum number of combinations.
APMapping chosenAPMap
The mapping of attachment points between the original vertex/es and the chosen link.
Vertex getChosenAlternativeLink()
Returns the vertex chosen as alternative.
GraphLinkFinder(FragmentSpace fragSpace, Edge originalEdge)
Constructor that specifies which edge has to be replaced with a vertex and two edges.
GraphLinkFinder(FragmentSpace fragSpace, Edge originalEdge, int newBuildingBlockID, boolean screenAll)
Constructor that specifies which edge has to be replaced with a vertex and two edges.
boolean foundNewLink
Flag recording if at least one alternative vertex was found.
Vertex chosenNewLink
The result of the search for a compatible building block, or null if no compatible link was found.
GraphLinkFinder(FragmentSpace fragSpace, Vertex originalLink, int newBuildingBlockID, boolean screenAll)
Constructor that specifies which vertex has to be replaced.
GraphLinkFinder(FragmentSpace fragSpace, Edge originalEdge, int newBuildingBlockID)
Constructor that specifies which edge has to be replaced with a vertex and two edges.
FragmentSpace fragmentSpace
Parameter and reference to the fragment space.
APMapping getChosenAPMapping()
Returns the AP mapping that allows the usage of the vertex chosen either as alternative to be install...
boolean foundAlternativeLink()
LinkedHashMap< Vertex, List< APMapping > > allCompatLinks
The collection of all alternative vertex that can replace the original vertex, with the consistent ma...
boolean isCPMapCompatibleWith(APClass other, FragmentSpace fragSpace)
Check compatibility as defined in the compatibility matrix considering this AP as source and the othe...
Class representing a mapping between attachment points (APs).
An attachment point (AP) is a possibility to attach a Vertex onto the vertex holding the AP (i....
APClass getAPClass()
Returns the Attachment Point class.
This class represents the edge between two vertices.
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
int getBuildingBlockId()
Returns the index of the building block that should correspond to the position of the building block ...
Vertex.BBType getBuildingBlockType()
abstract List< AttachmentPoint > getAttachmentPoints()
The type of building block.