help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] lpx load matrix(lp,ne,ia,ja,ar)


From: Andrew Makhorin
Subject: Re: [Help-glpk] lpx load matrix(lp,ne,ia,ja,ar)
Date: Thu, 20 Oct 2005 12:19:10 +0400

> My ar[] array has many zero elements. I hope it is allowed. I am a bit
> confused 
> on the subject since the second argument (ne) apparently represents (doc.
> page 
> 21) the number of non-zero elements. Can anyone enlighten me what's going
> on? If 
> zero elements are not allowed then I see no way how I could apply this
> package 
> to my problem since my equations can only be written one way. Or should I
> cheat 
> and instead of using "0.0" use (say) "0.0000001" which is non-zero?

Do not replace zeros by a small number, this is a bad idea. Just
before call to lpx_load_matrix call the following routine:

int remove_zeros(int ne, int ia[], int ja[], double ar[])
{     int new_ne = 0, k;
      for (k = 1; k <= ne; k++)
      {  if (ar[k] != 0.0)
         {  new_ne++;
            ia[new_ne] = ia[k];
            ja[new_ne] = ja[k];
            ar[new_ne] = ar[k];
         }
      }
      return new_ne;
}

i.e. the calling sequence is the following:

. . .
ne = remove_zeros(ne, ia, ja, ar);
lpx_load_matrix(lp, ne, ia, ja, ar);
. . .





reply via email to

[Prev in Thread] Current Thread [Next in Thread]