private List<Variable> force(final Formula formula, final Hypergraph<Variable> hypergraph,
                               final Map<Variable, HypergraphNode<Variable>> nodes) {
    final LinkedHashMap<HypergraphNode<Variable>, Integer> initialOrdering = createInitialOrdering(formula, nodes);
    LinkedHashMap<HypergraphNode<Variable>, Integer> lastOrdering;
    LinkedHashMap<HypergraphNode<Variable>, Integer> currentOrdering = initialOrdering;
    do {
      lastOrdering = currentOrdering;
      final LinkedHashMap<HypergraphNode<Variable>, Double> newLocations = new LinkedHashMap<>();
      for (final HypergraphNode<Variable> node : hypergraph.nodes())
        newLocations.put(node, node.computeTentativeNewLocation(lastOrdering));
      currentOrdering = orderingFromTentativeNewLocations(newLocations);
    } while (shouldProceed(lastOrdering, currentOrdering));
    final Variable[] ordering = new Variable[currentOrdering.size()];
    for (final Map.Entry<HypergraphNode<Variable>, Integer> entry : currentOrdering.entrySet())
      ordering[entry.getValue()] = entry.getKey().content();
    return Arrays.asList(ordering);
  }
private List < Variable > force ( final Formula formula , final Hypergraph < Variable > hypergraph , final Map < Variable , HypergraphNode < Variable > > nodes ) { final LinkedHashMap < HypergraphNode < Variable > , Integer > initialOrdering = createInitialOrdering ( formula , nodes ) ; LinkedHashMap < HypergraphNode < Variable > , Integer > lastOrdering ; LinkedHashMap < HypergraphNode < Variable > , Integer > currentOrdering = initialOrdering ; do { lastOrdering = currentOrdering ; final LinkedHashMap < HypergraphNode < Variable > , Double > newLocations = new LinkedHashMap < > ( ) ; for ( final HypergraphNode < Variable > node : hypergraph . nodes ( ) ) newLocations . put ( node , node . computeTentativeNewLocation ( lastOrdering ) ) ; currentOrdering = orderingFromTentativeNewLocations ( newLocations ) ; } while ( shouldProceed ( lastOrdering , currentOrdering ) ) ; final Variable [ ] ordering = new Variable [ currentOrdering . size ( ) ] ; for ( final Map . Entry < HypergraphNode < Variable > , Integer > entry : currentOrdering . entrySet ( ) ) ordering [ entry . getValue ( ) ] = entry . getKey ( ) . content ( ) ; return Arrays . asList ( ordering ) ; }
Executes the main FORCE algorithm.
@param formula    the CNF formula for the ordering
@param hypergraph the hypergraph for this formula
@param nodes      the variable to hypergraph node mapping
@return the variable ordering according to the FORCE algorithm