use of com.google.api.services.cloudresourcemanager.v3.model in project batfish by batfish.
the class PropertyChecker method checkDeterminism.
/*
* Check if there exist multiple stable solutions to the network.
* If so, reports the forwarding differences between the two cases.
*/
public AnswerElement checkDeterminism(HeaderQuestion q) {
Graph graph = new Graph(_batfish);
Encoder enc1 = new Encoder(_settings, graph, q);
Encoder enc2 = new Encoder(enc1, graph, q);
enc1.computeEncoding();
enc2.computeEncoding();
addEnvironmentConstraints(enc1, q.getBaseEnvironmentType());
BoolExpr relatedFailures = relateFailures(enc1, enc2);
BoolExpr relatedEnvs = relateEnvironments(enc1, enc2);
BoolExpr relatedPkts = relatePackets(enc1, enc2);
BoolExpr related = enc1.mkAnd(relatedFailures, relatedEnvs, relatedPkts);
BoolExpr required = enc1.mkTrue();
for (GraphEdge ge : graph.getAllRealEdges()) {
SymbolicDecisions d1 = enc1.getMainSlice().getSymbolicDecisions();
SymbolicDecisions d2 = enc2.getMainSlice().getSymbolicDecisions();
BoolExpr dataFwd1 = d1.getDataForwarding().get(ge.getRouter(), ge);
BoolExpr dataFwd2 = d2.getDataForwarding().get(ge.getRouter(), ge);
assert dataFwd1 != null;
assert dataFwd2 != null;
required = enc1.mkAnd(required, enc1.mkEq(dataFwd1, dataFwd2));
}
enc1.add(related);
enc1.add(enc1.mkNot(required));
Tuple<VerificationResult, Model> tup = enc1.verify();
VerificationResult res = tup.getFirst();
Model model = tup.getSecond();
SortedSet<String> case1 = null;
SortedSet<String> case2 = null;
Flow flow = null;
CounterExample ce = new CounterExample(model);
if (!res.isVerified()) {
case1 = new TreeSet<>();
case2 = new TreeSet<>();
flow = ce.buildFlow(enc1.getMainSlice().getSymbolicPacket(), "(none)");
for (GraphEdge ge : graph.getAllRealEdges()) {
SymbolicDecisions d1 = enc1.getMainSlice().getSymbolicDecisions();
SymbolicDecisions d2 = enc2.getMainSlice().getSymbolicDecisions();
BoolExpr dataFwd1 = d1.getDataForwarding().get(ge.getRouter(), ge);
BoolExpr dataFwd2 = d2.getDataForwarding().get(ge.getRouter(), ge);
assert dataFwd1 != null;
assert dataFwd2 != null;
boolean b1 = ce.boolVal(dataFwd1);
boolean b2 = ce.boolVal(dataFwd2);
if (b1 != b2) {
if (b1) {
String route = ce.buildRoute(enc1.getMainSlice(), ge);
String msg = ge + " -- " + route;
case1.add(msg);
}
if (b2) {
String route = ce.buildRoute(enc2.getMainSlice(), ge);
String msg = ge + " -- " + route;
case2.add(msg);
}
}
}
}
// Ensure canonical order
boolean less = (case1 == null || (case1.first().compareTo(case2.first()) < 0));
if (less) {
return new SmtDeterminismAnswerElement(flow, case1, case2);
} else {
return new SmtDeterminismAnswerElement(flow, case2, case1);
}
}
use of com.google.api.services.cloudresourcemanager.v3.model in project xtext-core by eclipse.
the class Bug305397Test method testBug.
@Test
public void testBug() throws Exception {
with(new Bug305397StandaloneSetup());
Model model = (Model) getModel(" a element \n element X end\n element Y end \nend");
Element outer = model.getElements().get(0);
Element firstInner = outer.getElements().get(0);
ICompositeNode outerNode = NodeModelUtils.getNode(outer);
assertEquals(3, outerNode.getOffset());
ICompositeNode firstInnerNode = NodeModelUtils.getNode(firstInner);
assertEquals(17, firstInnerNode.getOffset());
}
use of com.google.api.services.cloudresourcemanager.v3.model in project xtext-core by eclipse.
the class Bug311337TestLanguageSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == Bug311337Package.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case Bug311337Package.CHILD:
sequence_Child(context, (Child) semanticObject);
return;
case Bug311337Package.DEFINITION:
sequence_Definition(context, (Definition) semanticObject);
return;
case Bug311337Package.MODEL:
sequence_Model(context, (Model) semanticObject);
return;
case Bug311337Package.NESTED_REF:
sequence_Reference(context, (NestedRef) semanticObject);
return;
case Bug311337Package.REFERENCE:
sequence_Reference(context, (Reference) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of com.google.api.services.cloudresourcemanager.v3.model in project xtext-core by eclipse.
the class Bug302128TestLanguageSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == Bug302128Package.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case Bug302128Package.ELEMENT:
sequence_Element(context, (Element) semanticObject);
return;
case Bug302128Package.MODEL:
sequence_Model(context, (Model) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of com.google.api.services.cloudresourcemanager.v3.model in project xtext-core by eclipse.
the class Bug362902SemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == Bug362902Package.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case Bug362902Package.GREETING:
sequence_Greeting(context, (Greeting) semanticObject);
return;
case Bug362902Package.MODEL:
sequence_Model(context, (Model) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Aggregations