use of org.batfish.symbolic.answers.SmtOneAnswerElement in project batfish by batfish.
the class PropertyChecker method checkLoadBalancing.
/*
* Computes whether load balancing for each source node in a collection is
* within some threshold k of the each other.
*/
public AnswerElement checkLoadBalancing(HeaderLocationQuestion q, int k) {
return checkProperty(q, (enc, srcRouters, destPorts) -> {
PropertyAdder pa = new PropertyAdder(enc.getMainSlice());
Map<String, ArithExpr> loads = pa.instrumentLoad(destPorts);
Map<String, BoolExpr> prop = new HashMap<>();
// TODO: implement this properly after refactoring
loads.forEach((name, ae) -> prop.put(name, enc.mkTrue()));
return prop;
}, (vp) -> new SmtOneAnswerElement(vp.getResult()));
}
use of org.batfish.symbolic.answers.SmtOneAnswerElement in project batfish by batfish.
the class PropertyChecker method checkEqualLength.
/*
* Computes whether a collection of source routers will always have
* equal path length to destination port(s).
*/
public AnswerElement checkEqualLength(HeaderLocationQuestion q) {
return checkProperty(q, (enc, srcRouters, destPorts) -> {
PropertyAdder pa = new PropertyAdder(enc.getMainSlice());
Map<String, ArithExpr> lenVars = pa.instrumentPathLength(destPorts);
Map<String, BoolExpr> eqVars = new HashMap<>();
List<Expr> lens = new ArrayList<>();
for (String router : srcRouters) {
lens.add(lenVars.get(router));
}
BoolExpr allEqual = PropertyAdder.allEqual(enc.getCtx(), lens);
enc.add(enc.mkNot(allEqual));
for (Entry<String, ArithExpr> entry : lenVars.entrySet()) {
String name = entry.getKey();
BoolExpr b = srcRouters.contains(name) ? allEqual : enc.mkTrue();
eqVars.put(name, b);
}
return eqVars;
}, (vp) -> new SmtOneAnswerElement(vp.getResult()));
}
Aggregations