void runRing(backend_t backend, unsigned ncount, unsigned delay) { /* Make sure we go around the ring at least a couple of times */ const unsigned duration = ncount * 5 / 2; nemo::Configuration conf = configuration(false, 1024); setBackend(backend, conf); boost::scoped_ptr<nemo::Network> net(createRing(ncount, 0, false, 1, delay)); boost::scoped_ptr<nemo::Simulation> sim(nemo::simulation(*net, conf)); /* Stimulate a single neuron to get the ring going */ sim->step(std::vector<unsigned>(1, 0)); for(unsigned ms=1; ms < duration; ++ms) { const std::vector<unsigned>& fired = sim->step(); if(delay == 1) { BOOST_CHECK_EQUAL(fired.size(), 1U); BOOST_REQUIRE_EQUAL(fired.front(), ms % ncount); } else if(ms % delay == 0) { BOOST_CHECK_EQUAL(fired.size(), 1U); BOOST_REQUIRE_EQUAL(fired.front(), (ms / delay) % ncount); } else { BOOST_CHECK_EQUAL(fired.size(), 0U); } } }
void testFiringStimulus(backend_t backend) { unsigned ncount = 3000; // make sure to cross partition boundaries unsigned cycles = 1000; unsigned firing = 10; // every cycle double p_fire = double(firing) / double(ncount); nemo::Network net; for(unsigned nidx = 0; nidx < ncount; ++nidx) { addExcitatoryNeuron(nidx, net); } nemo::Configuration conf; setBackend(backend, conf); boost::scoped_ptr<nemo::Simulation> sim(nemo::simulation(net, conf)); rng_t rng; urng_t random(rng, boost::uniform_real<double>(0, 1)); for(unsigned t = 0; t < cycles; ++t) { std::vector<unsigned> fstim; for(unsigned n = 0; n < ncount; ++n) { if(random() < p_fire) { fstim.push_back(n); } } const std::vector<unsigned>& fired = sim->step(fstim); /* The neurons which just fired should be exactly the ones we just stimulated */ sortAndCompare(fstim, fired); } }
QString SSProfile::getBackend(bool relativePath) { if (!isBackendMatchType()) { setBackend(relativePath); } return backend; }
/* Make sure that calling applyStdp gives an error */ void testInvalidStdpUsage(backend_t backend) { boost::scoped_ptr<nemo::Network> net(createRing(10, 0, true)); nemo::Configuration conf; setBackend(backend, conf); BOOST_REQUIRE_THROW(simpleStdpRun(*net, conf), nemo::exception); }
void AdvancedPageWidget::setupDialog() { KService::List services = CoreBackendManager::self()->list(); foreach(KService::Ptr p, services) comboBackend().addItem(p->name()); setBackend(Config::backend()); }
CContactModel::CContactModel(CTelegramCore *backend, QObject *parent) : CPeerModel(parent) { setBackend(backend); connect(m_backend, SIGNAL(contactProfileChanged(quint32)), SLOT(onContactProfileChanged(quint32))); connect(m_backend, SIGNAL(contactStatusChanged(quint32,TelegramNamespace::ContactStatus)), SLOT(onContactStatusChanged(quint32))); }
void Backend::parse(std::string path) { auto scadModules = SCAD::load(path); for (auto &module : scadModules) { auto mod = new Module; *mod = module; mod->setBackend(this); modules[module.getName()] = mod; } }
ContactsSource::ContactsSource(QObject* parent, const QVariantList& args) : FunambolSyncSource(parent, args), d(new ContactsSource::Private) { setSourceUID("contacts-test-stub-plugin"); setSyncMimeType("application/base64"); // test setRemoteURI("http://localhost/", Base64); // Is this needed? ContactsBackend *backend = new ContactsBackend("contacts-test-stub-plugin", dynamic_cast<Funambol::AbstractSyncSourceConfig *>(getConfig())); setBackend(backend); }
nemo::Configuration configuration(backend_t backend) { nemo::Configuration conf; std::vector<float> pre(20); std::vector<float> post(20); for(unsigned i = 0; i < 20; ++i) { int dt = i; pre.at(i) = dwPre(-dt); post.at(i) = dwPost(dt); } /* don't allow negative synapses to go much more negative. * This is to avoid having large negative input currents, * which will result in extra firing (by forcing 'u' to * go highly negative) */ conf.setStdpFunction(pre, post, -0.5, 2*initWeight); setBackend(backend, conf); return conf; }
/* Run two small non-overlapping rings with different delays */ void runDoubleRing(backend_t backend) { /* Make sure we go around the ring at least a couple of times */ const unsigned ncount = 512; const unsigned duration = ncount * 5 / 2; nemo::Configuration conf = configuration(false, 1024); setBackend(backend, conf); boost::scoped_ptr<nemo::Network> net(new nemo::Network); createRing(net.get(), ncount, 0, false, 1, 1); createRing(net.get(), ncount, ncount, false, 1, 2); boost::scoped_ptr<nemo::Simulation> sim(nemo::simulation(*net, conf)); /* Stimulate a single neuron in each ring to get them going */ std::vector<unsigned> fstim; fstim.push_back(0); fstim.push_back(ncount); sim->step(fstim); for(unsigned ms=1; ms < duration; ++ms) { const std::vector<unsigned>& fired = sim->step(); if(ms % 2 == 0) { BOOST_CHECK_EQUAL(fired.size(), 2U); BOOST_REQUIRE_EQUAL(fired[0], ms % ncount); BOOST_REQUIRE_EQUAL(fired[1], ncount + (ms / 2) % ncount); } else { BOOST_CHECK_EQUAL(fired.size(), 1U); BOOST_REQUIRE_EQUAL(fired.front(), ms % ncount); } } }
Soprano::Util::SimpleStatementIterator& Soprano::Util::SimpleStatementIterator::operator=( const QList<Statement>& sl ) { setBackend( new SimpleStatementIteratorBackend( sl ) ); return *this; }
KNMusicPlugin::KNMusicPlugin(QObject *parent) : KNPluginBase(parent) { //Initial global instance and file pathes. m_global=KNGlobal::instance(); m_musicAlbumArt=QDir::toNativeSeparators(m_global->databaseFolder()+"/AlbumArt/"); m_musicDatabasePath=QDir::toNativeSeparators(m_global->databaseFolder()+"/Music.db"); //Initial music backend. setBackend(new KNLibBass); //Initial music model setLibraryModel(new KNMusicLibraryModel); //Initial music data base for storage. setDatabase(new KNMusicDatabase); //Initial playlist manager. m_playlistManager=new KNMusicPlaylistManager(this); m_playlistManager->setMusicBackend(m_backend); //Initial music viewer. m_musicViewer=new KNMusicViewer(m_global->mainWindow()); m_musicViewer->setMusicModel(m_libraryModel); m_musicViewer->requireSetPlaylistManager(m_playlistManager); m_musicViewer->requireSetBackend(m_backend); connect(m_playlistManager, &KNMusicPlaylistManagerBase::requireHideDragList, m_musicViewer, &KNMusicViewer::hidePlaylistDragList); connect(m_musicViewer, &KNMusicViewer::requireAnalysisUrls, this, &KNMusicPlugin::requireAnalysisUrls); connect(m_libraryModel, &KNMusicLibraryModelBase::requireResort, m_musicViewer, &KNMusicViewer::requireResort); //Initial header widget m_headerWidget=new KNMusicHeaderWidget(m_global->mainWindow()); m_headerWidget->setPlaylistManager(m_playlistManager); //This must be done first! m_headerWidget->setMusicModel(m_libraryModel); m_headerWidget->setBackend(m_backend); connect(m_headerWidget, &KNMusicHeaderWidget::requireSearch, m_musicViewer, &KNMusicViewer::requireSearch); connect(m_headerWidget, &KNMusicHeaderWidget::requireShowMusicPlayer, m_musicViewer, &KNMusicViewer::onActionShowPlayer); connect(m_headerWidget, &KNMusicHeaderWidget::requireHideMusicPlayer, m_musicViewer, &KNMusicViewer::onActionHidePlayer); connect(m_headerWidget, &KNMusicHeaderWidget::requireLostFocus, m_musicViewer, &KNMusicViewer::setContentsFocus); connect(m_musicViewer, &KNMusicViewer::requireClearSearch, m_headerWidget, &KNMusicHeaderWidget::clearSearch); connect(m_musicViewer, &KNMusicViewer::requireSetProxy, m_playlistManager, &KNMusicPlaylistManagerBase::setProxyModel); connect(m_musicViewer, &KNMusicViewer::requirePlayMusic, m_headerWidget, &KNMusicHeaderWidget::onActionPlayMusic); m_libraryViewMenu=new KNMusicViewerMenu(m_musicViewer); m_libraryViewMenu->setModel(m_libraryModel); connect(m_libraryViewMenu, &KNMusicViewerMenu::requirePlayMusic, m_headerWidget, &KNMusicHeaderWidget::onActionPlayMusic); connect(m_libraryViewMenu, &KNMusicViewerMenu::requireShowIn, m_musicViewer, &KNMusicViewer::showIn); connect(m_libraryViewMenu, &KNMusicViewerMenu::requireGetInfo, this, &KNMusicPlugin::onActionGetInfo); connect(m_libraryViewMenu, &KNMusicViewerMenu::requireDelete, m_musicViewer, &KNMusicViewer::deleteMusic); connect(m_libraryViewMenu, &KNMusicViewerMenu::requireDeleteSelection, m_musicViewer, &KNMusicViewer::deleteSelections); connect(m_musicViewer, &KNMusicViewer::requireShowContextMenu, this, &KNMusicPlugin::onActionShowContextMenu); //Initial music searcher and collector manager. setSearcher(new KNMusicSearcher); setInfoCollectManager(new KNMusicInfoCollectorManager); m_musicPlayerWidget=new KNMusicPlayerWidget(m_musicViewer); m_musicPlayerWidget->setHeaderPlayer(m_headerWidget->player()); m_musicPlayerWidget->setBackend(m_backend); connect(m_headerWidget, &KNMusicHeaderWidget::requireUpdatePlaylistModel, m_musicPlayerWidget, &KNMusicPlayerWidget::setPlayListModel); connect(m_headerWidget, &KNMusicHeaderWidget::requireShowMusicPlayer, m_musicPlayerWidget, &KNMusicPlayerWidget::onActionSetProgressBar); connect(m_headerWidget, &KNMusicHeaderWidget::requireHideMusicPlayer, m_musicPlayerWidget, &KNMusicPlayerWidget::onActionRestoreProgreeBar); m_equalizer=new KNMusicEQ(m_backend); m_musicPlayerWidget->setEqualizer(m_equalizer); m_musicViewer->setPlayWidget(m_musicPlayerWidget); //Initial the detail dialog. setDetailsDialog(new KNMusicDetailInfo(m_musicViewer)); //Initial other things. loadShortcuts(); loadThreads(); loadData(); }
Server::Server() :_data(new PrivateData) { // Currently we only support Mongoose. setBackend(std::make_shared<MongooseBackend>()); }