当前位置: 首页>>代码示例>>Java>>正文


Java Expressions.ZERO属性代码示例

本文整理汇总了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; 
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:19,代码来源:HOGModelVisitor.java

示例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; 
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:19,代码来源:HOGModelVisitor.java

示例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;
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:47,代码来源:HOGMRandomVariableDeclaration.java

示例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;
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:47,代码来源:ConstantDeclaration.java

示例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;
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:40,代码来源:PRAiSESolver.java

示例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());
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:11,代码来源:HOGMRandomVariableDeclaration.java

示例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());
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:10,代码来源:ConstantDeclaration.java


注:本文中的com.sri.ai.expresso.helper.Expressions.ZERO属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。