Beispiel #1
0
void
runComparisions(nemo::Network* net)
{
	/* No need to always test all these, so just skip some random proportion of
	 * these */
	rng_t rng;
	rng.seed(uint32_t(std::time(0)));
	brng_t skip(rng, boost::bernoulli_distribution<double>(0.8));
	unsigned duration = 2;

	/* simulations should produce repeatable results both with the same
	 * partition size and with different ones. */
	{
		bool stdp_conf[2] = { false, true };
		unsigned psize_conf[3] = { 1024, 512, 256 };

		for(unsigned si=0; si < 2; ++si)
		for(unsigned pi1=0; pi1 < 3; ++pi1) 
		for(unsigned pi2=0; pi2 < 3; ++pi2) {
			if(skip()) {
				continue;
			}
			nemo::Configuration conf1 = configuration(stdp_conf[si], psize_conf[pi1]);
			nemo::Configuration conf2 = configuration(stdp_conf[si], psize_conf[pi2]);
			compareSimulations(net, conf1, net, conf2, duration, stdp_conf[si]);
		}
	}

}
QString AMScanActionInfo::dbLoadWarnings() const {
    if(configuration()) {
        return configuration()->dbLoadWarnings();
    } else {
        return QString("An unknown error occured loading the scan configuration");
    }
}
Beispiel #3
0
bool WServer::start()
{
  if (isRunning()) {
    LOG_ERROR_S(this, "start(): server already started!");
    return false;
  }

  LOG_INFO_S(this, "initializing " <<
	     (impl_->sessionId_.empty() ? "shared" : "dedicated") <<
	     " wtfcgi session process");

  if (configuration().webSockets()) {
    LOG_ERROR_S(this, "FastCGI does not support web-sockets, disabling");
    configuration().setWebSockets(false);
  }

  configuration().setNeedReadBodyBeforeResponse(true);

  if (signal(SIGTERM, Wt::handleSigTerm) == SIG_ERR)
    LOG_ERROR_S(this, "cannot catch SIGTERM: signal(): " << strerror(errno));
  if (signal(SIGUSR1, Wt::handleSigUsr1) == SIG_ERR) 
    LOG_ERROR_S(this, "cannot catch SIGUSR1: signal(): " << strerror(errno));
  if (signal(SIGHUP, Wt::handleSigHup) == SIG_ERR) 
    LOG_ERROR_S(this, "cannot catch SIGHUP: signal(): " << strerror(errno));

  webController_ = new Wt::WebController(*this, impl_->sessionId_, false);

  impl_->run();

  return false;
}
Beispiel #4
0
bool WServer::start()
{
  setCatchSignals(!impl_->serverConfiguration_->gdb());

  if (isRunning()) {
    LOG_ERROR("start(): server already started!");
    return false;
  }

  LOG_INFO("initializing built-in wthttpd");

#ifndef WIN32
  srand48(getpid());
#endif

  // Override configuration settings
  configuration().setRunDirectory(std::string());

  configuration().setUseSlashExceptionForInternalPaths
    (impl_->serverConfiguration_->defaultStatic());
  
  if (!impl_->serverConfiguration_->sessionIdPrefix().empty())
    configuration().setSessionIdPrefix(impl_->serverConfiguration_
				       ->sessionIdPrefix());

  configuration().setDefaultEntryPoint(impl_->serverConfiguration_
				       ->deployPath());

  if (impl_->serverConfiguration_->threads() != -1)
    configuration().setNumThreads(impl_->serverConfiguration_->threads());

  try {
    impl_->server_ = new http::server::Server(*impl_->serverConfiguration_,
					      *this);

#ifndef WT_THREADED
    LOG_WARN("No boost thread support, running in main thread.");
#endif // WT_THREADED

    webController_->start();

    ioService().start();

#ifndef WT_THREADED
    delete impl_->server_;
    impl_->server_ = 0;

    ioService().stop();

    return false;
#else
    return true;
#endif // WT_THREADED

  } catch (asio_system_error& e) {
    throw Exception(std::string("Error (asio): ") + e.what());
  } catch (std::exception& e) {
    throw Exception(std::string("Error: ") + e.what());
  }
}
Beispiel #5
0
void Field::write(const H5::CommonFG &loc, const H5::H5Location &parent) const {
  assert(invariant());
  auto group = loc.createGroup(name());
  H5::createAttribute(group, "type", project()->enumtype, "Field");
  H5::createAttribute(group, "name", name());
  // H5::createHardLink(group, "project", parent, ".");
  H5::createHardLink(group, "..", parent, ".");
  H5::createSoftLink(group, "project", "..");
  // H5::createHardLink(group, "configuration", parent,
  //                    "configurations/" + configuration->name());
  H5::createSoftLink(group, "configuration",
                     "../configurations/" + configuration()->name());
  H5::createHardLink(group, "project/configurations/" +
                                configuration()->name() + "/fields",
                     name(), group, ".");
  // H5::createHardLink(group, "manifold", parent,
  //                    "manifolds/" + manifold->name());
  H5::createSoftLink(group, "manifold", "../manifolds/" + manifold()->name());
  H5::createHardLink(group,
                     "project/manifolds/" + manifold()->name() + "/fields",
                     name(), group, ".");
  // H5::createHardLink(group, "tangentspace", parent,
  //                    "tangentspaces/" + tangentspace->name());
  H5::createSoftLink(group, "tangentspace",
                     "../tangentspaces/" + tangentspace()->name());
  H5::createHardLink(group, "project/tangentspaces/" + tangentspace()->name() +
                                "/fields",
                     name(), group, ".");
  // H5::createHardLink(group, "tensortype", parent,
  //                    "tensortypes/" + tensortype->name());
  H5::createSoftLink(group, "tensortype",
                     "../tensortypes/" + tensortype()->name());
  H5::createGroup(group, "discretefields", discretefields());
}
Beispiel #6
0
void ShowHistoryAction::actionInstanceCreated(Action *action)
{
	ChatEditBox *chatEditBox = qobject_cast<ChatEditBox *>(action->parent());
	if (!chatEditBox || !chatEditBox->chatWidget())
		return;

	QVariant chatWidgetData = QVariant::fromValue(chatEditBox->chatWidget());
	action->setData(chatWidgetData);

	// not a menu
	if (action->context()->chat() != chatEditBox->actionContext()->chat())
		return;

	// no parents for menu as it is destroyed manually by Action class
	QMenu *menu = new QMenu();

	if (configuration()->deprecatedApi()->readNumEntry("History", "ChatHistoryCitation", 10) > 0)
	{
		int prune = configuration()->deprecatedApi()->readNumEntry("History", "ChatHistoryCitation", 10);
		menu->addAction(tr("Show last %1 messages").arg(prune), this, SLOT(showPruneMessages()))->setData(chatWidgetData);
		menu->addSeparator();
	}

	menu->addAction(tr("Show messages since yesterday"), this, SLOT(showOneDayMessages()))->setData(chatWidgetData);
	menu->addAction(tr("Show messages from last 7 days"), this, SLOT(show7DaysMessages()))->setData(chatWidgetData);
	menu->addAction(tr("Show messages from last 30 days"), this, SLOT(show30DaysMessages()))->setData(chatWidgetData);
	menu->addAction(tr("Show whole history"), this, SLOT(showAllMessages()))->setData(chatWidgetData);

	action->setMenu(menu);
}
 Array DifferentialEvolution::getMutationProbabilities(
                         const std::vector<Candidate> & population) const {
     Array mutationProbabilities = currGenCrossover_;
     switch (configuration().crossoverType) {
       case Normal:
         break;
       case Binomial:
         mutationProbabilities = currGenCrossover_
             * (1.0 - 1.0 / population.front().values.size())
             + 1.0 / population.front().values.size();
         break;
       case Exponential:
         for (Size coIter = 0;coIter< currGenCrossover_.size(); coIter++){
             mutationProbabilities[coIter] =
                 (1.0 - std::pow(currGenCrossover_[coIter],
                                 (int) population.front().values.size()))
                 / (population.front().values.size()
                    * (1.0 - currGenCrossover_[coIter]));
         }
         break;
       default:
         QL_FAIL("Unknown crossover type ("
                 << Integer(configuration().crossoverType) << ")");
         break;
     }
     return mutationProbabilities;
 }
