leaf-analysis/src/simulation/CSPLinks.java
/**
	 * Helper Method to create constraints for contribution links.
	 * @param cType	ContributionType of the link
	 * @param src	Source time-point
	 * @param tgt	Target time-point
	 * @return		The resulting constraint.
	 */
Helper Method to create constraints for contribution links.
@param cType ContributionType of the link
@param src   Source time-point
@param tgt   Target time-point
@return              The resulting constraint.
Helper Method to create constraints for contribution links . @param cType ContributionType of the link @param src Source time - point @param tgt Target time - point @return The resulting constraint .
private static PrimitiveConstraint createForwardContributionConstraint(ContributionType cType, BooleanVar[] src, BooleanVar[] tgt){
		PrimitiveConstraint result = null;
		if (cType == ContributionType.PP){ 					
			result = new And(new And(new Or(new XeqC(src[3], 0), new XeqC(tgt[3], 1)), new Or(new XeqC(src[2], 0), new XeqC(tgt[2], 1))), 
					         new And(new Or(new XeqC(src[1], 0), new XeqC(tgt[1], 1)), new Or(new XeqC(src[0], 0), new XeqC(tgt[0], 1))));
		}else if (cType == ContributionType.P){				
			result = new And(new Or(new XeqC(src[2], 0), new XeqC(tgt[2], 1)), new Or(new XeqC(src[1], 0), new XeqC(tgt[1], 1)));
		}else if (cType == ContributionType.M){				
			result = new And(new Or(new XeqC(src[2], 0), new XeqC(tgt[1], 1)), new Or(new XeqC(src[1], 0), new XeqC(tgt[2], 1)));
		}else if (cType == ContributionType.MM){				-
			result = new And(new And(new Or(new XeqC(src[3], 0), new XeqC(tgt[0], 1)), new Or(new XeqC(src[2], 0), new XeqC(tgt[1], 1))), 
			                 new And(new Or(new XeqC(src[1], 0), new XeqC(tgt[2], 1)), new Or(new XeqC(src[0], 0), new XeqC(tgt[3], 1))));
		}else if (cType == ContributionType.SPP){ 			+S 
			result = new And(new Or(new XeqC(src[3], 0), new XeqC(tgt[3], 1)), new Or(new XeqC(src[2], 0), new XeqC(tgt[2], 1)));
		}else if (cType == ContributionType.SP){			S
			result = new Or(new XeqC(src[2], 0), new XeqC(tgt[2], 1));
		}else if (cType == ContributionType.SM){			S
			result = new Or(new XeqC(src[2], 0), new XeqC(tgt[1], 1));
		}else if (cType == ContributionType.SMM){			-S
			result = new And(new Or(new XeqC(src[3], 0), new XeqC(tgt[0], 1)), new Or(new XeqC(src[2], 0), new XeqC(tgt[1], 1)));
		}else if (cType == ContributionType.DPP){ 			+D 
			result = new And(new Or(new XeqC(src[1], 0), new XeqC(tgt[1], 1)), new Or(new XeqC(src[0], 0), new XeqC(tgt[0], 1)));
		}else if (cType == ContributionType.DP){			D
			result = new Or(new XeqC(src[1], 0), new XeqC(tgt[1], 1));
		}else if (cType == ContributionType.DM){			D
			result = new Or(new XeqC(src[1], 0), new XeqC(tgt[2], 1));
		}else if (cType == ContributionType.DMM){			-D
			result = new And(new Or(new XeqC(src[1], 0), new XeqC(tgt[2], 1)), new Or(new XeqC(src[0], 0), new XeqC(tgt[3], 1)));
		}else
			throw new RuntimeException("ERROR: No rule for " + cType.toString() + " link type.");	
		if (Main.DEBUG)
			System.out.println("Link: " + result.toString());
		return result;
	}
