Exemple #1
0
int main(int argc, char *argv[])
{
    Network yarp;
    if (!yarp.checkNetwork())
    {
        yError("YARP server not available!");
        return 1;
    }

    ResourceFinder rf;
    rf.setDefaultContext("fingersTuner");
    rf.setDefaultConfigFile("config.ini");
    rf.configure(argc,argv);

    TunerModule mod;
    return mod.runModule(rf);
}
Exemple #2
0
int main(int argc, char *argv[])
{
    Network yarp;
    if (!yarp.checkNetwork())
    {
        yError("Yarp network doesn't seem to be available!");
        return -1;
    }

    ResourceFinder rf;
    rf.setDefaultContext("iol2opc");
    rf.setDefaultConfigFile("config.ini");
    rf.configure(argc,argv);

    IOL2OPCBridge bridge;
    return bridge.runModule(rf);
}
Exemple #3
0
int main(int argc, char *argv[])
{
   Network yarp;

   if (!yarp.checkNetwork())
       return 1;

   ResourceFinder rf;
   rf.setVerbose(true);
   rf.setDefaultContext("himrep");
   rf.setDefaultConfigFile("sparseCoder.ini");
   rf.configure(argc,argv);
   rf.setDefault("name","sparseCoder");
   SparseCoderModule mod;

   return mod.runModule(rf);
}
void ContextMenuActionProvider::addIrcUserActions(QMenu *menu, const QModelIndex &index)
{
    // this can be called: a) as a nicklist context menu (index has IrcUserItemType)
    //                     b) as a query buffer context menu (index has BufferItemType and is a QueryBufferItem)
    //                     c) right-click in a query chatview (same as b), index will be the corresponding QueryBufferItem)
    //                     d) right-click on some nickname (_contextItem will be non-null, _filter -> chatview, index -> message buffer)

    if (contextItem().isNull()) {
        // cases a, b, c
        bool haveQuery = indexList().count() == 1 && findQueryBuffer(index).isValid();
        NetworkModel::ItemType itemType = static_cast<NetworkModel::ItemType>(index.data(NetworkModel::ItemTypeRole).toInt());
        addAction(_nickModeMenuAction, menu, itemType == NetworkModel::IrcUserItemType);
        addAction(_nickCtcpMenuAction, menu);

        IrcUser *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
        if (ircUser) {
            Network *network = ircUser->network();
            // only show entries for usermode +h if server supports it
            if (network && network->prefixModes().contains('h')) {
                action(NickHalfop)->setVisible(true);
                action(NickDehalfop)->setVisible(true);
            }
            else {
                action(NickHalfop)->setVisible(false);
                action(NickDehalfop)->setVisible(false);
            }
            // ignoreliststuff
            QString bufferName;
            BufferInfo bufferInfo = index.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
            if (bufferInfo.type() == BufferInfo::ChannelBuffer)
                bufferName = bufferInfo.bufferName();
            QMap<QString, bool> ignoreMap = Client::ignoreListManager()->matchingRulesForHostmask(ircUser->hostmask(), ircUser->network()->networkName(), bufferName);
            addIgnoreMenu(menu, ircUser->hostmask(), ignoreMap);
            // end of ignoreliststuff
        }
        menu->addSeparator();
        addAction(NickQuery, menu, itemType == NetworkModel::IrcUserItemType && !haveQuery && indexList().count() == 1);
        addAction(NickSwitchTo, menu, itemType == NetworkModel::IrcUserItemType && haveQuery);
        menu->addSeparator();
        addAction(NickWhois, menu, true);
    }
    else if (!contextItem().isEmpty() && messageFilter()) {
        // case d
        // TODO
    }
}
Exemple #5
0
TEST(CoordinatorTest, MultipleAppends)
{
  const std::string path1 = utils::os::getcwd() + "/.log1";
  const std::string path2 = utils::os::getcwd() + "/.log2";

  utils::os::rmdir(path1);
  utils::os::rmdir(path2);

  Replica replica1(path1);
  Replica replica2(path2);

  Network network;

  network.add(replica1.pid());
  network.add(replica2.pid());

  Coordinator coord(2, &replica1, &network);

  {
    Result<uint64_t> result = coord.elect(Timeout(1.0));
    ASSERT_TRUE(result.isSome());
    EXPECT_EQ(0, result.get());
  }

  for (uint64_t position = 1; position <= 10; position++) {
    Result<uint64_t> result =
      coord.append(utils::stringify(position), Timeout(1.0));
    ASSERT_TRUE(result.isSome());
    EXPECT_EQ(position, result.get());
  }

  {
    Future<std::list<Action> > actions = replica1.read(1, 10);
    ASSERT_TRUE(actions.await(2.0));
    ASSERT_TRUE(actions.isReady());
    EXPECT_EQ(10, actions.get().size());
    foreach (const Action& action, actions.get()) {
      ASSERT_TRUE(action.has_type());
      ASSERT_EQ(Action::APPEND, action.type());
      EXPECT_EQ(utils::stringify(action.position()), action.append().bytes());
    }
  }

  utils::os::rmdir(path1);
  utils::os::rmdir(path2);
}
const Error *Node::UnInit( void )
{
   // Detach this node from the network
   if( netRef ) 
   {
      Network *net = (Network*)RefObj::LockRef( netRef );
      if( net )
      {  
         net->DetachNode( this );
         net->UnlockRef();
      }
      RefObj::ReleaseRef( netRef );
      netRef = 0;
   }

   return 0;
}
Exemple #7
0
Network * Network::NewNetwork(const Configuration & config, const string & name)
{
  const string topo = config.GetStr( "topology" );
  Network * n = NULL;
  if ( topo == "torus" ) {
    KNCube::RegisterRoutingFunctions() ;
    n = new KNCube( config, name, false );
  } else if ( topo == "mesh" ) {
    KNCube::RegisterRoutingFunctions() ;
    n = new KNCube( config, name, true );
  } else if ( topo == "cmesh" ) {
    CMesh::RegisterRoutingFunctions() ;
    n = new CMesh( config, name );
  } else if ( topo == "fly" ) {
    KNFly::RegisterRoutingFunctions() ;
    n = new KNFly( config, name );
  } else if ( topo == "qtree" ) {
    QTree::RegisterRoutingFunctions() ;
    n = new QTree( config, name );
  } else if ( topo == "tree4" ) {
    Tree4::RegisterRoutingFunctions() ;
    n = new Tree4( config, name );
  } else if ( topo == "fattree" ) {
    FatTree::RegisterRoutingFunctions() ;
    n = new FatTree( config, name );
  } else if ( topo == "flatfly" ) {
    FlatFlyOnChip::RegisterRoutingFunctions() ;
    n = new FlatFlyOnChip( config, name );
  } else if ( topo == "anynet"){
    AnyNet::RegisterRoutingFunctions() ;
    n = new AnyNet(config, name);
  } else if ( topo == "dragonflynew"){
    DragonFlyNew::RegisterRoutingFunctions() ;
    n = new DragonFlyNew(config, name);
  } else {
    cerr << "Unknown topology: " << topo << endl;
  }
  
  /*legacy code that insert random faults in the networks
   *not sure how to use this
   */
  if ( n && ( config.GetInt( "link_failures" ) > 0 ) ) {
    n->InsertRandomFaults( config );
  }
  return n;
}
Exemple #8
0
int main(int argc, char *argv[]) {
    printf("This test creates two ports and writes from one to the other.\n");
    printf("Make sure no other YARP programs are running.\n");
    printf("(or else remove the yarpNetworkSetLocalMode line)\n");

    Network yarp;
    yarp.setLocalMode(1);

    Port p1, p2;
    bool ok = p1.open("/test1") && p2.open("/test2");
    if (!ok) {
        printf("failed to open ports\n");
        return 1;
    }

    ok = yarp.connect("/test1","/test2",NULL);
    if (!ok) {
        printf("failed to connect ports\n");
        return 1;
    }

    p1.enableBackgroundWrite(true);

    MyPortable i1, i2;
    i1.val = 15;

    printf("Writing (in background)...\n");
    p1.write(i1);

    printf("Reading...\n");

    p2.read(i2);

    printf("After read, received %d\n", i2.val);
    if (i2.val==15) {
        printf("Correct!\n");
    } else {
        printf("That's not right, something failed.\n");
        return 1;
    }

    p1.close();
    p2.close();

    return 0;
}
int main(int argc, char *argv[])
{
    Network yarp;

    if (!yarp.checkNetwork())
        return -1;

    YARP_REGISTER_DEVICES(icubmod)

    ResourceFinder rf;
    rf.setVerbose(true);
    rf.setDefaultContext("sceneFlowModule");
    rf.configure(argc,argv);
    sceneFlowModule mod;

    return mod.runModule(rf);
}
Exemple #10
0
  void			receiveMe(const std::string &ip, int port, const std::string &dir, void (*cb)(int, void*), void *data) {
    Network		net;
    FILE		*file;
    char		*buff;
    int			received;
    int			i = 0, odoSize;
    ANetwork::t_frame	frame;
    bool		reading = true;

    try {
      net.init(port, ANetwork::TCP_MODE);
      net.connect(ip);
      net.write(CreateRequest::create(1, 2, 3, "File"));
      frame = net.read();
      odoSize = atoi(frame.data);
      frame = net.read();
      file = fopen(std::string(dir + frame.data).c_str(), "wb");
      while (reading) {
	buff = (char*) net.getSocket()->read(D_BUF, &received);
	if (received <= 0)
	  break;
	i += fwrite(buff, 1, received, file);
	cb(i * 100 / odoSize, data);
      }
      fclose(file);
    } catch (const std::exception &e) {
      std::cout << e.what() << std::endl;
    }
  };
	/**
	 * 
	 * ~~~~~ Back Propogation ~~~~~
	 * 
	 * Train the network by 'back propogation'
	 * see http://en.wikipedia.org/wiki/Backpropagation
	 */
	std::vector<double> _backPropogation ( std::vector<double> input, std::vector<double> expected, Network& net )
	{
		// get the result of feeding the input into the network
		std::vector<double> output = net.feedForward(input);

		ActFunction actf = net.activate();
		double rate = net.rate();

		// ~~~~~ loop backwards over the layers ~~~~~
		// 
		// as we descend though the layers, the difference between the output and the expected 
		// result is propogated through each layer; while the change in weights (deltas) is computed 
		// on for each layer.
		for(auto layer = net.rbegin(); layer != net.rend(); ++layer)
		{

			// input and output for each layer
			std::vector<double> layer_input = (*layer)->getInput();
			std::vector<double> layer_output = (*layer)->getOutput();

			// iterate over the neurons in a vector
			auto out = layer_output.begin();
			for (auto neuron = (*layer)->begin(); neuron != (*layer)->end(); ++neuron, ++out)
			{

				// the output layer is handled a bit differently, as it can be compared directly with the 
				// expected answer
				auto ex = expected.begin();
				auto in = layer_input.begin();
				for (auto weight = (*neuron).begin(); weight != (*neuron).end(); ++weight, ++in, ++ex )
				{
					// calculate the deltas of the weights
					double delta = rate * ((*ex) - (*in)) * actf.dydx((*out)) * (*in);
					(*weight) -= delta; 

				}
			}

			// propogate the expected value down the chain by 
			// recalculating the layer's output with the new weights
			expected = (*layer)->feedForward( layer_input );
		}

		return expected;
	}