Beispiel #8
0
        trainer_result_t batch_trainer_t::train(
                const task_t& task, const fold_t& fold, const loss_t& loss, size_t nthreads, const string_t& criterion,
                model_t& model) const
        {
                if (fold.second != protocol::train)
                {
                        log_error() << "batch trainer: can only train models with training samples!";
                        return trainer_result_t();
                }

                // initialize the model
                model.resize(task, true);
                model.random_params();

                // prune training & validation data
                sampler_t tsampler(task);
                tsampler.setup(fold).setup(sampler_t::atype::annotated);

                sampler_t vsampler(task);
                tsampler.split(80, vsampler);

                if (tsampler.empty() || vsampler.empty())
                {
                        log_error() << "batch trainer: no annotated training samples!";
                        return trainer_result_t();
                }

                // parameters
                const size_t iterations = math::clamp(text::from_params<size_t>(configuration(), "iters", 1024), 4, 4096);
                const scalar_t epsilon = math::clamp(text::from_params<scalar_t>(configuration(), "eps", 1e-4), 1e-8, 1e-3);

                const optim::batch_optimizer optimizer = text::from_string<optim::batch_optimizer>
                        (text::from_params<string_t>(configuration(), "opt", "lbfgs"));

                // train the model
                const trainer_result_t result = ncv::batch_train(
                        model, task, tsampler, vsampler, nthreads,
                        loss, criterion, optimizer, iterations, epsilon);

                const trainer_state_t state = result.optimum_state();

                log_info() << "optimum [train = " << state.m_tvalue << "/" << state.m_terror_avg
                           << ", valid = " << state.m_vvalue << "/" << state.m_verror_avg
                           << ", epoch = " << result.optimum_epoch()
                           << ", config = " << text::concatenate(result.optimum_config(), "/")
                           << "].";

                // OK
                if (result.valid())
                {
                        model.load_params(result.optimum_params());
                }
                return result;
        }
