當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。