當前位置: 首頁>>代碼示例>>Java>>正文


Java Expressions.ONE屬性代碼示例

本文整理匯總了Java中com.sri.ai.expresso.helper.Expressions.ONE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Expressions.ONE屬性的具體用法?Java Expressions.ONE怎麽用?Java Expressions.ONE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.sri.ai.expresso.helper.Expressions的用法示例。


在下文中一共展示了Expressions.ONE屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getQuantifiedExpression

private static Expression getQuantifiedExpression(QuantifiedExpression q) {
	Expression result;
	if (q instanceof IntensionalSet) {
		result = ((IntensionalSet)q).getHead();
	}
	else if (q instanceof CountingFormula) {
		result = Expressions.ONE;
	}
	else if (q instanceof QuantifiedExpressionWithABody) {
		result = ((QuantifiedExpressionWithABody)q).getBody();
	}
	else {
		throw new UnsupportedOperationException("Quantified expression currently not supported: "+q);
	}
	return result;
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:16,代碼來源:SetOfArgumentTuplesForFunctionOccurringInExpression.java

示例2: simplify

public static Expression simplify(Expression expression) {
	Expression base     = expression.get(0);
	Expression exponent = expression.get(1);

	Rational exponentValue = null;
	Rational baseValue     = null;
	
	if (Expressions.isNumber(exponent)) {
		exponentValue = exponent.rationalValue();
		if (exponentValue.isZero()) {
			return Expressions.ONE;
		}
		if (exponentValue.isOne()) {
			return base;
		}
	}
	
	if (Expressions.isNumber(base)) {
		baseValue = base.rationalValue();
		if (baseValue.isOne()) {
			return Expressions.ONE;
		}
		// we refrain from simplifying 0^x to 0, because x could be 0 itself.
	}
	
	if (baseValue != null && exponentValue != null) {
		Rational   pow    = baseValue.pow(exponentValue);
		Expression result = Expressions.makeSymbol(pow);
		return result;
	}

	return expression;
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:33,代碼來源:Exponentiation.java

示例3: solve

@Override
public SolverResult solve(String solveRequestId,
		ModelLanguage modelLanguage, String model, String evidenceQuery) throws Exception {

	if (modelLanguage != ModelLanguage.HOGMv1) {
		throw new UnsupportedOperationException(
				modelLanguage.name() + " is currently not supported by this solver.");
	}

	SGSolverCallResult prResult = prCallSGSolverCLI(model, evidenceQuery);

	Expression probabilityEvidence = null;	
	if (prResult.resultExpression != null) {
		Expression queryExpr = Expressions.parse(evidenceQuery);
		Expression resultExpr = Expressions.parse(prResult.resultExpression);
		// Simplify if possible
		if (IfThenElse.isIfThenElse(resultExpr)) {
			Expression condition = IfThenElse.condition(resultExpr);
			if (condition.equals(queryExpr)) {
				probabilityEvidence = IfThenElse.thenBranch(resultExpr);
			} else if (Not.isNegation(condition) && condition.get(0).equals(queryExpr)) {
				probabilityEvidence = IfThenElse.elseBranch(resultExpr);
			}
		} else if (resultExpr.equals(queryExpr)) {
			probabilityEvidence = Expressions.ONE;
		} else if (Not.isNegation(resultExpr)) {
			if (resultExpr.get(0).equals(queryExpr)) {
				probabilityEvidence = Expressions.ZERO;
			}
		}
		// If unable to simplify just return the result as computed (i.e. likely symbolic).
		if (probabilityEvidence == null) {
			probabilityEvidence = resultExpr;
		}
	}

	SolverResult result = new SolverResult(0,
			prResult.sgSolverProcessTookMS, probabilityEvidence);
	return result;
}
 
開發者ID:aic-sri-international,項目名稱:aic-praise,代碼行數:40,代碼來源:PRAiSESolver.java

示例4: make

public static Expression make(Expression numerator, Expression denominator) {
	if (numerator.equals(denominator)) {
		return Expressions.ONE;
	}
	return Expressions.apply("/", numerator, denominator);
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:6,代碼來源:Division.java


注:本文中的com.sri.ai.expresso.helper.Expressions.ONE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。