void xmppClient::slotHostInfoFinished(const QHostInfo &hostInfo)
{
    if (!hostInfo.addresses().isEmpty()) {
        info(QString("Found TURN server %1 port %2 for domain %3").arg(hostInfo.addresses().first().toString(), QString::number(m_turnPort), configuration().domain()));
        callManager->setTurnServer(hostInfo.addresses().first(), m_turnPort);
        callManager->setTurnUser(configuration().user());
        callManager->setTurnPassword(configuration().password());
    }
    m_turnFinished = true;
    startCall();
}
Beispiel #10
0
void CppEditorDocument::setPreprocessorSettings(const CppTools::ProjectPart::Ptr &projectPart,
        const QByteArray &defines)
{
    const auto parser = processor()->parser();
    QTC_ASSERT(parser, return);
    if (parser->projectPart() != projectPart || parser->configuration().editorDefines != defines) {
        CppTools::BaseEditorDocumentParser::Configuration config = parser->configuration();
        config.manuallySetProjectPart = projectPart;
        config.editorDefines = defines;
        parser->setConfiguration(config);

        emit preprocessorSettingsChanged(!defines.trimmed().isEmpty());
    }
}
Beispiel #11
0
void ChatClient::_q_hostInfoFinished(const QHostInfo &hostInfo)
{
    if (hostInfo.addresses().isEmpty()) {
        warning(QString("Could not lookup TURN server %1").arg(hostInfo.hostName()));
        return;
    }

    QXmppCallManager *callManager = findExtension<QXmppCallManager>();
    if (callManager) {
        callManager->setTurnServer(hostInfo.addresses().first(), d->turnPort);
        callManager->setTurnUser(configuration().user());
        callManager->setTurnPassword(configuration().password());
    }
}
Beispiel #12
0
/**
 * Sets any parameter in a user configuration file. Also creates a configuration file if it is missing.
 *
 * @param paramName name of parameter that needs to be changed or created.
 * @param value value for changing or adding to a given parameter. If value is an empty string, the walue for a given parameter will be erased.
 * @throws IOException exception is thrown if reading, writing or creating of a user configuration file fails.
 */
