24 package org.lightjason.agentspeak.consistency.metric;
28 import java.util.Collection;
29 import java.util.HashSet;
31 import java.util.stream.Collectors;
32 import java.util.stream.Stream;
43 public final Double
apply(
final Stream<? extends ITerm> p_first,
final Stream<? extends ITerm> p_second )
45 final Collection<ITerm> l_first = p_first.collect( Collectors.toCollection( HashSet<ITerm>::new ) );
46 final Collection<ITerm> l_second = p_second.collect( Collectors.toCollection( HashSet<ITerm>::new ) );
49 final double l_union = Stream.concat( l_first.stream(), l_second.stream() ).count();
50 final Set<? extends ITerm> l_intersection =
new HashSet<>( l_first );
51 l_intersection.retainAll( l_second );
54 return ( 2.0 * l_union
59 / l_intersection.size();
metric interface of the coherency structure
calculates the distance with respect to size of union and intersection of beliefbases.
final Double apply(final Stream<? extends ITerm > p_first, final Stream<? extends ITerm > p_second)