private static PrimitiveConstraint createForwardContributionConstraint ( ContributionType cType , BooleanVar [ ] src , BooleanVar [ ] tgt ) { PrimitiveConstraint result = null ; if ( cType == ContributionType . PP ) { result = new And ( new And ( new Or ( new XeqC ( src [ 3 ] , 0 ) , new XeqC ( tgt [ 3 ] , 1 ) ) , new Or ( new XeqC ( src [ 2 ] , 0 ) , new XeqC ( tgt [ 2 ] , 1 ) ) ) , new And ( new Or ( new XeqC ( src [ 1 ] , 0 ) , new XeqC ( tgt [ 1 ] , 1 ) ) , new Or ( new XeqC ( src [ 0 ] , 0 ) , new XeqC ( tgt [ 0 ] , 1 ) ) ) ) ; } else if ( cType == ContributionType . P ) { result = new And ( new Or ( new XeqC ( src [ 2 ] , 0 ) , new XeqC ( tgt [ 2 ] , 1 ) ) , new Or ( new XeqC ( src [ 1 ] , 0 ) , new XeqC ( tgt [ 1 ] , 1 ) ) ) ; } else if ( cType == ContributionType . M ) { result = new And ( new Or ( new XeqC ( src [ 2 ] , 0 ) , new XeqC ( tgt [ 1 ] , 1 ) ) , new Or ( new XeqC ( src [ 1 ] , 0 ) , new XeqC ( tgt [ 2 ] , 1 ) ) ) ; } else if ( cType == ContributionType . MM ) { result = new And ( new And ( new Or ( new XeqC ( src [ 3 ] , 0 ) , new XeqC ( tgt [ 0 ] , 1 ) ) , new Or ( new XeqC ( src [ 2 ] , 0 ) , new XeqC ( tgt [ 1 ] , 1 ) ) ) , new And ( new Or ( new XeqC ( src [ 1 ] , 0 ) , new XeqC ( tgt [ 2 ] , 1 ) ) , new Or ( new XeqC ( src [ 0 ] , 0 ) , new XeqC ( tgt [ 3 ] , 1 ) ) ) ) ; } else if ( cType == ContributionType . SPP ) { result = new And ( new Or ( new XeqC ( src [ 3 ] , 0 ) , new XeqC ( tgt [ 3 ] , 1 ) ) , new Or ( new XeqC ( src [ 2 ] , 0 ) , new XeqC ( tgt [ 2 ] , 1 ) ) ) ; } else if ( cType == ContributionType . SP ) { result = new Or ( new XeqC ( src [ 2 ] , 0 ) , new XeqC ( tgt [ 2 ] , 1 ) ) ; } else if ( cType == ContributionType . SM ) { result = new Or ( new XeqC ( src [ 2 ] , 0 ) , new XeqC ( tgt [ 1 ] , 1 ) ) ; } else if ( cType == ContributionType . SMM ) { result = new And ( new Or ( new XeqC ( src [ 3 ] , 0 ) , new XeqC ( tgt [ 0 ] , 1 ) ) , new Or ( new XeqC ( src [ 2 ] , 0 ) , new XeqC ( tgt [ 1 ] , 1 ) ) ) ; } else if ( cType == ContributionType . DPP ) { result = new And ( new Or ( new XeqC ( src [ 1 ] , 0 ) , new XeqC ( tgt [ 1 ] , 1 ) ) , new Or ( new XeqC ( src [ 0 ] , 0 ) , new XeqC ( tgt [ 0 ] , 1 ) ) ) ; } else if ( cType == ContributionType . DP ) { result = new Or ( new XeqC ( src [ 1 ] , 0 ) , new XeqC ( tgt [ 1 ] , 1 ) ) ; } else if ( cType == ContributionType . DM ) { result = new Or ( new XeqC ( src [ 1 ] , 0 ) , new XeqC ( tgt [ 2 ] , 1 ) ) ; } else if ( cType == ContributionType . DMM ) { result = new And ( new Or ( new XeqC ( src [ 1 ] , 0 ) , new XeqC ( tgt [ 2 ] , 1 ) ) , new Or ( new XeqC ( src [ 0 ] , 0 ) , new XeqC ( tgt [ 3 ] , 1 ) ) ) ; } else throw new RuntimeException ( "ERROR: No rule for " + cType . toString ( ) + " link type." ) ; if ( Main . DEBUG ) System . out . println ( "Link: " + result . toString ( ) ) ; return result ; }
Helper Method to create constraints for contribution links.
Helper Method to create constraints for contribution links .
//++  //+ //- //-- //++S  //+S //-S //--S //++D  //+D //-D //--D