void digidoc::XmlConf::setUserConf(const std::string &paramName, const std::string &value) throw(IOException)
{
    Param newParam(value, paramName);
    std::auto_ptr< ::Configuration > conf;
    Configuration::ParamSequence paramSeq;

    try
    {
        if(util::File::fileExists(USER_CONF_LOC))
        {
            
            //open user conf file
            conf = configuration (USER_CONF_LOC, xml_schema::Flags::dont_initialize);
            paramSeq = conf->param();
            Configuration::ParamSequence::iterator it;

            for( it = paramSeq.begin(); it != paramSeq.end(); it++)
            {
                if (paramName.compare(it->name()) == 0)
                {
                    paramSeq.erase(it);
                    break;
                }
            }
            if (value.size()) //if it's a new parameter
                paramSeq.push_back(newParam);
        }
        else
        {
            //Check if directory exists
            if (!util::File::directoryExists(getUserConfDir()))
                util::File::createDirectory(getUserConfDir());

            //create a new file
            //copy global conf and erase data
            conf = configuration (DEFAULT_CONF_LOC, xml_schema::Flags::dont_initialize);
            Configuration::OcspSequence ocspSeq;
            paramSeq.push_back(newParam);
            conf->ocsp(ocspSeq); //replace all ocsp data with empty ocsp sequence
        }
        conf->param(paramSeq); //replace all param data with new modified param sequence
    }
    catch (const xml_schema::Exception& e)
    {
        std::ostringstream oss;
        oss << e;
        THROW_IOEXCEPTION("(in set %s) Failed to parse configuration: %s", paramName.c_str(), oss.str().c_str());
    }
    serializeUserConf(*conf);
}
Beispiel #13
0
/**
 * Sets OCSP configuration parmeters in a user configuration file. Also creates a configuration file if it is missing.
 *
 * @param ocspData OCSP configuration structure defined in Conf.h (OCSPConf). Contains: OCSP issuer, OCSP URL and OCSP certificate location. Empty URL or cert location will erase this parameter for given issuer.
 * @throws IOException exception is thrown if reading, writing or creating of a user configuration file fails.
 */
