本文整理汇总了Java中com.sri.ai.expresso.helper.Expressions.ZERO属性的典型用法代码示例。如果您正苦于以下问题:Java Expressions.ZERO属性的具体用法?Java Expressions.ZERO怎么用?Java Expressions.ZERO使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.sri.ai.expresso.helper.Expressions
的用法示例。
在下文中一共展示了Expressions.ZERO属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitPropositionalConstantDeclaration
@Override
public Expression visitPropositionalConstantDeclaration(HOGMParser.PropositionalConstantDeclarationContext ctx) {
Expression name = newSymbol(ctx.name.getText());
Expression arity = Expressions.ZERO;
Expression range = visit(ctx.range );
List<Expression> declarationArgs = new ArrayList<Expression>();
declarationArgs.add(name);
declarationArgs.add(arity);
declarationArgs.add(range);
Expression result = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(
ConstantDeclaration.FUNCTOR_CONSTANT_DECLARATION,
declarationArgs.toArray());
constantDeclarations.add(newStatementInfo(result, ctx));
return result;
}
示例2: visitPropositionalRandomVariableDeclaration
@Override
public Expression visitPropositionalRandomVariableDeclaration(HOGMParser.PropositionalRandomVariableDeclarationContext ctx) {
Expression name = newSymbol(ctx.name.getText());
Expression arity = Expressions.ZERO;
Expression range = visit(ctx.range);
List<Expression> declarationArgs = new ArrayList<Expression>();
declarationArgs.add(name);
declarationArgs.add(arity);
declarationArgs.add(range);
Expression result = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(
HOGMRandomVariableDeclaration.FUNCTOR_RANDOM_VARIABLE_DECLARATION,
declarationArgs.toArray());
randomVariableDeclarations.add(newStatementInfo(result, ctx));
return result;
}
示例3: makeRandomVariableDeclaration
/**
* Make a random variable declaration object. Will default the arity of the
* random variable declaration to 0 and range to be of sort 'Boolean' if not
* specified in the expression passed in.
*
* @param expression
* an expression in the form of a random variable declaration.
* @return a RandomVariableDeclaration object corresonding to the expression
* passed in.
*/
public static HOGMRandomVariableDeclaration makeRandomVariableDeclaration(
Expression expression) {
HOGMRandomVariableDeclaration declaration = null;
if (Expressions.hasFunctor(expression, FUNCTOR_RANDOM_VARIABLE_DECLARATION)) {
int numArgs = expression.numberOfArguments();
if (numArgs > 0) {
// Extract arguments
Expression name = expression.get(0);
Expression arity = Expressions.ZERO;
if (numArgs >= 2) {
arity = expression.get(1);
}
Expression[] parametersAndRange = new Expression[0];
if (numArgs > 2) {
parametersAndRange = new Expression[numArgs - 2];
for (int i = 2; i < numArgs; i++) {
parametersAndRange[i - 2] = expression.get(i);
}
}
else {
parametersAndRange = new Expression[0];
}
declaration = new HOGMRandomVariableDeclaration(name, arity, parametersAndRange);
}
}
if (declaration == null) {
throw new IllegalArgumentException(
"Not a legal definition of a random variable declartion:" + expression);
}
return declaration;
}
示例4: makeConstantDeclaration
/**
* Make a constant declaration object. Will default the arity of the
* constant declaration to 0 and range to be of sort 'Boolean' if not
* specified in the expression passed in.
*
* @param expression
* an expression in the form of a constant declaration.
* @return a ConstantDeclaration object corresponding to the expression
* passed in.
*/
public static ConstantDeclaration makeConstantDeclaration(
Expression expression) {
ConstantDeclaration declaration = null;
if (Expressions.hasFunctor(expression, FUNCTOR_CONSTANT_DECLARATION)) {
int numArgs = expression.numberOfArguments();
if (numArgs > 0) {
// Extract arguments
Expression name = expression.get(0);
Expression arity = Expressions.ZERO;
if (numArgs >= 2) {
arity = expression.get(1);
}
Expression[] parametersAndRange = new Expression[0];
if (numArgs > 2) {
parametersAndRange = new Expression[numArgs - 2];
for (int i = 2; i < numArgs; i++) {
parametersAndRange[i - 2] = expression.get(i);
}
}
else {
parametersAndRange = new Expression[0];
}
declaration = new ConstantDeclaration(name, arity, parametersAndRange);
}
}
if (declaration == null) {
throw new IllegalArgumentException(
"Not a legal definition of a constant declartion:" + expression);
}
return declaration;
}
示例5: 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;
}
示例6: HOGMRandomVariableDeclaration
/**
* Default constructor. Will default the arity of the random variable
* declaration to 0 and range to be of sort 'Boolean'.
*
* @param name
* a unique string valued symbol for the random variable
* declaration.
*/
public HOGMRandomVariableDeclaration(Expression name) {
this(name, Expressions.ZERO, HOGMSortDeclaration.IN_BUILT_BOOLEAN.getName());
}
示例7: ConstantDeclaration
/**
* Default constructor. Will default the arity of the constant
* declaration to 0 and range to be of sort 'Boolean'.
*
* @param name
* a unique string valued symbol for the constant declaration.
*/
public ConstantDeclaration(Expression name) {
this(name, Expressions.ZERO, HOGMSortDeclaration.IN_BUILT_BOOLEAN.getName());
}