}
public DLClause getSwappedDLClause(int bodyIndex) {
m_nodeIDComparisonAtoms.clear();
for (int index=m_usedAtoms.length-1;index>=0;--index) {
m_usedAtoms[index]=false;
Atom atom=m_dlClause.getBodyAtom(index);
if (NodeIDLessEqualThan.INSTANCE.equals(atom.getDLPredicate()))
m_nodeIDComparisonAtoms.add(atom);
}
m_reorderedAtoms.clear();
m_boundVariables.clear();
Atom atom=m_dlClause.getBodyAtom(bodyIndex);
atom.getVariables(m_boundVariables);
m_reorderedAtoms.add(atom);
m_usedAtoms[bodyIndex]=true;
while (m_reorderedAtoms.size()!=m_usedAtoms.length) {
Atom bestAtom=null;
int bestAtomIndex=-1;
int bestAtomGoodness=-1000;
for (int index=m_usedAtoms.length-1;index>=0;--index)
if (!m_usedAtoms[index]) {
atom=m_dlClause.getBodyAtom(index);
int atomGoodness=getAtomGoodness(atom);
if (atomGoodness>bestAtomGoodness) {
bestAtom=atom;
bestAtomGoodness=atomGoodness;
bestAtomIndex=index;
}
}
m_reorderedAtoms.add(bestAtom);
m_usedAtoms[bestAtomIndex]=true;
bestAtom.getVariables(m_boundVariables);
m_nodeIDComparisonAtoms.remove(bestAtom);
}
Atom[] bodyAtoms=new Atom[m_reorderedAtoms.size()];
m_reorderedAtoms.toArray(bodyAtoms);
return m_dlClause.getChangedDLClause(null,bodyAtoms);