本文整理汇总了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;
}
示例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;
}
示例4: make
public static Expression make(Expression numerator, Expression denominator) {
if (numerator.equals(denominator)) {
return Expressions.ONE;
}
return Expressions.apply("/", numerator, denominator);
}