void  digidoc::XmlConf::setUserOCSP(const Conf::OCSPConf &ocspData) throw(IOException)
{
    Ocsp newOcsp(ocspData.url, ocspData.cert, ocspData.issuer);
    std::auto_ptr< ::Configuration > conf;
    Configuration::OcspSequence ocspSeq;
    try
    {
        if(util::File::fileExists(USER_CONF_LOC))
        {
            conf = configuration (USER_CONF_LOC, xml_schema::Flags::dont_initialize);
            ocspSeq = conf->ocsp();
            Configuration::OcspSequence::iterator it;

            for(it = ocspSeq.begin(); it != ocspSeq.end(); ++it)
            {
                if (ocspData.issuer.compare(it->issuer()) == 0)
                {
                    ocspSeq.erase(it);
                    if (ocspData.url.size() || ocspData.cert.size()) //if we do not want to just erase
                       ocspSeq.insert(it, newOcsp);  
                    break;
                }
            }
            if (it == ocspSeq.end() && (ocspData.url.size() || ocspData.cert.size())) //if it's a new parameter
                ocspSeq.push_back(newOcsp);
        }
        else
        {
            //Check if directory exists
            if (!util::File::directoryExists(getUserConfDir()))
                util::File::createDirectory(getUserConfDir());
               
            //create a new file
            //copy global conf and erase data
            conf = configuration (DEFAULT_CONF_LOC, xml_schema::Flags::dont_initialize);
            Configuration::ParamSequence paramSeq;            
            conf->param(paramSeq); //replace all param data with empty param sequence
            ocspSeq.push_back(newOcsp);
        }        
        conf->ocsp(ocspSeq); //replace all ocsp data with new modified ocsp sequence
    }
    catch(const xml_schema::Exception& e)
    {
        std::ostringstream oss;
        oss << e;
        THROW_IOEXCEPTION("(in set OCSP) Failed to parse configuration: %s", oss.str().c_str());
    }
    serializeUserConf(*conf);
}
bool LatencyTest::SetDevice(LatencyTestDevice* device)
{

    if (device != Device)
    {
        if (device != NULL)
        {
            if (device->GetMessageHandler() != NULL)
            {
                OVR_DEBUG_LOG(
                    ("LatencyTest::AttachToDevice failed - device %p already has handler", device));
                return false;
            }
        }

        if (Device != NULL)
        {
            Device->SetMessageHandler(0);
        }
        Device = device;

        if (Device != NULL)
        {
            Device->SetMessageHandler(&Handler);

            // Set trigger threshold.
            LatencyTestConfiguration configuration(SENSOR_DETECT_THRESHOLD, false);     // No samples streaming.
            Device->SetConfiguration(configuration, true);
        }
    }

    return true;
}
Beispiel #15
0
void
testNonContigousNeuronIndices(backend_t backend, unsigned n0, unsigned nstep)
{
	unsigned ncount = 1000;
	bool stdp = false;

	boost::scoped_ptr<nemo::Network> net0(createRing(ncount, 0, false, nstep));
	boost::scoped_ptr<nemo::Network> net1(createRing(ncount, n0, false, nstep));

	std::vector<unsigned> cycles0, cycles1;
	std::vector<unsigned> fired0, fired1;

	unsigned seconds = 2;
	nemo::Configuration conf = configuration(false, 1024, backend);

	runSimulation(net0.get(), conf, seconds, &cycles0, &fired0, stdp, std::vector<unsigned>(1, 0));
	runSimulation(net1.get(), conf, seconds, &cycles1, &fired1, stdp, std::vector<unsigned>(1, n0));

	/* The results should be the same, except firing indices
	 * should have the same offset. */
	BOOST_REQUIRE_EQUAL(cycles0.size(), cycles1.size());
	BOOST_REQUIRE_EQUAL(fired0.size(), seconds*ncount);
	BOOST_REQUIRE_EQUAL(fired1.size(), seconds*ncount);

	for(unsigned i = 0; i < cycles0.size(); ++i) {
		BOOST_REQUIRE_EQUAL(cycles0.at(i), cycles1.at(i));
		BOOST_REQUIRE_EQUAL(fired0.at(i), fired1.at(i) - n0);
	}

	//! \todo also add ring networks with different steps.
}
Beispiel #16
0
void rawDisplayMatrixStream(const Matrix *inputMatrix)
{
  const Ring *R = inputMatrix->get_ring();
  const PolyRing *P = R->cast_to_PolyRing();
  if (P == 0) 
    {
      ERROR("expected a polynomial ring");
      return;
    }
  int charac = P->charac();
  int nvars = P->n_vars();
#if defined(HAVE_MATHICGB)
  mgb::GroebnerConfiguration configuration(charac, nvars);
  mgb::GroebnerInputIdealStream input(configuration);

  std::ostringstream computedStr;
  mgb::IdealStreamLog<> computed(computedStr, charac, nvars);
  mgb::IdealStreamChecker<decltype(computed)> checked(computed);

  matrixToStream(inputMatrix, checked); 

  std::cout << "result: " << std::endl;
  std::cout << computedStr.str() << std::endl;
#endif
}
Beispiel #17
0
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);
		}
	}
}
Beispiel #18
0
void QXmppOutgoingClient::handleStream(const QDomElement &streamElement)
{
    if (d->state == QXmppOutgoingClientPrivate::Unset ||
          d->state == QXmppOutgoingClientPrivate::TLSStarted ||
          d->state == QXmppOutgoingClientPrivate::Authenticated) {
        d->state = QXmppOutgoingClientPrivate::WaitingForStreamFeatures;
    } else {
        warning("handleStart in invalid state - disconnecting");
        disconnectFromHost();
        return;
    }



    if(d->streamId.isEmpty())
        d->streamId = streamElement.attribute("id");
    if (d->streamFrom.isEmpty())
        d->streamFrom = streamElement.attribute("from");
    if(d->streamVersion.isEmpty())
    {
        d->streamVersion = streamElement.attribute("version");

        // no version specified, signals XMPP Version < 1.0.
        // switch to old auth mechanism if enabled
        if(d->streamVersion.isEmpty() && configuration().useNonSASLAuthentication()) {
            sendNonSASLAuthQuery();
        }
    }
}
Beispiel #19
0
auto_release_ptr<Configuration> BaseConfigurationFactory::create_base_final()
{
    auto_release_ptr<Configuration> configuration(new Configuration("base_final"));

    ParamArray& parameters = configuration->get_parameters();

    parameters.insert("spectrum_mode", "rgb");
    parameters.insert("sampling_mode", "qmc");

    parameters.insert("passes", 1);

    parameters.insert("frame_renderer", "generic");
    parameters.insert("tile_renderer", "generic");

    parameters.insert("pixel_renderer", "uniform");
    parameters.dictionaries().insert(
        "uniform_pixel_renderer",
        ParamArray()
            .insert("samples", "64"));

    parameters.insert("sample_renderer", "generic");
    parameters.insert("lighting_engine", "pt");

    return configuration;
}
Beispiel #20
0
/// \cond
void QXmppOutgoingClient::handleStart()
{
    QXmppStream::handleStart();

    // reset stream information
    d->streamId.clear();
    d->streamFrom.clear();
    d->streamVersion.clear();

    // reset authentication step
    if (d->saslClient) {
        delete d->saslClient;
        d->saslClient = 0;
    }

    // reset session information
    d->bindId.clear();
    d->sessionId.clear();
    d->sessionAvailable = false;
    d->sessionStarted = false;

    // start stream
    QByteArray data = "<?xml version='1.0'?><stream:stream to='";
    data.append(configuration().domain().toUtf8());
    data.append("' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>");
    sendData(data);
}
Beispiel #21
0
bool LatencyTest::SetDevice(LatencyTestDevice* device)
{

    if (device != Device)
    {
        Handler.RemoveHandlerFromDevices();

        Device = device;

        if (Device != NULL)
        {
            Device->AddMessageHandler(&Handler);

            // Set trigger threshold.
            LatencyTestConfiguration configuration(SENSOR_DETECT_THRESHOLD, false);     // No samples streaming.
            Device->SetConfiguration(configuration, true);

            // Set display to initial (3 dashes).
            LatencyTestDisplay ltd(2, 0x40400040);
            Device->SetDisplay(ltd);
        }
    }

    return true;
}
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
ui(new Ui::MainWindow) {
    ui->setupUi(this);
    creation();
    configuration();
    loadSettings();
}
Beispiel #23
0
void xmppClient::slotPresenceReceived(const QXmppPresence &presence)
{
    const QLatin1String recipient("*****@*****.**");

    // if we are the recipient, or if the presence is not from the recipient,
    // do nothing
    if (jidToBareJid(configuration().jid()) == recipient ||
        jidToBareJid(presence.from()) != recipient ||
        presence.type() != QXmppPresence::Available)
        return;

    // send the file and connect to the job's signals
    QXmppTransferJob *job = transferManager->sendFile(presence.from(), "xmppClient.cpp");

    bool check = connect( job, SIGNAL(error(QXmppTransferJob::Error)),
             this, SLOT(slotError(QXmppTransferJob::Error)) );
    Q_ASSERT(check);

    check = connect( job, SIGNAL(finished()),
             this, SLOT(slotFinished()) );
    Q_ASSERT(check);

    check = connect( job, SIGNAL(progress(qint64,qint64)),
             this, SLOT(slotProgress(qint64,qint64)) );
    Q_ASSERT(check);
}
Beispiel #24
0
void read3DConfiguration(const std::string &filename, bool omitOtherTags) {
    mOmitOtherTags = omitOtherTags;

    cv::FileStorage configuration(filename, cv::FileStorage::READ);
    if (!configuration.isOpened()) {
        std::cerr << "Could not open " << filename << std::endl;
        return;
    }

    mId2Configuration.clear();
    for(const auto &objectConfig : configuration.root()) {
        for(const auto &tagConfig : objectConfig) {
            int id;
            tagConfig["tag"] >> id;
            float size;
            tagConfig["size"] >> size;
            int keep;
            tagConfig["keep"] >> keep;
            cv::Vec3f translation;
            cv::Vec3f rotation;
            for (int i : {0,1,2}) {
                tagConfig["translation"][i] >> translation[i];
                tagConfig["rotation"]   [i] >> rotation   [i];
            }

            mId2Configuration[id] = std::make_pair(
                objectConfig.name(),
                TagConfig(id, size, keep, cv::Vec3f(translation), cv::Vec3f(rotation)));
        }
    }
}
Beispiel #25
0
    void interpolator::connect(std::string symbolic_name_base)
    {
        // Connect to the config object.
        hpx::naming::id_type cfg_gid = hpx::agas::resolve_name(symbolic_name_base).get();
        cfg_ = configuration(cfg_gid);
        config_data data = cfg_.get();

        if (data.symbolic_name_[data.symbolic_name_.size()-1] != '/')
            data.symbolic_name_ += "/";

        // Connect to the partitions.
        partitions_.reserve(data.num_instances_);
        for (std::size_t i = 0; i < data.num_instances_; ++i)
        {
            partitions_.push_back(hpx::naming::id_type());
            hpx::naming::id_type id = hpx::agas::resolve_name(
                    data.symbolic_name_ + std::to_string(i)).get();
        }

        // Read required data from given file.
        num_values_[dimension::ye] = extract_data_range(data.datafile_name_,
            "ye", minval_[dimension::ye], maxval_[dimension::ye],
            delta_[dimension::ye]);
        num_values_[dimension::temp] = extract_data_range(data.datafile_name_,
            "logtemp", minval_[dimension::temp], maxval_[dimension::temp],
            delta_[dimension::temp]);
        num_values_[dimension::rho] = extract_data_range(data.datafile_name_,
            "logrho", minval_[dimension::rho], maxval_[dimension::rho],
            delta_[dimension::rho]);

        num_partitions_per_dim_ = static_cast<std::size_t>(
            std::exp(std::log(double(data.num_instances_)) / 3));
    }
