thanks Glynn, I'll try it soon!
gianluca
Glynn Clements ha scritto:
gianluca massei wrote:

thank you for interesting about mcda. I need help and suggest for
better coding!

- Yes, r.mcda.electre, r.mcda.regime use
G_alloc_matrix((nrows*ncols),(nrows*ncols)) with related memory
problem. I'm looking for a better algorithm, especially for pairwise
comparison that need large matrix ((nrows*ncols),(nrows*ncols)) for
derive concordance and discordance matrix. Now I don't find it but I'
still looking for. Could you give me a suggest ?.
Is this a sparse matrix? Or do you actually store a value for every
possible combination?

How is the resulting matrix used? If you don't need repeated, random
access, it would be better to calculate the values as they are
required instead of storing them.
I need matrix for storage a pairwise comparison pixel to pixel for generate an index for each row/colum an re-generate the output grid. For avoid the problem I'm tinking storage the value in a file... but It dosen't a smart solution.

Looking at the code, it would appear that you don't need to store the
entire matrix, only the row/column sums. Something like the following
(untested):

void build_dominance_matrix(int nrows, int ncols, int ncriteria,
                            double *weight_vect, double ***decision_vol)
{
    int row1, col1, row2, col2;
    int i, j, k, cont;
    double *row_sum_conc = G_alloc_vector(nrows * ncols);
    double *col_sum_conc = G_alloc_vector(nrows * ncols);
    double *row_sum_disc = G_alloc_vector(nrows * ncols);
    double *col_sum_disc = G_alloc_vector(nrows * ncols);

    k = 0;                      /* make pairwise comparation and build 
concordance/discordance matrix */
    for (row1 = 0; row1 < nrows; row1++) {
        G_percent(row1, nrows, 2);
        for (col1 = 0; col1 < ncols; col1++) {
            j = 0;
            for (row2 = 0; row2 < nrows; row2++) {
                for (col2 = 0; col2 < ncols; col2++) {
                    double conc = 0, disc = 0;
                    for (i = 0; i < ncriteria; i++) {
                        double d = decision_vol[row1][col1][i] - 
decision_vol[row2][col2][i];
                        if (d >= 0)
                            conc += weight_vect[i];
                        if (d > conc)
                            disc = -d;
                    }
                    row_sum_conc[k] += conc;
                    col_sum_conc[j] += conc;
                    row_sum_disc[k] += disc;
                    col_sum_disc[j] += disc;

                    j++;        /* increase rows index up to nrows*ncols */
                }
            }
            k++;                /* increase columns index up to nrows*ncols */
        }
    }

    /*calculate concordance and discordance index and storage in decision_vol */
    cont = 0;                   /*variabile progressiva per riga/colonna della 
concordance_map */
    for (row1 = 0; row1 < nrows; row1++) {
        G_percent(row1, nrows, 2);
        for (col1 = 0; col1 < ncols; col1++) {
            /* da un valore incrementale ad ogni ciclo per progredire nella 
concordance_mat */
            decision_vol[row1][col1][ncriteria] = row_sum_conc[cont] - 
col_sum_conc[cont];      /*fill matrix with concordance index for each DCELL */
            decision_vol[row1][col1][ncriteria + 1] = row_sum_disc[cont] - 
col_sum_disc[cont];  /*fill matrix with discordance index for each DCELL */
            cont++;
        }
    }
}

------------------------------------------------------------------------


Database dei virus interno non c aggiornato.
Controllato da AVG - http://www.avg.com Versione: 8.0.175 / Database dei virus: 270.8.4/1752 - Data di rilascio: 28/10/2008 10.04


_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to