Re: Is this code correct in the GMPL implementation ?

Domingo Alvarez Duarte <[email protected]> Sat, 1 Aug 2020 11:26:53 +0200
Newsgroups gmane.comp.gnu.glpk
Message-ID <[email protected]>
Hello !

This is my fourth time trying to replace the actual TUPLE struct 
representation https://github.com/mingodad/GLPK/tree/new-tuple and I'm 
struggling again in understand/rewrite some parts of the code, mainly 
src/mpl/mpl3.c::saturate_set and other places.

I'm asking for help to try to fix/rewrite the missing pieces on it, I 
hope that this changes once corrected would give a reduction in memory 
usage and probably execution time for GMPL.

Thank you in advance for any help you can give !

Cheers !

On 25/7/20 14:51, Andrew Makhorin wrote:
> On Sat, 2020-07-25 at 13:35 +0200, Domingo Alvarez Duarte wrote:
>> Hello !
>>
>> Trying to change the actual TUPLE structure by:
>>
>> ====
>>
>> #ifndef TUPLE_SIZE_T
>> #define TUPLE_SIZE_T int
>> #endif
>> struct TUPLE
>> {
>>         TUPLE_SIZE_T size;
>>         TUPLE_SIZE_T refcount;
>>         SYMBOL sym[1];
>>         /* symbol, which the component refers to; cannot be NULL */
>> };
>>
>> ====
>>
>> I found the code bellow (in src/mpl/mpl3.c) that I'm not sure I
>> understand it,
>>
>> it seems that it's only testing the last tuple against
>> "code->arg.arg.y", shouldn't it be testing inside the loop for every
>> tuple ?
>>
>> I would appreciate someone could help understand this code !
>>
>> ====
>>
>> int is_member(MPL *mpl, CODE *code, const TUPLE *tuple)
>> {     int value;
>> ...
>>
>>            case O_CROSS:
>>               {  int j;
>>                  value = is_member(mpl, code->arg.arg.x, tuple);
>>                  if (value)
>>                  {  for (j = 1; j <= code->arg.arg.x->dim; j++)
>>                     {  xassert(tuple != NULL);
>>                        tuple = tuple->next;
>>                     }
>>                     value = is_member(mpl, code->arg.arg.y, tuple);
>>                  }
>>               }
>>               break;
>>
>> ====
>>
>> Cheers !
>>
>>
>>
> The routine is_member checks if the given n-tuple (specified by
> 'tuple') is a member of the given set (specified by 'code'). The check
> is performed recursively by traversing the set expression tree. For
> example, on evaluating the condition "... (x,y) in X cross Y ..." the
> routine will check that x is in X and y is in Y.
>
>
>