/** * Special case congestion minimisation, rotate terminals bonds around ring * systems so they are inside the ring. * * @param pairs congested atom pairs */ void invert(Collection<AtomPair> pairs) { for (AtomPair pair : pairs) { if (congestion.contribution(pair.fst, pair.snd) < MIN_SCORE) continue; if (fusionPointInversion(pair)) continue; if (macroCycleInversion(pair)) continue; } }
Congestion(IAtomContainer mol, int[][] adjList) { final int numAtoms = mol.getAtomCount(); this.contribution = new double[numAtoms][numAtoms]; this.atoms = AtomContainerManipulator.getAtomArray(mol); for (int v = 0; v < numAtoms; v++) for (int w : adjList[v]) contribution[v][v] = contribution[v][w] = -1; this.score = initScore(); }
double min = congestion.score(); congestion.update(visited, stackBackup.xs, stackBackup.len); double delta = min - congestion.score(); (delta > 1 && congestion.contribution(pair.fst, pair.snd) < MIN_SCORE)) { continue Pair; } else { congestion.update(visited, stackBackup.xs, stackBackup.len); congestion.score = min;
private boolean fusionPointInversion(AtomPair pair) { // not candidates for inversion // > 3 bonds if (pair.bndAt.length != 3) return false; if (bfix.contains(pair.bndAt[0]) || bfix.contains(pair.bndAt[2])) return false; // we want *!@*@*!@* if (!pair.bndAt[0].isInRing() || pair.bndAt[1].isInRing() || pair.bndAt[2].isInRing()) return false; // non-terminals if (adjList[pair.fst].length > 1 || adjList[pair.snd].length > 1) return false; IAtom fst = atoms[pair.fst]; // choose which one to invert, preffering hydrogens stackBackup.clear(); if (fst.getAtomicNumber() == 1) stackBackup.push(pair.fst); else stackBackup.push(pair.snd); reflect(stackBackup, pair.bndAt[0].getBegin(), pair.bndAt[0].getEnd()); congestion.update(stackBackup.xs, stackBackup.len); return true; }
/** * Refine the 2D coordinates of a layout to reduce overlap and congestion. */ public void refine() { for (int i = 1; i <= MAX_ITERATIONS; i++) { final List<AtomPair> pairs = findCongestedPairs(); if (pairs.isEmpty()) break; final double min = congestion.score(); // rotation: flipping around sigma bonds rotate(pairs); // rotation improved, so try more rotation, we may have caused // new conflicts that can be resolved through more rotations if (congestion.score() < min) continue; // inversion: terminal atoms can be placed inside rings // which is preferable to bending or stretching invert(pairs); if (congestion.score() < min) continue; // bending or stretching: least favourable but sometimes // the only way. We try either and use the best bendOrStretch(pairs); if (congestion.score() < min) continue; break; } }
this.visited = new boolean[atoms.length]; this.congestion = new Congestion(mol, adjList);
double min = congestion.score(); congestion.update(visited, stackBackup.xs, stackBackup.len); double delta = min - congestion.score(); (delta > 1 && congestion.contribution(pair.fst, pair.snd) < MIN_SCORE)) { continue Pair; } else { congestion.update(visited, stackBackup.xs, stackBackup.len); congestion.score = min;
private boolean fusionPointInversion(AtomPair pair) { // not candidates for inversion // > 3 bonds if (pair.bndAt.length != 3) return false; if (bfix.contains(pair.bndAt[0]) || bfix.contains(pair.bndAt[2])) return false; // we want *!@*@*!@* if (!pair.bndAt[0].isInRing() || pair.bndAt[1].isInRing() || pair.bndAt[2].isInRing()) return false; // non-terminals if (adjList[pair.fst].length > 1 || adjList[pair.snd].length > 1) return false; IAtom fst = atoms[pair.fst]; // choose which one to invert, preffering hydrogens stackBackup.clear(); if (fst.getAtomicNumber() == 1) stackBackup.push(pair.fst); else stackBackup.push(pair.snd); reflect(stackBackup, pair.bndAt[0].getBegin(), pair.bndAt[0].getEnd()); congestion.update(stackBackup.xs, stackBackup.len); return true; }
/** * Refine the 2D coordinates of a layout to reduce overlap and congestion. */ public void refine() { for (int i = 1; i <= MAX_ITERATIONS; i++) { final List<AtomPair> pairs = findCongestedPairs(); if (pairs.isEmpty()) break; final double min = congestion.score(); // rotation: flipping around sigma bonds rotate(pairs); // rotation improved, so try more rotation, we may have caused // new conflicts that can be resolved through more rotations if (congestion.score() < min) continue; // inversion: terminal atoms can be placed inside rings // which is preferable to bending or stretching invert(pairs); if (congestion.score() < min) continue; // bending or stretching: least favourable but sometimes // the only way. We try either and use the best bendOrStretch(pairs); if (congestion.score() < min) continue; break; } }
this.visited = new boolean[atoms.length]; this.congestion = new Congestion(mol, adjList);
/** * Special case congestion minimisation, rotate terminals bonds around ring * systems so they are inside the ring. * * @param pairs congested atom pairs */ void invert(Collection<AtomPair> pairs) { for (AtomPair pair : pairs) { if (congestion.contribution(pair.fst, pair.snd) < MIN_SCORE) continue; if (fusionPointInversion(pair)) continue; if (macroCycleInversion(pair)) continue; } }
Congestion(IAtomContainer mol, int[][] adjList) { final int numAtoms = mol.getAtomCount(); this.contribution = new double[numAtoms][numAtoms]; this.atoms = AtomContainerManipulator.getAtomArray(mol); for (int v = 0; v < numAtoms; v++) for (int w : adjList[v]) contribution[v][v] = contribution[v][w] = -1; this.score = initScore(); }
final double score = congestion.score(); double min = score; stretch(stack, beg, end, pair.attempt * STRETCH_STEP); congestion.update(visited, stack.xs, stack.len); if (percDiff(score, congestion.score()) >= IMPROVEMENT_PERC_THRESHOLD && congestion.score() < min) { backupCoords(coords, stack); min = congestion.score(); stackBackup.copyFrom(stack); congestion.update(visited, stack.xs, stack.len); congestion.score = score;
for (int u = 0; u < numAtoms; u++) { for (int v = u + 1; v < numAtoms; v++) { double contribution = congestion.contribution(u, v);
final double score = congestion.score(); double min = score; stretch(stack, beg, end, pair.attempt * STRETCH_STEP); congestion.update(visited, stack.xs, stack.len); if (percDiff(score, congestion.score()) >= IMPROVEMENT_PERC_THRESHOLD && congestion.score() < min) { backupCoords(coords, stack); min = congestion.score(); stackBackup.copyFrom(stack); congestion.update(visited, stack.xs, stack.len); congestion.score = score;
for (int u = 0; u < numAtoms; u++) { for (int v = u + 1; v < numAtoms; v++) { double contribution = congestion.contribution(u, v);