示例#1
0
void Gene::crossover(gene_t_p * n){
  gene_t_p * t = get_random_node();
  gene_t_p sp = *t;
  *t = *n;
  *n = sp;
  return;
}
int get_param_nodeid(char *value, nodeid_t *node, nodeid_t myself) {
    if (strcmp(value, "random")) {
        *node = (nodeid_t) strtoll(value, NULL, 10);
    } else {
        *node = get_random_node(myself);
    }

    return 0;
}
示例#3
0
void justine::sampleclient::ShmClient::foo ( void )
{

  osmium::unsigned_object_id_type random_node = get_random_node();

  std::cout << random_node << std::endl;
  std::cout << num_edges ( random_node ) << std::endl;

}
示例#4
0
文件: tree.cpp 项目: kryonix/tetrisGP
Node* Tree::insert_random(Node* node, unsigned int max_depth, bool halframping)
{
   if( max_depth == 0 )
   {
      return new Node(node, mRandom.rnd(Operators::Piece, Operators::constant), mRandom.rnd(0, 10));
   }
   else
   {
      Node* new_node;
      new_node = get_random_node(halframping, mRandom.rnd(0,100));
      new_node->mNodeParent = node;

      int childs = 0;

      if(new_node->getOperator() == Operators::ifthen4)
      {
         childs = 4;
      }

      if(new_node->getOperator() >= Operators::add && new_node->getOperator() <= Operators::mul)
      {
         childs = 2;
      }

      if(new_node->getOperator() >= Operators::MoveLeft && new_node->getOperator() <= Operators::DoNothing)
      {
         childs = 1;
      }

      for(int i = 0; i < childs; i++)
      {
         new_node->insertChild(insert_random(new_node, max_depth-1, halframping));
      }

      return new_node;
   }
}
示例#5
0
void Gene::mutation(){
  gene_t_p * t = get_random_node();
  free_tree(*t);
  *t = get_random_tree();
  return;
}