本文整理汇总了Java中com.sri.ai.util.Util.thereExists方法的典型用法代码示例。如果您正苦于以下问题:Java Util.thereExists方法的具体用法?Java Util.thereExists怎么用?Java Util.thereExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sri.ai.util.Util
的用法示例。
在下文中一共展示了Util.thereExists方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refineOrNull
import com.sri.ai.util.Util; //导入方法依赖的package包/类
@Override
protected T refineOrNull() {
T result = null;
if ( ! firstComputationDone) { // first computed value
result = computeFunction();
firstComputationDone = true;
}
else { // incremental computation
boolean hasMoreRefinedValue;
if ( ! (hasMoreRefinedValue = Util.thereExists(arguments, new HasMoreRefinedValueSinceLastTimeAtNoCost()))) {
hasMoreRefinedValue = tryToRefineSomeArgumentAccordingToRanking();
}
if (hasMoreRefinedValue) {
result = computeFunction();
}
}
return result;
}
示例2: simplify
import com.sri.ai.util.Util; //导入方法依赖的package包/类
public static Expression simplify(Expression expression, Context context) {
Expression result = expression;
if (expression.hasFunctor(FunctorConstants.INTERSECTION)) {
if (Util.thereExists(expression.getArguments(), Sets::isEmptySet)) {
result = Sets.EMPTY_SET;
}
}
return result;
}
示例3: runModelCountingTestForSingleVariableConstraint
import com.sri.ai.util.Util; //导入方法依赖的package包/类
private static void runModelCountingTestForSingleVariableConstraint(
Expression variable,
Collection<Expression> literals,
Constraint constraint,
boolean testAgainstBruteForce,
Theory theory,
Context context) {
Expression literalsConjunction = And.make(literals);
String problemDescription = "model counting of " + literalsConjunction + " for variable " + variable;
output("Problem: " + problemDescription);
Simplifier symbolicSolver = (e, p) -> computeModelCountBySolver((SingleVariableConstraint) e, p);
SingleVariableConstraint singleVariableConstraint = (SingleVariableConstraint) constraint;
Expression symbolicSolution = symbolicSolver.apply(singleVariableConstraint, context);
if (Util.thereExists(new SubExpressionsDepthFirstIterator(symbolicSolution), e -> e instanceof QuantifiedExpression || Sets.isIntensionalSet(e))) {
throw new Error("Symbolic solution is not quantifier-free: " + symbolicSolution);
}
output("Symbolic result: " + symbolicSolution);
if (testAgainstBruteForce) {
if (singleVariableConstraint.isContradiction()) {
if (!symbolicSolution.equals(ZERO)) {
throw new Error("Constraint is contradiction, but symbolic solver does not produce 0, but instead " + symbolicSolution);
}
}
else {
Expression testingVariable = singleVariableConstraint.getVariable();
Set<Expression> allVariables = getVariablesBeingReferenced(singleVariableConstraint, context);
Collection<Expression> otherVariables = removeFromSetNonDestructively(allVariables, v -> v.equals(testingVariable));
BinaryFunction<BruteForceCommonInterpreter, Context, Expression> fromInterpreterAndContextWithAssignmentToOtherVariablesToBruteForceSolution =
(interpreter, contextWithAssignmentToOtherVariables)
-> bruteForceModelCounterForVariableGivenInterpreterAndAssignmentToOtherVariables(
variable, literalsConjunction, interpreter, theory, contextWithAssignmentToOtherVariables);
testSymbolicVsBruteForceComputationForEachAssignment(theory, problemDescription, otherVariables, symbolicSolution, fromInterpreterAndContextWithAssignmentToOtherVariablesToBruteForceSolution, context);
}
}
else {
output("Skipping test againt brute-force.");
}
}
示例4: runGroupProblemSolvingTestGivenConstraintAndProblem
import com.sri.ai.util.Util; //导入方法依赖的package包/类
/**
* @param problem
* @param indices
* @param constraint
* @param body
* @param testAgainstBruteForce
* @param theoryTestingSupport
* @param context
* @throws Error
*/
public static void runGroupProblemSolvingTestGivenConstraintAndProblem(Expression problem, Collection<Expression> indices, Constraint constraint, Expression body, boolean testAgainstBruteForce, TheoryTestingSupport theoryTestingSupport, Context context) throws Error {
Theory theory = theoryTestingSupport.getTheory();
Collection<Expression> freeVariables = getFreeVariableMinusIndices(indices, constraint, body, context);
String problemDescription = problem.toString();
output(problemDescription);
Simplifier symbolicInterpreter = (e, c) -> theory.evaluate(e,c);
long start = System.currentTimeMillis();
Expression symbolicSolution = symbolicInterpreter.apply(problem, context);
long time = System.currentTimeMillis() - start;
output("Symbolic solution: " + symbolicSolution);
output("Computed in " + time + " ms");
if (Util.thereExists(new SubExpressionsDepthFirstIterator(symbolicSolution), e -> e instanceof QuantifiedExpression || Sets.isIntensionalSet(e))) {
throw new Error("Symbolic solution is not quantifier-free: " + symbolicSolution);
}
if (testAgainstBruteForce) {
BinaryFunction<BruteForceCommonInterpreter, Context, Expression>
bruteForceSolutionGivenInterpreterAndContextWithAssignmentToOtherVariables = (i, c) -> i.apply(problem, c);
testSymbolicVsBruteForceComputationForEachAssignment(
theory,
problemDescription,
freeVariables,
symbolicSolution,
bruteForceSolutionGivenInterpreterAndContextWithAssignmentToOtherVariables,
context);
// A more elegant approach would be to create a "for all free variables : symbolic = problem" expression
// and solve it by brute force instead of using testSymbolicVsBruteForceComputation
// which replicates the brute force interpreter to some extent.
// The reason we do not do this is simply due to the fact that the brute force interpreter would return "false"
// in case of failure, without indicating which assignment failed, which is very useful for debugging.
// If interpreters, and in fact the whole framework, provided proofs of its calculations,
// then we could simply use the more elegant approach.
}
else {
output("Skipping test againt brute-force.");
}
}
示例5: containsF
import com.sri.ai.util.Util; //导入方法依赖的package包/类
private static boolean containsF(Expression e, Predicate<Expression> isF) {
boolean result = Util.thereExists(new SubExpressionsDepthFirstIterator(e), isF);
return result;
}
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:5,代码来源:SetOfArgumentTuplesForFunctionOccurringInExpression.java
示例6: apply
import com.sri.ai.util.Util; //导入方法依赖的package包/类
@Override
public boolean apply(Expression possibleIndex) {
List<Expression> indexExpressionsList = ((ExtensionalIndexExpressionsSet) indexExpressions).getList();
boolean result = Util.thereExists(indexExpressionsList, new HasIndex(possibleIndex));
return result;
}
示例7: apply
import com.sri.ai.util.Util; //导入方法依赖的package包/类
@Override
public boolean apply(Expression expression) {
return Util.thereExists(expression.getArguments(), equals);
}
示例8: apply
import com.sri.ai.util.Util; //导入方法依赖的package包/类
@Override
public boolean apply(Expression input) {
boolean result = Util.thereExists(input.getArguments(), base);
return result;
}
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:6,代码来源:FunctionApplicationContainsArgumentSatisfying.java
示例9: isSubExpressionOf
import com.sri.ai.util.Util; //导入方法依赖的package包/类
public static boolean isSubExpressionOf(Expression searched, Expression expression) {
boolean result = Util.thereExists(new SubExpressionsDepthFirstIterator(expression), new Equals<Expression>(searched));
return result;
}
示例10: containsAnyOfGivenCollectionAsSubExpression
import com.sri.ai.util.Util; //导入方法依赖的package包/类
/**
* Indicates whether any of <code>expressions</code> is a sub-expression of <code>expression</code>.
*/
public static boolean containsAnyOfGivenCollectionAsSubExpression(Expression expression, Collection<Expression> expressions) {
return Util.thereExists(expressions, new IsSubExpressionOf(expression));
}