use of com.google.api.expr.v1alpha1.Expr in project batfish by batfish.
the class TransferResult method mergeChangedVariables.
// TODO: this really needs to use persistent set data types
public PList<Pair<String, Pair<Expr, Expr>>> mergeChangedVariables(TransferResult<U, T> other) {
Set<String> seen = new HashSet<>();
PList<Pair<String, Pair<Expr, Expr>>> vars = PList.empty();
for (Pair<String, Expr> cv1 : this._changedVariables) {
String s = cv1.getFirst();
Expr x = cv1.getSecond();
if (!seen.contains(s)) {
seen.add(s);
Expr e = find(other._changedVariables, s);
Pair<Expr, Expr> pair = new Pair<>(x, e);
vars = vars.plus(new Pair<>(s, pair));
}
}
for (Pair<String, Expr> cv1 : other._changedVariables) {
String s = cv1.getFirst();
Expr x = cv1.getSecond();
if (!seen.contains(s)) {
seen.add(s);
Expr e = find(this._changedVariables, s);
// preserve order
Pair<Expr, Expr> pair = new Pair<>(e, x);
vars = vars.plus(new Pair<>(s, pair));
}
}
return vars;
}
use of com.google.api.expr.v1alpha1.Expr in project batfish by batfish.
the class Z3ContextJob method computeSmtConstraintsViaNod.
protected BoolExpr computeSmtConstraintsViaNod(NodProgram program, boolean negate) {
Fixedpoint fix = mkFixedpoint(program, true);
Expr answer = answerFixedPoint(fix, program);
return getSolverInput(answer, program, negate);
}
use of com.google.api.expr.v1alpha1.Expr in project bmoth by hhu-stups.
the class StateTest method testGetStateConstraint.
@Test
public void testGetStateConstraint() {
HashMap<String, Expr> map1 = new HashMap<>();
map1.put("x", z3Context.mkInt(11));
map1.put("y", z3Context.mkInt(12));
State state1 = new State(map1);
State state2 = new State(new HashMap<>());
assertEquals("(and (= x 11) (= y 12))", state1.getStateConstraint(z3Context).toString());
assertNull(state2.getStateConstraint(z3Context));
}
use of com.google.api.expr.v1alpha1.Expr in project bmoth by hhu-stups.
the class StateTest method testToString.
@Test
public void testToString() throws Exception {
HashMap<String, Expr> map = new HashMap<>();
map.put("z", z3Context.mkInt(13));
map.put("x", z3Context.mkInt(11));
map.put("y", z3Context.mkInt(12));
map.put("a", z3Context.mkInt(-200));
State state = new State(map);
assertEquals("{a=-200, x=11, y=12, z=13}", state.toString());
}
use of com.google.api.expr.v1alpha1.Expr in project bmoth by hhu-stups.
the class StateTest method testStateEquals.
@Test
public void testStateEquals() throws Exception {
HashMap<String, Expr> map1 = new HashMap<>();
HashMap<String, Expr> map2 = new HashMap<>();
map1.put("x", z3Context.mkInt(11));
map2.put("x", z3Context.mkInt(11));
State state1 = new State(map1);
State state2 = new State(map2);
assertEquals(state1, state2);
assertEquals(state1.hashCode(), state2.hashCode());
}
Aggregations