use of com.sri.ai.expresso.core.DefaultExtensionalUniSet in project aic-expresso by aic-sri-international.
the class VariableComponent method chooseDepthImportantFirst.
public int chooseDepthImportantFirst() {
Expression min = parse("{ 1 }");
Integer jToReturn = 0;
for (int j = 0; j < this.children.size(); j++) {
if (!this.children.get(j).entirelyDiscover) {
Set<Expression> toMultiply = this.model.getNeighbors(this.children.get(j).phi);
toMultiply.removeAll(this.children.get(j).parent);
DefaultExtensionalUniSet varToMultiply = new DefaultExtensionalUniSet(new ArrayList<>(toMultiply));
IndexExpressionsSet indices = getIndexExpressionsOfFreeVariablesIn(varToMultiply, this.model.context);
// TODO Find a way to do : intersection (variablesToBeSummedOut, FreeVariables(phi))
Expression setOfFactorInstantiations = IntensionalSet.makeMultiSet(indices, // head
Bounds.normalizeSingleExpression(this.children.get(j).phi, this.model.theory, this.model.context), // No Condition
makeSymbol(true));
Expression firstProduct = apply(TIMES, setOfFactorInstantiations);
Expression evaluation = this.model.theory.evaluate(firstProduct, this.model.context);
DefaultExtensionalUniSet varToSum = new DefaultExtensionalUniSet(new ArrayList<>(this.children.get(j).parent));
indices = getIndexExpressionsOfFreeVariablesIn(varToSum, this.model.context);
setOfFactorInstantiations = IntensionalSet.makeMultiSet(indices, // head
evaluation, // No Condition
makeSymbol(true));
Expression sumOnPhi = apply(SUM, setOfFactorInstantiations);
evaluation = this.model.theory.evaluate(sumOnPhi, this.model.context);
if (evaluation.compareTo(min) < 0) {
min = evaluation;
jToReturn = j;
}
}
}
return jToReturn;
}
use of com.sri.ai.expresso.core.DefaultExtensionalUniSet in project aic-expresso by aic-sri-international.
the class VariableComponent method calculateBound.
public void calculateBound() {
Theory theory = this.model.theory;
Context context = this.model.context;
// Expression childrenBound = parse("{ 1 }");
// for (FactorComponent children : this.children) {
// childrenBound = Bounds.boundProduct(theory, context, childrenBound, children.bound);
// }
Bound[] childrenArray = new Bound[children.size()];
int i = 0;
for (FactorComponent children : this.children) {
childrenArray[i] = children.bound;
i++;
}
Bound childrenBound;
if (childrenArray.length != 0) {
childrenBound = Bounds.boundProduct(this.model.theory, this.model.context, isExtensionalBound, childrenArray);
} else {
childrenBound = Bounds.makeSingleElementBound(makeSymbol(1), isExtensionalBound);
}
Iterator<Expression> iteratorToVariables = this.cutsetInsideSubModel.iterator();
ArrayList<Expression> variablesToBeSummedOut = new ArrayList<>(this.cutsetInsideSubModel.size());
for (Expression var : Util.in(iteratorToVariables)) {
variablesToBeSummedOut.add(var);
}
// We want sum other toSum of Phi*childrenBound
DefaultExtensionalUniSet varToSum = new DefaultExtensionalUniSet(variablesToBeSummedOut);
bound = childrenBound.summingBound(varToSum, context, theory);
}
use of com.sri.ai.expresso.core.DefaultExtensionalUniSet in project aic-expresso by aic-sri-international.
the class DistinctExpressionsStepSolver method makeSolution.
/**
* @param distinctValuesList
* @return
*/
private Solution makeSolution(List<Expression> distinctValuesList) {
ArrayList<Expression> arrayList = new ArrayList<>(distinctValuesList);
DefaultExtensionalUniSet set = new DefaultExtensionalUniSet(arrayList);
Solution result = new Solution(set);
return result;
}
use of com.sri.ai.expresso.core.DefaultExtensionalUniSet in project aic-expresso by aic-sri-international.
the class Bounds method updateExtremes.
/**
* Eliminate factors not in Ext(C.Hull(B))
* @param B
* @return
*/
private static Expression updateExtremes(Expression B, Theory theory, Context context) {
List<Expression> listOfB = getElements(B);
ArrayList<Expression> elements = new ArrayList<>(listOfB.size());
int indexPhi = 0;
for (Expression phi : listOfB) {
if (isExtremePoint(phi, indexPhi, B, theory, context)) {
elements.add(phi);
}
indexPhi++;
}
DefaultExtensionalUniSet result = new DefaultExtensionalUniSet(elements);
return result;
}
use of com.sri.ai.expresso.core.DefaultExtensionalUniSet in project aic-expresso by aic-sri-international.
the class IntervalWithMeasureEquivalentToSingleVariableLinearRealArithmeticConstraintStepSolver method getSolutionExpressionForBoundVariable.
@Override
public Expression getSolutionExpressionForBoundVariable() {
Expression oneOfTheVariableValues = getFirst(getEquals());
DefaultExtensionalUniSet result = new DefaultExtensionalUniSet(oneOfTheVariableValues);
return result;
}
Aggregations