def addSentencesTrueByRulesDifferentially(cls, sentencesByForm, domainModel, reasoner): """ generated source for method addSentencesTrueByRulesDifferentially """ model = domainModel constantForms = model.getConstantSentenceForms() # Find the part of the dependency graph dealing only with the constant forms. dependencySubgraph = Multimaps.filterKeys(model.getDependencyGraph(), Predicates.in_(constantForms)) dependencySubgraph = Multimaps.filterValues(model.getDependencyGraph(), Predicates.in_(constantForms)) dependencySubgraph = ImmutableMultimap.copyOf(dependencySubgraph) ordering = DependencyGraphs.toposortSafe(constantForms, dependencySubgraph) for stratum in ordering: # One non-differential pass, collecting the changes for form in stratum: for rule in model.getRules(form): if not reasoner.isSubsetOf(sentencesByForm, ruleResults): sentencesByForm = reasoner.getUnion(sentencesByForm, ruleResults) newlyTrueSentences = reasoner.getUnion(newlyTrueSentences, ruleResults) # Now a lot of differential passes to deal with recursion efficiently while somethingChanged: somethingChanged = False for form in stratum: for rule in model.getRules(form): if not reasoner.isSubsetOf(sentencesByForm, ruleResults): somethingChanged = True newStuffInThisPass = reasoner.getUnion(newStuffInThisPass, ruleResults) sentencesByForm = reasoner.getUnion(sentencesByForm, newStuffInThisPass) newlyTrueSentences = newStuffInThisPass
def discover(self): vms = [] options = PaginationOptions.Builder.queryParameters(ImmutableMultimap.of("all_tenants", "1")) serverApi = self.api.getServerApi(self.regionName) for server in serverApi.listInDetail(options): logger.debug("serverApi.listInDetail().concat():", server) vm = self.buildVm(server) vm and vms.append(vm) return vms
def discover(self): vms = [] options = PaginationOptions.Builder.queryParameters( ImmutableMultimap.of("all_tenants", "1")) serverApi = self.api.getServerApi(self.regionName) for server in serverApi.listInDetail(options): logger.debug("serverApi.listInDetail().concat():", server) vm = self.buildVm(server) vm and vms.append(vm) return vms
def create(cls, model): """ generated source for method create """ constantsBuilder = ImmutableMultimap.builder() for form in model.getSentenceForms(): constantsBuilder.putAll(form, model.getSentencesListedAsTrue(form)) return GdlChainingReasoner(model, constantsBuilder.build())