use of org.batfish.symbolic.answers.SmtReachabilityAnswerElement in project batfish by batfish.
the class PropertyChecker method checkReachability.
/*
* Check if a collection of routers will be reachable to
* one or more destinations.
*/
public AnswerElement checkReachability(HeaderLocationQuestion q) {
return checkProperty(q, (enc, srcRouters, destPorts) -> {
PropertyAdder pa = new PropertyAdder(enc.getMainSlice());
return pa.instrumentReachability(destPorts);
}, (vp) -> {
if (vp.getResult().isVerified()) {
return new SmtReachabilityAnswerElement(vp.getResult(), new FlowHistory());
} else {
FlowHistory fh;
CounterExample ce = new CounterExample(vp.getModel());
String testrigName = _batfish.getTestrigName();
if (q.getDiffType() != null) {
fh = ce.buildFlowHistoryDiff(testrigName, vp.getSrcRouters(), vp.getEnc(), vp.getEncDiff(), vp.getProp(), vp.getPropDiff());
} else {
Map<String, Boolean> reachVals = vp.getProp().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> ce.isTrue(entry.getValue()) ^ q.getNegate()));
fh = ce.buildFlowHistory(testrigName, vp.getSrcRouters(), vp.getEnc(), reachVals);
}
return new SmtReachabilityAnswerElement(vp.getResult(), fh);
}
});
}
Aggregations