IncrementalPM/src/conformance/traceAnalysis/resourceDeviation/ResourceDeviationConformanceCalculator.java
public synchronized void updateAndGetLocalCopy(Map<String, Map<String, Double>> newDeviations, Map<String, Double> newCnts, Map<String, Double> deviationCnts, Map<String, Map<String, Double>> deviations) {
		//first, get all resources deviations that did not change and add to copy
		for (String activity :this.violatingResourcesAbsolute.keySet()) {
			if(!deviations.containsKey(activity)) {
				newDeviations.put(activity, new HashMap<String, Double>());
				for (Entry<String,Double> resource : this.violatingResourcesAbsolute.get(activity).entrySet()) {
					newDeviations.get(activity).put(resource.getKey(),resource.getValue());
					newCnts.put(activity, cnts.get(activity));
				}
			}
		}
		
		for(String activity : deviations.keySet()) {
			//update counter for each affected activity
			double size = 0.0;
			for (double value : deviations.get(activity).values()) {
				size =size +value;
			}
			this.cnts.put(activity, this.cnts.getOrDefault(activity,0.0)+size);
			newCnts.put(activity, this.cnts.getOrDefault(activity,0.0)+size);
			deviationCnts.put(activity, size);
			
			//if activity is new and was not deviating before, just add all resource from deviations
			if(!this.violatingResourcesAbsolute.containsKey(activity)) {
				this.violatingResourcesAbsolute.put(activity, new HashMap<String, Double>());
				newDeviations.put(activity, new HashMap<String,Double>());
				for (Entry<String,Double> resource : deviations.get(activity).entrySet()) {
					this.violatingResourcesAbsolute.get(activity).put(resource.getKey(),resource.getValue());
					newDeviations.get(activity).put(resource.getKey(),resource.getValue());
				}
			}
			//for all remaining activities, merge deviation counts of resources
			else {
				newDeviations.put(activity, new HashMap<String, Double>());
				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);
				
				 //= violatingResourcesAbsolute.get(activity).keySet();
				//unionKeySet.addAll(deviations.get(activity).keySet());
				for(String key : unionKeySet) {
					double violatingResourceCount=violatingResourcesAbsolute.get(activity).getOrDefault(key,0.0);
					double deviationResourceCount=deviations.get(activity).getOrDefault(key,0.0);
					this.violatingResourcesAbsolute.get(activity).put(key, violatingResourceCount+deviationResourceCount);
					newDeviations.get(activity).put(key, (deviationResourceCount+violatingResourceCount));
				}
			}
		}
	}
/**
	 * updates the current state synchronously
	 * also returns local copies after update in parameters
	 * returns absolute values, conversion to relative frequency is done locally to save time
	 */
updates the current state synchronously
also returns local copies after update in parameters
returns absolute values, conversion to relative frequency is done locally to save time
updates the current state synchronously also returns local copies after update in parameters returns absolute values conversion to relative frequency is done locally to save time
public synchronized void updateAndGetLocalCopy(Map<String, Map<String, Double>> newDeviations, Map<String, Double> newCnts, Map<String, Double> deviationCnts, Map<String, Map<String, Double>> deviations) {
		for (String activity :this.violatingResourcesAbsolute.keySet()) {
			if(!deviations.containsKey(activity)) {
				newDeviations.put(activity, new HashMap<String, Double>());
				for (Entry<String,Double> resource : this.violatingResourcesAbsolute.get(activity).entrySet()) {
					newDeviations.get(activity).put(resource.getKey(),resource.getValue());
					newCnts.put(activity, cnts.get(activity));
				}
			}
		}
		for(String activity : deviations.keySet()) {
			double size = 0.0;
			for (double value : deviations.get(activity).values()) {
				size =size +value;
			}
			this.cnts.put(activity, this.cnts.getOrDefault(activity,0.0)+size);
			newCnts.put(activity, this.cnts.getOrDefault(activity,0.0)+size);
			deviationCnts.put(activity, size);
			if(!this.violatingResourcesAbsolute.containsKey(activity)) {
				this.violatingResourcesAbsolute.put(activity, new HashMap<String, Double>());
				newDeviations.put(activity, new HashMap<String,Double>());
				for (Entry<String,Double> resource : deviations.get(activity).entrySet()) {
					this.violatingResourcesAbsolute.get(activity).put(resource.getKey(),resource.getValue());
					newDeviations.get(activity).put(resource.getKey(),resource.getValue());
				}
			}
			else {
				newDeviations.put(activity, new HashMap<String, Double>());
				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);
					this.violatingResourcesAbsolute.get(activity).put(key, violatingResourceCount+deviationResourceCount);
					newDeviations.get(activity).put(key, (deviationResourceCount+violatingResourceCount));
				}
			}
		}
	}
public synchronized void updateAndGetLocalCopy ( Map < String , Map < String , Double > > newDeviations , Map < String , Double > newCnts , Map < String , Double > deviationCnts , Map < String , Map < String , Double > > deviations ) { for ( String activity : this . violatingResourcesAbsolute . keySet ( ) ) { if ( ! deviations . containsKey ( activity ) ) { newDeviations . put ( activity , new HashMap < String , Double > ( ) ) ; for ( Entry < String , Double > resource : this . violatingResourcesAbsolute . get ( activity ) . entrySet ( ) ) { newDeviations . get ( activity ) . put ( resource . getKey ( ) , resource . getValue ( ) ) ; newCnts . put ( activity , cnts . get ( activity ) ) ; } } } for ( String activity : deviations . keySet ( ) ) { double size = 0.0 ; for ( double value : deviations . get ( activity ) . values ( ) ) { size = size + value ; } this . cnts . put ( activity , this . cnts . getOrDefault ( activity , 0.0 ) + size ) ; newCnts . put ( activity , this . cnts . getOrDefault ( activity , 0.0 ) + size ) ; deviationCnts . put ( activity , size ) ; if ( ! this . violatingResourcesAbsolute . containsKey ( activity ) ) { this . violatingResourcesAbsolute . put ( activity , new HashMap < String , Double > ( ) ) ; newDeviations . put ( activity , new HashMap < String , Double > ( ) ) ; for ( Entry < String , Double > resource : deviations . get ( activity ) . entrySet ( ) ) { this . violatingResourcesAbsolute . get ( activity ) . put ( resource . getKey ( ) , resource . getValue ( ) ) ; newDeviations . get ( activity ) . put ( resource . getKey ( ) , resource . getValue ( ) ) ; } } else { newDeviations . put ( activity , new HashMap < String , Double > ( ) ) ; 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 ) ; this . violatingResourcesAbsolute . get ( activity ) . put ( key , violatingResourceCount + deviationResourceCount ) ; newDeviations . get ( activity ) . put ( key , ( deviationResourceCount + violatingResourceCount ) ) ; } } } }
updates the current state synchronously
 also returns local copies after update in parameters
 returns absolute values, conversion to relative frequency is done locally to save time
updates the current state synchronously also returns local copies after update in parameters returns absolute values conversion to relative frequency is done locally to save time
//first, get all resources deviations that did not change and add to copy //update counter for each affected activity //if activity is new and was not deviating before, just add all resource from deviations //for all remaining activities, merge deviation counts of resources //= violatingResourcesAbsolute.get(activity).keySet(); //unionKeySet.addAll(deviations.get(activity).keySet());