void StoragesAssigner::getAvailableStoreAssignments(Element* element, std::map<Store*, std::vector<Store*> >& STsOnStore, std::map<Store*, Assignment* >& stAssignment, Assignment* assignment) { Stores::iterator storesIt = network->getStores().begin(); Stores::iterator storesItEnd = network->getStores().end(); for ( ; storesIt != storesItEnd; ++storesIt ) { if ( (*storesIt)->getTypeOfStore() == static_cast<Store*>(element)->getTypeOfStore() ) { // inserting only vms with capacity less then the element's one STsOnStore[*storesIt] = std::vector<Store *>(); // going through all other assigned requests RequestAssignment::iterator it = requestAssignment.begin(); RequestAssignment::iterator itEnd = requestAssignment.end(); for ( ; it != itEnd; ++it ) { Stores storages = it->second->GetAssigned(*storesIt); Stores::iterator stIt = storages.begin(); Stores::iterator stItEnd = storages.end(); for ( ; stIt != stItEnd; ++stIt ) { STsOnStore[*storesIt].push_back(*stIt); stAssignment[*stIt] = it->second; } } } } }
Stores NetworkManager::getStoreCandidates() { Stores result; while( !depthSearcher->isExhausted() ) { Elements elements = depthSearcher->getElementCandidates(); cerr << "[NM]\tDepth search returned " << elements.size() << endl; for ( Elements::iterator i = elements.begin(); i != elements.end(); i++ ) { Element * element = *i; if ( ! element->isStore() ) continue; Store * store = (Store *) element; if ( rejectedStores.find(store) != rejectedStores.end() ) continue; result.insert(store); } depthSearcher->increaseSearchSpace(); if ( !result.empty() ) break; } rejectedStores.insert(result.begin(), result.end()); cerr << "[NM]\tPrepared " << result.size() << " candidates" << endl; return result; }
// files holds the transactions for every store // findBook returns a vector with an entry for each store that sold the given book vector<matches> findBook(const Stores &files, const string &book) { vector<matches> ret; // initially empty // for each store find the range of matching books, if any for (Stores::const_iterator it = files.begin(); it != files.end(); ++it) { // find the range of Sales_data that have the same ISBN pair<vector<Sales_data>::const_iterator, vector<Sales_data>::const_iterator> found = equal_range(it->begin(), it->end(), book, compareIsbn); if (found.first != found.second) // this store had sales // remember the index of this store and the matching range ret.push_back(make_tuple(it - files.begin(), found.first, found.second)); } return ret; // empty if no matches found }