Exemplo n.º 1
0
void LNLP::prepare_forecast()
{
    if(remake_vectors)
    {
        make_vectors();
        init_distances();
    }
    
    if(remake_targets)
        make_targets();
    
    if(remake_ranges)
    {
        set_indices_from_range(lib_indices, lib_ranges, (E-1)*tau, -std::max(0, tp), true);
        set_indices_from_range(pred_indices, pred_ranges, (E-1)*tau, -std::max(0, tp), false);

        check_cross_validation();

        which_lib = which_indices_true(lib_indices);
        which_pred = which_indices_true(pred_indices);
        
        remake_ranges = false;
    }
    
    compute_distances();
    return;
}
Exemplo n.º 2
0
void LNLP::set_time_series(const NumericVector data)
{
    time_series = as<std::vector<double> >(data);
    num_vectors = time_series.size();
    init_distances();
    return;
}
Exemplo n.º 3
0
void Xmap::set_block(const NumericMatrix new_block)
{
    size_t num_cols = size_t(new_block.ncol());
    block.resize(num_cols);
    num_vectors = size_t(new_block.nrow());
    for(size_t i = 0; i < num_cols; ++i)
    {
        block[i].resize(num_vectors);
        for(size_t j = 0; j < num_vectors; ++j)
            block[i][j] = new_block(j,i);
    }
    init_distances();
    return;
}
Exemplo n.º 4
0
/*
 * @brief		Main function to classify a collection (list of datasets)
 *
 * This function is the main call of the classification system. It takes a set of parameters and launch computations.
 *
 * @param       mParameter* Global parameters to apply for the system
 *
 */
void                    classifyCollection(mParameters *param)
{
    collection          *datasets;
    dataset             *current, *test;
    distances           *distanceSet;
    criteria            *criterias;
    char                *directories;
    int                 i;
    
    datasets = importCollection(param->collection, 0);
    if (datasets == NULL)
        return;
    criterias = init_criteria(1);
    distanceSet = init_distances(1);
    directories = calloc(1024, sizeof(char));
    for (i = 0; i < datasets->size; i++)
    {
        current = NULL;
        printf("Processing dataset : %s - %s\n", datasets->name[i], datasets->path[i]);
        // Preparing output directories
        sprintf(directories, "%s/%s", param->output, datasets->name[i]);
        umask(0); mkdir(directories, 0777);
        sprintf(directories, "%s/%s/distances", param->output, datasets->name[i]);
        umask(0); mkdir(directories, 0777);
        sprintf(directories, "%s/%s/optimize_distance", param->output, datasets->name[i]);
        umask(0); mkdir(directories, 0777);
        sprintf(directories, "%s/%s/optimize_criteria", param->output, datasets->name[i]);
        umask(0); mkdir(directories, 0777);
        sprintf(directories, "%s/%s/results", param->output, datasets->name[i]);
        umask(0); mkdir(directories, 0777);
        if (datasets->type[i] == TYPE_LOO || datasets->type[i] == TYPE_TRAIN)
            current = importRaw(datasets->path[i], datasets->name[i], NULL, 0);
        if (datasets->type[i] == TYPE_LOO_MULTI || datasets->type[i] == TYPE_TRAIN_MULTI)
            current = importRawMultiple(datasets->path[i], datasets->name[i]);
        if (current == NULL) { printf("Skipping.\n"); continue; }
        if (datasets->type[i] == TYPE_LOO)
            classifyDatasetLOO(current, distanceSet, criterias);
        if (datasets->type[i] == TYPE_LOO_MULTI)
            classifyDatasetLOO(current, distanceSet, criterias);
        if (datasets->type[i] == TYPE_TRAIN)
        {
            test = importRaw(datasets->path_test[i], datasets->name[i], current->class_vals, current->nb_classes);
            if (test == NULL) { printf("Skipping.\n"); continue; }
            optimizeDatasetTT(current, distanceSet, criterias, param);
            classifyDatasetTT(current, test, distanceSet, criterias, param);
        }
        freeDataset(current, datasets->type[i]);
    }
    free(directories);
}
Exemplo n.º 5
0
void run_testcase()
{
        int start_point;
        graph g;
        graph *graphptr = &g;

        initialize_graph(graphptr, false);
        read_graph(graphptr, false);
        initialize_search(graphptr);

        scanf("%d", &start_point);
        init_distances(start_point);

        bfs(graphptr, start_point);
        print_distances(graphptr, start_point);
}
Exemplo n.º 6
0
/** Fill residue bonds using the bond library. */
void mdt_fill_residue_bonds(struct mdt_residue_bond_list *bondlist,
                            const struct mdt_library *mlib,
                            const struct mod_libraries *libs)
{
  /* Consider only standard amino acids */
  const int n_std_restyp = 20;

  GHashTable *res_hash;

  /* Do nothing if the information is already populated */
  if (bondlist->nres > 0) {
    return;
  }

  res_hash = make_residue_types(bondlist, n_std_restyp, libs);
  make_atom_names(bondlist->bonds, mlib->atclass[1], res_hash);
  init_distances(bondlist);
  add_bonds(bondlist->bonds, mlib->atclass[1], res_hash);
  g_hash_table_destroy(res_hash);
  fill_distances(bondlist);
}