Search in sources :

Example 1 with StackedHashMap

use of com.sri.ai.util.collect.StackedHashMap in project aic-expresso by aic-sri-international.

the class AbstractIterativeMultiIndexQuantifierElimination method extendAssignments.

/**
	 * Sets the value assignment to a given expression in the binding mechanism stored in the context.
	 * @param newAssignment
	 * @param context
	 * @return
	 */
public static Context extendAssignments(Map<Expression, Expression> newAssignments, Context context) {
    @SuppressWarnings("unchecked") Map<Expression, Expression> assignments = (Map<Expression, Expression>) context.getGlobalObject(ASSIGNMENTS_GLOBAL_OBJECTS_KEY);
    Map<Expression, Expression> extendedAssignments;
    if (assignments == null) {
        extendedAssignments = newAssignments;
    } else {
        extendedAssignments = new StackedHashMap<>(newAssignments, assignments);
    }
    Context result = context.putGlobalObject(ASSIGNMENTS_GLOBAL_OBJECTS_KEY, extendedAssignments);
    return result;
}
Also used : Context(com.sri.ai.grinder.sgdpllt.api.Context) Expression(com.sri.ai.expresso.api.Expression) StackedHashMap(com.sri.ai.util.collect.StackedHashMap) Map(java.util.Map)

Example 2 with StackedHashMap

use of com.sri.ai.util.collect.StackedHashMap in project aic-expresso by aic-sri-international.

the class Assignment method extendAssignments.

/**
 * Sets the value assignment to a given expression in the binding mechanism stored in the context.
 * @param newAssignment
 * @param context
 * @return
 */
public static Context extendAssignments(Map<Expression, Expression> newAssignments, Context context) {
    @SuppressWarnings("unchecked") Map<Expression, Expression> assignments = (Map<Expression, Expression>) context.getGlobalObject(ContextAssignmentLookup.ASSIGNMENTS_GLOBAL_OBJECTS_KEY);
    Map<Expression, Expression> extendedAssignments;
    if (assignments == null) {
        extendedAssignments = newAssignments;
    } else {
        extendedAssignments = new StackedHashMap<>(newAssignments, assignments);
    }
    Context result = ContextAssignmentLookup.setAssignments(context, extendedAssignments);
    return result;
}
Also used : Context(com.sri.ai.grinder.api.Context) Expression(com.sri.ai.expresso.api.Expression) StackedHashMap(com.sri.ai.util.collect.StackedHashMap) Map(java.util.Map)

Aggregations

Expression (com.sri.ai.expresso.api.Expression)2 StackedHashMap (com.sri.ai.util.collect.StackedHashMap)2 Map (java.util.Map)2 Context (com.sri.ai.grinder.api.Context)1 Context (com.sri.ai.grinder.sgdpllt.api.Context)1