Exemple #12
0
int main(int argc, char *argv[]) {
  Property config;
  config.fromCommand(argc,argv);

  Network yarp;
  Port client_port;

  std::string servername= config.find("server").asString().c_str();
  client_port.open("/demo/client");
  if (!yarp.connect("/demo/client",servername.c_str()))
  {
     std::cout << "Error! Could not connect to server " << servername << std::endl;
     return -1;
  }

  Demo demo;
  demo.yarp().attachAsClient(client_port);

  PointD point;
  point.x = 0;
  point.y = 0;
  point.z = 0;
  PointD offset;
  offset.x = 1;
  offset.y = 2;
  offset.z = 3;

  std::cout << "== get_answer ==" << std::endl;
  int answer=demo.get_answer();
  std::cout << answer << std::endl;

  std::cout<<"== add_one =="<<std::endl;
  answer = demo.add_one(answer);
  std::cout << answer << std::endl;

  std::cout<<"== double_down =="<<std::endl;
  answer = demo.double_down(answer);
  std::cout << answer << std::endl;

  std::cout<<"== add_point =="<<std::endl;
  point = demo.add_point(point,offset);
  std::cout<<("== done! ==\n");

  return 0;
}
Exemple #13
0
void test2() {
	using namespace Utility;
	using namespace std;
	using namespace ml;
	typedef double T;

	Timer<float> timer;
	timer.start();
	Network<T>* network = new Network<T>();
	ILayer<T>* l1 = new Layer<T>(100);
	ILayer<T>* l2 = new Layer<T>(200);
	ILayer<T>* l3 = new Layer<T>(500);
	ILayer<T>* l4 = new Layer<T>(10);
	l1->setName("L1");
	l2->setName("L2");
	l3->setName("L3");
	l4->setName("L4");
	network->setInputLayer(l1);
	network->connect(l1, l2);
	network->connect(l2, l3);
	network->connect(l3, l4);
	network->setOutputLayer(l4);
	network->init();

	ml::Mat<T> samples(100, 100, 1);
    ml::Mat<T> nominals(1, 10, 0); 
    network->train(samples, nominals);

	timer.stop();
	cout << timer.getTime() << endl;
}
Exemple #14
0
int main(int argc,char** argv){
  if (argc <= 1 || argc > 2)
  {
    std::cerr << "Please enter exactly one filename" << std::endl;
  }else
  {
    Network n;
    std::string file(argv[1]), name;
    std::stringstream sfile(file);
    std::getline(sfile,name,'.');
    name = name + ".ieq" ;
    
    n.init(argv[1]);
    n.findSequences();
    n.findSPC();
    n.findWPC();
    // n.printWPC();
    // n.printControlArcs();
    n.writePorta(name);
    name = "matrix";
    n.writeIncidenceMatrix(name);
    
  }
  
  return 0;
}
Exemple #15
0
/*
 * Modified from the Infomap implementation.
 * Reading the given network data in Pajek format.
 */
