SymbolicExpr::VisitAction preVisit(const SymbolicExpr::Ptr &node) { if (!seen.insert(getRawPointer(node)).second) return SymbolicExpr::TRUNCATE; // already processed this subexpression if (SymbolicExpr::LeafPtr leaf = node->isLeafNode()) { if (leaf->isVariable()) { if (defns->find(leaf->nameId()) == defns->end()) { defns->insert(leaf->nameId()); yices_type bvtype = yices_mk_bitvector_type(self->context, leaf->nBits()); ASSERT_not_null(bvtype); std::string name = "v" + StringUtility::numberToString(leaf->nameId()); yices_var_decl vdecl __attribute__((unused)) = yices_mk_var_decl(self->context, name.c_str(), bvtype); ASSERT_not_null(vdecl); } } else if (leaf->isMemory()) { if (defns->find(leaf->nameId()) == defns->end()) { defns->insert(leaf->nameId()); yices_type domain = yices_mk_bitvector_type(self->context, leaf->domainWidth()); yices_type range = yices_mk_bitvector_type(self->context, leaf->nBits()); yices_type ftype = yices_mk_function_type(self->context, &domain, 1, range); ASSERT_not_null(ftype); std::string name = "m" + StringUtility::numberToString(leaf->nameId()); yices_var_decl vdecl __attribute__((unused)) = yices_mk_var_decl(self->context, name.c_str(), ftype); ASSERT_not_null(vdecl); } } } return SymbolicExpr::CONTINUE; }
void NBTrafficLightLogicCont::replaceRemoved(NBEdge* removed, int removedLane, NBEdge* by, int byLane) { Definitions definitions = getDefinitions(); for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) { (*it)->replaceRemoved(removed, removedLane, by, byLane); } }
void NBTrafficLightLogicCont::remapRemoved(NBEdge* removed, const EdgeVector& incoming, const EdgeVector& outgoing) { Definitions definitions = getDefinitions(); for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) { (*it)->remapRemoved(removed, incoming, outgoing); } }
SymbolicExpr::VisitAction preVisit(const SymbolicExpr::Ptr &node) { if (!seen.insert(getRawPointer(node)).second) return SymbolicExpr::TRUNCATE; // already processed this subexpression if (SymbolicExpr::LeafPtr leaf = node->isLeafNode()) { if (leaf->isVariable()) { if (defns->find(leaf->nameId())==defns->end()) { defns->insert(leaf->nameId()); o <<"\n"; if (!leaf->comment().empty()) o <<StringUtility::prefixLines(leaf->comment(), "; ") <<"\n"; o <<"(define v" <<leaf->nameId() <<"::" <<get_typename(leaf) <<")\n"; } } else if (leaf->isMemory()) { if (defns->find(leaf->nameId())==defns->end()) { defns->insert(leaf->nameId()); o <<"\n"; if (!leaf->comment().empty()) o <<StringUtility::prefixLines(leaf->comment(), "; ") <<"\n"; o <<"(define m" <<leaf->nameId() <<"::" <<get_typename(leaf) <<")\n"; } } } return SymbolicExpr::CONTINUE; }
void NBTrafficLightLogicCont::setTLControllingInformation(const NBEdgeCont& ec, const NBNodeCont& nc) { Definitions definitions = getDefinitions(); // set the information about all participants, first for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) { (*it)->setParticipantsInformation(); } // clear previous information because tlDefs may have been removed in NETEDIT ec.clearControllingTLInformation(); // insert the information about the tl-controlling for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) { (*it)->setTLControllingInformation(); } // handle rail signals which are not instantiated as normal definitions for (std::map<std::string, NBNode*>::const_iterator it = nc.begin(); it != nc.end(); it ++) { NBNode* n = it->second; if (n->getType() == NODETYPE_RAIL_SIGNAL || n->getType() == NODETYPE_RAIL_CROSSING) { NBOwnTLDef dummy(n->getID(), n, 0, TLTYPE_STATIC); dummy.setParticipantsInformation(); dummy.setTLControllingInformation(); n->removeTrafficLight(&dummy); } } }
void NBTrafficLightLogicCont::clear() { Definitions definitions = getDefinitions(); for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) { delete *it; } myDefinitions.clear(); Logics logics = getComputed(); for (Logics::iterator it = logics.begin(); it != logics.end(); it++) { delete *it; } myComputed.clear(); for (std::set<NBTrafficLightDefinition*>::iterator it = myExtracted.begin(); it != myExtracted.end(); it++) { delete *it; } myExtracted.clear(); }
std::pair<unsigned int, unsigned int> NBTrafficLightLogicCont::computeLogics(OptionsCont& oc) { // clean previous logics Logics logics = getComputed(); for (Logics::iterator it = logics.begin(); it != logics.end(); it++) { delete *it; } myComputed.clear(); unsigned int numPrograms = 0; Definitions definitions = getDefinitions(); for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) { if (computeSingleLogic(oc, *it)) { numPrograms++; } } return std::pair<unsigned int, unsigned int>((unsigned int)myComputed.size(), numPrograms); }