Search in sources :

Example 11 with DefaultExtensionalUniSet

use of com.sri.ai.expresso.core.DefaultExtensionalUniSet in project aic-expresso by aic-sri-international.

the class DefaultExtensionalBound method summingBound.

public DefaultExtensionalBound summingBound(ArrayList<Expression> variablesToBeSummedOut, Context context, Theory theory) {
    Expression varsSet = new DefaultExtensionalUniSet(variablesToBeSummedOut);
    DefaultExtensionalBound result = summingBound(varsSet, context, theory);
    return result;
}
Also used : Expression(com.sri.ai.expresso.api.Expression) DefaultExtensionalUniSet(com.sri.ai.expresso.core.DefaultExtensionalUniSet)

Example 12 with DefaultExtensionalUniSet

use of com.sri.ai.expresso.core.DefaultExtensionalUniSet in project aic-expresso by aic-sri-international.

the class Expressions method makeDefaultExtensionalUniSetFromLabelAndSubTrees.

private static Expression makeDefaultExtensionalUniSetFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
    if (subTreeObjects.length == 1 && subTreeObjects[0] instanceof Collection) {
        subTreeObjects = ((Collection) subTreeObjects[0]).toArray();
    }
    ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
    if (subTreeExpressions.size() == 1) {
        subTreeExpressions = new ArrayList<Expression>(Expressions.ensureListFromKleeneList(subTreeExpressions.get(0)));
    }
    Expression result = new DefaultExtensionalUniSet(subTreeExpressions);
    return result;
}
Also used : DefaultLambdaExpression(com.sri.ai.expresso.core.DefaultLambdaExpression) Expression(com.sri.ai.expresso.api.Expression) LambdaExpression(com.sri.ai.expresso.api.LambdaExpression) Collection(java.util.Collection) IndexExpressions(com.sri.ai.grinder.library.indexexpression.IndexExpressions) DefaultExtensionalUniSet(com.sri.ai.expresso.core.DefaultExtensionalUniSet)

Example 13 with DefaultExtensionalUniSet

use of com.sri.ai.expresso.core.DefaultExtensionalUniSet in project aic-expresso by aic-sri-international.

the class FactorComponent method calculateBound.

public void calculateBound() {
    Theory theory = this.model.theory;
    Context context = this.model.context;
    // Expression childrenBound = parse("{1}");
    // for (VariableComponent children : this.children) {
    // childrenBound = Bounds.boundProduct(this.model.theory, this.model.context, childrenBound, children.bound);
    // }
    Bound[] cildrenArray = new Bound[children.size()];
    int i = 0;
    for (VariableComponent children : this.children) {
        cildrenArray[i] = children.bound;
        i++;
    }
    Bound childrenBound = Bounds.boundProduct(this.model.theory, this.model.context, isExtensionalBound, cildrenArray);
    Set<Expression> toSum = model.getNeighbors(phi);
    for (Expression e : this.parent) {
        toSum.remove(e);
    }
    for (Expression e : this.cutsetOutsideSubModel) {
        toSum.remove(e);
    }
    toSum.addAll(this.cutsetInsideSubModel);
    ArrayList<Expression> variablesToBeSummedOut = new ArrayList<>(toSum.size());
    variablesToBeSummedOut.addAll(toSum);
    // We want sum other toSum of Phi*childrenBound
    DefaultExtensionalUniSet varToSum = new DefaultExtensionalUniSet(variablesToBeSummedOut);
    bound = childrenBound.summingPhiTimesBound(varToSum, phi, context, theory);
}
Also used : Context(com.sri.ai.grinder.api.Context) Theory(com.sri.ai.grinder.api.Theory) Expression(com.sri.ai.expresso.api.Expression) Bound(com.sri.ai.grinder.library.bounds.Bound) ArrayList(java.util.ArrayList) DefaultExtensionalUniSet(com.sri.ai.expresso.core.DefaultExtensionalUniSet)

Aggregations

Expression (com.sri.ai.expresso.api.Expression)13 DefaultExtensionalUniSet (com.sri.ai.expresso.core.DefaultExtensionalUniSet)13 ArrayList (java.util.ArrayList)8 Util.mapIntoArrayList (com.sri.ai.util.Util.mapIntoArrayList)4 Context (com.sri.ai.grinder.api.Context)2 Theory (com.sri.ai.grinder.api.Theory)2 Bound (com.sri.ai.grinder.library.bounds.Bound)2 ExtensionalSet (com.sri.ai.expresso.api.ExtensionalSet)1 IndexExpressionsSet (com.sri.ai.expresso.api.IndexExpressionsSet)1 LambdaExpression (com.sri.ai.expresso.api.LambdaExpression)1 DefaultLambdaExpression (com.sri.ai.expresso.core.DefaultLambdaExpression)1 ExtensionalIndexExpressionsSet (com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet)1 IndexExpressions (com.sri.ai.grinder.library.indexexpression.IndexExpressions)1 NullaryFunction (com.sri.ai.util.base.NullaryFunction)1 CartesianProductIterator (com.sri.ai.util.collect.CartesianProductIterator)1 Collection (java.util.Collection)1