IncrementalPM/src/conformance/traceAnalysis/resourceDeviation/ResourceDeviationConformanceCalculator.java
public double quantifyChange(Map<String, Map<String, Double>> deviations) {
		Map<String, Map<String, Double>> newDeviations=new HashMap<String, Map<String, Double>>();
		Map<String, Map<String, Double>> oldDeviations=new HashMap<String, Map<String, Double>>();
		Map<String,Double> cnts=new HashMap<String, Double>();
		
		//first, get all resources deviations that did not change and add to copy
		for(String activity : this.violatingResourcesAbsolute.keySet()) {
			oldDeviations.put(activity,new HashMap<String, Double>());
			cnts.put(activity,this.cnts.get(activity));
			newDeviations.put(activity,new HashMap<String, Double>());

			
			for(Entry<String, Double> resource : this.violatingResourcesAbsolute.get(activity).entrySet()) {
				oldDeviations.get(activity).put(resource.getKey(),resource.getValue()/cnts.get(activity));
				if(!deviations.containsKey(activity)) {
					newDeviations.get(activity).put(resource.getKey(),resource.getValue()/cnts.get(activity));
				}
			}
		}
		
		for(String activity : deviations.keySet()) {
			if(!newDeviations.containsKey(activity)) {
				newDeviations.put(activity, new HashMap<String, Double>());
			}
		
			double size = 0.0;
			for (double value : deviations.get(activity).values()) {
				size=size+value;
			}
			//if activity is new and was not deviating before, just add all resource from deviations
			if(!this.violatingResourcesAbsolute.containsKey(activity)) {
				for(Entry<String, Double> resource : deviations.get(activity).entrySet()) {
					newDeviations.get(activity).put(resource.getKey(), resource.getValue()/size);
				}
			}
			
			//for all remaining activities, merge deviation counts of resources
			else {
				Set<String> unionKeySet = new HashSet<String>();
				for(String key : violatingResourcesAbsolute.get(activity).keySet())
					unionKeySet.add(key);
				for(String key : deviations.get(activity).keySet())
					unionKeySet.add(key);
				for(String key : unionKeySet) {
					double violatingResourceCount=violatingResourcesAbsolute.get(activity).getOrDefault(key,0.0);
					double deviationResourceCount=deviations.get(activity).getOrDefault(key,0.0);

					newDeviations.get(activity).put(key, (deviationResourceCount+violatingResourceCount)/(size+cnts.getOrDefault(activity,0.0)));
				}
			}
		}
		return calculateDistance(oldDeviations, newDeviations);
	}
/**
	 * locally create potential future state induced by deviations and compare for significant change, convert to relative frequency as soon as possible
	 */
locally create potential future state induced by deviations and compare for significant change, convert to relative frequency as soon as possible
locally create potential future state induced by deviations and compare for significant change convert to relative frequency as soon as possible
public double quantifyChange(Map<String, Map<String, Double>> deviations) {
		Map<String, Map<String, Double>> newDeviations=new HashMap<String, Map<String, Double>>();
		Map<String, Map<String, Double>> oldDeviations=new HashMap<String, Map<String, Double>>();
		Map<String,Double> cnts=new HashMap<String, Double>();
		for(String activity : this.violatingResourcesAbsolute.keySet()) {
			oldDeviations.put(activity,new HashMap<String, Double>());
			cnts.put(activity,this.cnts.get(activity));
			newDeviations.put(activity,new HashMap<String, Double>());
			for(Entry<String, Double> resource : this.violatingResourcesAbsolute.get(activity).entrySet()) {
				oldDeviations.get(activity).put(resource.getKey(),resource.getValue()/cnts.get(activity));
				if(!deviations.containsKey(activity)) {
					newDeviations.get(activity).put(resource.getKey(),resource.getValue()/cnts.get(activity));
				}
			}
		}
		for(String activity : deviations.keySet()) {
			if(!newDeviations.containsKey(activity)) {
				newDeviations.put(activity, new HashMap<String, Double>());
			}
			double size = 0.0;
			for (double value : deviations.get(activity).values()) {
				size=size+value;
			}
			if(!this.violatingResourcesAbsolute.containsKey(activity)) {
				for(Entry<String, Double> resource : deviations.get(activity).entrySet()) {
					newDeviations.get(activity).put(resource.getKey(), resource.getValue()/size);
				}
			}
			else {
				Set<String> unionKeySet = new HashSet<String>();
				for(String key : violatingResourcesAbsolute.get(activity).keySet())
					unionKeySet.add(key);
				for(String key : deviations.get(activity).keySet())
					unionKeySet.add(key);
				for(String key : unionKeySet) {
					double violatingResourceCount=violatingResourcesAbsolute.get(activity).getOrDefault(key,0.0);
					double deviationResourceCount=deviations.get(activity).getOrDefault(key,0.0);
					newDeviations.get(activity).put(key, (deviationResourceCount+violatingResourceCount)/(size+cnts.getOrDefault(activity,0.0)));
				}
			}
		}
		return calculateDistance(oldDeviations, newDeviations);
	}
