@ Override public int compare ( Activation a1 , Activation a2 ) { //Salience-based conflict resolution. final int s1 = a1 . getSalience ( ) ; final int s2 = a2 . getSalience ( ) ; if ( s1 > s2 ) { return - 1 ; } else if ( s1 < s2 ) { return 1 ; } //Propagation-based conflict resolution. final long p1 = a1 . getPropagationContext ( ) . getPropagationNumber ( ) ; final long p2 = a2 . getPropagationContext ( ) . getPropagationNumber ( ) ; if ( p1 != p2 ) { return ( int ) ( p2 - p1 ) ; } //Recency-based conflict resolution. final long r1 = a1 . getTuple ( ) . getRecency ( ) ; final long r2 = a2 . getTuple ( ) . getRecency ( ) ; if ( r1 != r2 ) { return ( int ) ( r2 - r1 ) ; } //Topological-sort-based conflict resolution. final Rule rule1 = a1 . getRule ( ) ; final Rule rule2 = a2 . getRule ( ) ; if ( rule1 != rule2 ) { TemporalPropositionDefinition def1 = this . ruleToTPD . get ( rule1 ) ; TemporalPropositionDefinition def2 = this . ruleToTPD . get ( rule2 ) ; /* * If def1 is null, then rule1 does not correspond to an * abstraction or context definition. If def2 is null, then rule2 * does not correspond to an abstraction or context definition. In * either case, topological sort-based conflict resolution does not * apply, so skip to the next conflict resolution strategy. */ if ( def1 != null && def2 != null ) { return this . topSortComp . compare ( def1 , def2 ) ; } } //Load order-based conflict resolution. final long l1 = rule1 . getLoadOrder ( ) ; final long l2 = rule2 . getLoadOrder ( ) ; return ( int ) ( l2 - l1 ) ; }
Compares two activations for order . Sequentially tries salience - propagation - recency - topological - and load order - based conflict resolution . The first of these conflict resolution attempts that successfully finds a non - equal ordering of the two activations immediately returns the ordering found .