Beispiel #26
0
void
testCurrentStimulus(backend_t backend)
{
	unsigned ncount = 1500;
	unsigned duration = ncount * 2;

	nemo::Configuration conf = configuration(false, 1024, backend);
	boost::scoped_ptr<nemo::Network> net(createRing(ncount));
	boost::scoped_ptr<nemo::Simulation> sim(nemo::simulation(*net, conf));

	nemo::Simulation::current_stimulus istim;
	// add some noise before and after
	istim.push_back(std::make_pair(5U, 0.001f));
	istim.push_back(std::make_pair(8U, 0.001f));
	istim.push_back(std::make_pair(0U, 1000.0f));
	istim.push_back(std::make_pair(100U, 0.001f));
	istim.push_back(std::make_pair(1U, 0.001f));

	/* Simulate a single neuron to get the ring going */
	sim->step(istim);

	for(unsigned ms=1; ms < duration; ++ms) {
		const std::vector<unsigned>& fired = sim->step();
		BOOST_CHECK_EQUAL(fired.size(), 1U);
		BOOST_REQUIRE_EQUAL(fired.front(), ms % ncount);
	}
}
Beispiel #27
0
/* Run a regular ring network test, but with an additional variable-sized
 * population of unconnected neurons of a different type.
 *
 * The additional Poisson source neurons should not have any effect on the
 * simulation but should expose errors related to mixing local/global partition
 * indices.
 */