void load_pajek_format_network(string fName, Network &network) {

  string line;
  string buf;
  string nameBuf;
  
  /* Read network in Pajek format with nodes ordered 1, 2, 3, ..., N,            */
  /* each directed link occurring only once, and link weights > 0.               */
  /* For more information, see http://vlado.fmf.uni-lj.si/pub/networks/pajek/.   */
  /* Node weights are optional and sets the relative proportion to which         */
  /* each node receives teleporting random walkers. Default value is 1.          */
  /* Example network with three nodes and four directed and weighted links:      */
  /* *Vertices 3                                                                 */
  /* 1 "Name of first node" 1.0                                                  */
  /* 2 "Name of second node" 2.0                                                 */
  /* 3 "Name of third node" 1.0                                                  */
  /* *Arcs 4                                                                     */
  /* 1 2 1.0                                                                     */
  /* 1 3 1.7                                                                     */
  /* 2 3 2.0                                                                     */
  /* 3 2 1.2                                                                     */
  
  cout << "Reading network " << fName << " file\n" << flush;
  ifstream net(fName.c_str());
  network.setNNode(0);

  istringstream ss;
  while(network.NNode() == 0){ 
    if(getline(net,line) == NULL){
      cout << "the network file is not in Pajek format...exiting" << endl;
      exit(-1);
    }
    else{
      ss.clear();
      ss.str(line);
      ss >> buf;
      if(buf == "*Vertices" || buf == "*vertices" || buf == "*VERTICES"){
        ss >> buf;
        network.setNNode(atoi(buf.c_str()));
      }
      else{
        cout << "the network file is not in Pajek format...exiting" << endl;
        exit(-1);
      }
    }
Exemple #16
0
int main(int argc, char *argv[])
{
    Network yarp;
    if (!yarp.checkNetwork())
    {
        yError("YARP server not available!");
        return -1;
    }

    YARP_REGISTER_DEVICES(icubmod)

    ResourceFinder rf;
    rf.setVerbose(true);
    rf.configure(argc,argv);

    ServerModule mod;
    return mod.runModule(rf);
}
Exemple #17
0
Network *PerceptronModel::createNetwork(Episode *first_episode) const
{
    Network *network = new Network(first_episode->encodedStateSize());

    Dense *hidden = new Dense(_hidden_neurons, 1e-2);
    TanhActivation *hidden_activation = new TanhActivation;
    Dense *dense2 = new Dense(first_episode->valueSize(), 1e-2);

    hidden->setInput(network->inputPort());
    hidden_activation->setInput(hidden->output());
    dense2->setInput(hidden_activation->output());

    network->addNode(hidden);
    network->addNode(hidden_activation);
    network->addNode(dense2);

    return network;
}
Exemple #18
0
int main(int argc, char *argv[])
{

	YARP_REGISTER_DEVICES(icubmod)

																					Network yarp;

	if (!yarp.checkNetwork())
		return -1;

	ResourceFinder rf;

	rf.configure("ICUB_ROOT",argc,argv);

	objectMoverModule mod;

	return mod.runModule(rf);
}
Exemple #19
0
int main(int argc, char **argv)
{
    Network yarp;

    if( !yarp.checkNetwork() )
    {
        cout << "yarp server not found..." << endl;
        return 1;
    }

    ResourceFinder rf;
    rf.setVerbose(true);
    rf.configure(argc,argv);
    
    speechInteraction mod;

    return mod.runModule(rf);
}
Exemple #20
0
	Simulator::Simulator(Network & network, UDPConnection::Endpoint const & endpoint)
		: m_network(network)
		, m_connection(network.service(), boost::bind(&Simulator::packet_received, this, _1, _2), endpoint)
		, m_sequence(0)
		, m_name()
		, m_connected(false)
		, m_stats()
	{
	}
// Only for named networks
void flatten(MultipleNetwork& mnet, MNET_FLATTENING_ALGORITHM algorithm,
		Network& net) {

	std::set<global_vertex_id> vertexes;
	mnet.getVertexes(vertexes);
	std::set<global_vertex_id>::const_iterator v_it;
	for (v_it = vertexes.begin(); v_it != vertexes.end(); ++v_it) {
		net.addVertex(mnet.getVertexName(*v_it));
	}

	std::set<global_edge_id> edges;
	mnet.getEdges(edges);
	std::set<global_edge_id>::const_iterator e_it;
	for (e_it = edges.begin(); e_it != edges.end(); ++e_it) {
		if (! net.containsEdge(mnet.getVertexName((*e_it).v1),mnet.getVertexName((*e_it).v2)))
			net.addEdge(mnet.getVertexName((*e_it).v1),mnet.getVertexName((*e_it).v2));
	}
}
int main(int argc, char *argv[])
{
    Network yarp;

    if (!yarp.checkNetwork())
        return -1;

    ResourceFinder rf;
    rf.setVerbose(true);
    //the following lines could be nice if ever i put stuff in a config file.
//   rf.setDefaultContext("iLearnStuff/conf");
    //  rf.setDefaultConfigFile("iLearnStuff.ini");
    rf.configure("ICUB_ROOT",argc,argv);

    LearnerModule mod;

    return mod.runModule(rf);
}
Exemple #23
0
int main()
{
	Network yarp;
	if (!yarp.checkNetwork())
        return -1;

	PMPmodule myPMPmodule;

	ResourceFinder rf;
	rf.setVerbose(true); // print to a console conf info
	rf.setDefaultConfigFile("PMPundistorted.ini");
	rf.setDefaultContext("PMP_undistorted/conf"); // dove sono i file .ini
	rf.configure("ICUB_ROOT",0,NULL);

	myPMPmodule.runModule(rf);

	return 0;
}
Exemple #24
0
		Statistics calcStat(const Network& network) {
			Statistics stat;

			for (Network::IndexVector::const_iterator i = indices.begin(), last = indices.end(); i != last; ++i) {
				stat.accum(network.flux(*i));
			}

			return stat;
		}
Exemple #25
0
int main(void) {
    transport.setup(&io, &controller);
    controller.setup(&network, &transport);
    MICROFLO_LOAD_STATIC_GRAPH((&controller), graph);
    while (1) {
        transport.runTick();
        network.runTick();
    }
}
Exemple #26
0
int main(int argc, char *argv[]) 
{
    Network yarp;
    if (!yarp.checkNetwork())
    {
        printf("yarp network is not available!\n");
        return -1;
    }

    ResourceFinder rf;
    rf.setDefaultContext("imageSplitter");

    rf.configure(argc, argv);

    ImageFuser mod;
    return mod.runModule(rf);
    return 0;
}
Exemple #27
0
int main(int argc, char *argv[])
{
    Network yarp;
    if (!yarp.checkNetwork())
    {
        printf("yarp network is not available!\n");
        return -1;
    }

    ResourceFinder rf;
    rf.setVerbose(true);
    rf.setDefaultContext("keyboardBabbling");
    rf.setDefaultConfigFile("default.ini");
    rf.configure(argc,argv);

    keyboardBabbling mod;
    return mod.runModule(rf);
}
Exemple #28
0
/**
 * Initializes the layer given the reference network is a two mode
 * network.
 */
void DistanceTwoLayer::initializeTwoMode(const Network& rNetwork) {
	// this is a two mode network so we do not need to check for loops
	// nor do we have to store the reciever two paths.
	for (int i = 0; i < rNetwork.m(); ++i) {
		// construct all pairs
		for (IncidentTieIterator outerIter = rNetwork.inTies(i);
				outerIter.valid(); outerIter.next()) {
			int outerActor = outerIter.actor();
			// copy the iterator
			IncidentTieIterator innerIter(outerIter);
			// move to the next position
			innerIter.next();
			for (; innerIter.valid(); innerIter.next()) {
				modifyTieValue(outerActor, innerIter.actor(), 1);
			}
		}
	}
}
boolean ReceiverNode::initialize()
{
    const char *label;

    label = this->getLabelString();
    Network *net = this->getNetwork();
    EditorWindow *editor = net->getEditor();
    if (!net->isReadingNetwork() && editor) {
        TransmitterNode *tmtr = editor->getMostRecentTransmitterNode();
        if (tmtr)
            label = tmtr->getLabelString();
    }
    initializing = TRUE;
    this->setLabelString(label);
    initializing = FALSE;

    return TRUE;
}
Exemple #30
0
int main(int argc, char *argv[])
{
    Network yarp;
    if (!yarp.checkNetwork())
    {
        printf("YARP server not available!\n");
        return -1;
    }

    ResourceFinder rf;
    rf.setVerbose(true);
    rf.setDefaultContext("cameraAlign/conf");
    //rf.setDefaultConfigFile("cameraAlign.ini"); 
    rf.configure("ICUB_ROOT",argc,argv);

    CameraAlign cameraAlign;
    return cameraAlign.runModule(rf);
}