public double quantifyChange ( Map < String , Map < String , Double > > deviations ) { Map < String , Map < String , Double > > newDeviations = new HashMap < String , Map < String , Double > > ( ) ; Map < String , Map < String , Double > > oldDeviations = new HashMap < String , Map < String , Double > > ( ) ; Map < String , Double > cnts = new HashMap < String , Double > ( ) ; for ( String activity : this . violatingResourcesAbsolute . keySet ( ) ) { oldDeviations . put ( activity , new HashMap < String , Double > ( ) ) ; cnts . put ( activity , this . cnts . get ( activity ) ) ; newDeviations . put ( activity , new HashMap < String , Double > ( ) ) ; for ( Entry < String , Double > resource : this . violatingResourcesAbsolute . get ( activity ) . entrySet ( ) ) { oldDeviations . get ( activity ) . put ( resource . getKey ( ) , resource . getValue ( ) / cnts . get ( activity ) ) ; if ( ! deviations . containsKey ( activity ) ) { newDeviations . get ( activity ) . put ( resource . getKey ( ) , resource . getValue ( ) / cnts . get ( activity ) ) ; } } } for ( String activity : deviations . keySet ( ) ) { if ( ! newDeviations . containsKey ( activity ) ) { newDeviations . put ( activity , new HashMap < String , Double > ( ) ) ; } double size = 0.0 ; for ( double value : deviations . get ( activity ) . values ( ) ) { size = size + value ; } if ( ! this . violatingResourcesAbsolute . containsKey ( activity ) ) { for ( Entry < String , Double > resource : deviations . get ( activity ) . entrySet ( ) ) { newDeviations . get ( activity ) . put ( resource . getKey ( ) , resource . getValue ( ) / size ) ; } } else { Set < String > unionKeySet = new HashSet < String > ( ) ; for ( String key : violatingResourcesAbsolute . get ( activity ) . keySet ( ) ) unionKeySet . add ( key ) ; for ( String key : deviations . get ( activity ) . keySet ( ) ) unionKeySet . add ( key ) ; for ( String key : unionKeySet ) { double violatingResourceCount = violatingResourcesAbsolute . get ( activity ) . getOrDefault ( key , 0.0 ) ; double deviationResourceCount = deviations . get ( activity ) . getOrDefault ( key , 0.0 ) ; newDeviations . get ( activity ) . put ( key , ( deviationResourceCount + violatingResourceCount ) / ( size + cnts . getOrDefault ( activity , 0.0 ) ) ) ; } } } return calculateDistance ( oldDeviations , newDeviations ) ; }
locally create potential future state induced by deviations and compare for significant change, convert to relative frequency as soon as possible
locally create potential future state induced by deviations and compare for significant change convert to relative frequency as soon as possible
//first, get all resources deviations that did not change and add to copy //if activity is new and was not deviating before, just add all resource from deviations //for all remaining activities, merge deviation counts of resources