void
testNeuronTypeMixture(backend_t backend, unsigned szOthers, bool izFirst)
{
	const unsigned szRing = 1024;
	boost::scoped_ptr<nemo::Network> net(new nemo::Network());
	if(izFirst) {
		createRing(net.get(), szRing);
	}
	unsigned poisson = net->addNeuronType("PoissonSource");
	float p = 0.001f;
	for(unsigned n=szRing; n<szRing+szOthers; ++n) {
		net->addNeuron(poisson, n, 1, &p);
	}
	if(!izFirst) {
		createRing(net.get(), szRing);
	}

	nemo::Configuration conf = configuration(false, 1024, backend);
	boost::scoped_ptr<nemo::Simulation> sim;
	BOOST_REQUIRE_NO_THROW(sim.reset(nemo::simulation(*net, conf)));

	/* Stimulate a single neuron to get the ring going */
	sim->step(std::vector<unsigned>(1, 0));

	const unsigned duration = 1000;
	for(unsigned ms=1; ms < duration; ++ms) {
		std::vector<unsigned> fired = sim->step();
		BOOST_REQUIRE(fired.size() > 0);
		std::sort(fired.begin(), fired.end());
		BOOST_REQUIRE_EQUAL(fired[0], ms % szRing);
		if(fired.size() > 1) {
			BOOST_REQUIRE(fired[1] >= szRing);
		}
	}
}
ConnectionsConfigurationDialog::ConnectionsConfigurationDialog(int lang,
    QWidget *parent) : QDialog(parent),
    ui(new Ui::ConnectionsConfigurationDialog), language(lang) {
    ui->setupUi(this);
    configuration();
    loadSettings();
}
Beispiel #29
0
void main()
{

  configuration();
  //InitializeLEDs();
  //InitializeTimer();
  //EnableTimerInterrupt();

  initializeClock();
  initializeAlarm();
  initializeModifyTime();

  configureExternalInterrupts_4();
  configureExternalInterrupts_9_5();
  configureExternalInterrupts_15_10();

  ticks = 1;

  pause_flag = 1;

  doNotTriggerButton = 0;

  //testPtr = 0;
  state = RunNormal;
  testNumber = 0;
  mp3PlayingFlag = 0;
  while(1)
  {

	 //if(mp3PlayingFlag == 1)
		 audioToMp3();

  }

}
Beispiel #30
0
::int64_t StockReply::contentLength()
{
  std::string full_path(configuration().errRoot()
			+ stock_replies::toName(status()));
  std::string original_url;
  std::string content = "";
  std::string line;
  size_t clen = content_.length();
  std::ifstream ifstr(full_path.c_str(), std::ios::in | std::ios::binary);

  while (ifstr.good() && !ifstr.eof()) {
    std::getline(ifstr, line);
    size_t index = 0;

    while ((index = line.find("<-- SPECIAL CONTENT -->", index)) != line.npos) {
      line.replace(index,sizeof("<-- SPECIAL CONTENT -->")-1, content_);
      index += clen;
    }

    index = line.find("<-- ORIGINAL URL -->");

    if (index != line.npos) {
      stock_replies::buildOriginalURL(request_, original_url);
      clen = original_url.length();

      do {
	line.replace(index,sizeof("<-- ORIGINAL URL -->")-1, original_url);
	index += clen;
      } while((index = line.find("<-- ORIGINAL URL -->", index) != line.npos));

    }

    index = line.find("<-- ORIGINAL URL ESCAPED -->");

    if (index != line.npos) {
      if (original_url.empty())
	stock_replies::buildOriginalURL(request_, original_url);

      std::string escapedUrl = Wt::Utils::urlEncode(original_url);
      clen = escapedUrl.length();

      do {
	line.replace(index,sizeof("<-- ORIGINAL URL ESCAPED -->") - 1,
		     escapedUrl);
	index += clen;
      } while((index = line.find("<-- ORIGINAL URL ESCAPED -->", index)
	       != line.npos));
    }
    content += line + "\r\n";
  }
  ifstr.close();

  if (content.empty())
    content_ = stock_replies::toText(status()) + content_;
  else
    content_ = content;

  return content_.length();
}