Topic
  • 4 replies
  • Latest Post - ‏2014-05-22T13:58:16Z by BLAIS
BLAIS
BLAIS
22 Posts

Pinned topic Extracting efficiently multiple sub-tupleset from a unique tupleset

‏2014-05-01T15:44:45Z |

In want to know if there exist an efficient way to extract different sub tupleset from one unique tupleset. Below here is the inefficient implementation. I want to create four tuplesets (relAPH, relDEM, relACP and relVEP) from the tupleset relDonneesIntrants that contain all the data.

 

setof(rvDonneesContinuesIntrants) relDonneesIntrants= ... ;

//APH

setof(rvMvtEau) relAPH= { <espSource,espDestination,pas,valeur> | <variante, espSource,espDestination,pas,typedonnee,0,valeur> in relDonneesIntrants : typedonnee=="APH"&& variante==prmVariante[0]};

//DEM

setof(rvMvtEnergieClasse) relDEM= { <espSource,espDestination,pas,classe,valeur> | <variante, espSource,espDestination,pas,typedonnee,classe,valeur> in relDonneesIntrants : typedonnee=="DEM"&& variante==0};

//ACP

setof(rvMvtEnergieClasse) relACP= { <espSource,espDestination,pas,classe,valeur> | <variante, espSource,espDestination,pas,typedonnee,classe,valeur> in relDonneesIntrants : typedonnee=="ACP"&& variante==0};

//VEP

setof(rvMvtEnergieClasse) relVEP= { <espSource,espDestination,pas,classe,valeur> | <variante, espSource,espDestination,pas,typedonnee,classe,valeur> in relDonneesIntrants : typedonnee=="VEP"&& variante==0};

In want to know if there exist an efficient way of extraction different sub tupleset from one unique tupleset. Below here is the inefficient implementation. I want to create four tupleset (relAPH, relDEM, relACP and relVEP) from the tupleset relDonneesIntrants that contain all the data.

 

setof(rvDonneesContinuesIntrants) relDonneesIntrants= ... ;

//APH

setof(rvMvtEau) relAPH= { <espSource,espDestination,pas,valeur> | <variante, espSource,espDestination,pas,typedonnee,0,valeur> in relDonneesIntrants : typedonnee=="APH"&& variante==prmVariante[0]};

//DEM

setof(rvMvtEnergieClasse) relDEM= { <espSource,espDestination,pas,classe,valeur> | <variante, espSource,espDestination,pas,typedonnee,classe,valeur> in relDonneesIntrants : typedonnee=="DEM"&& variante==0};

//ACP

setof(rvMvtEnergieClasse) relACP= { <espSource,espDestination,pas,classe,valeur> | <variante, espSource,espDestination,pas,typedonnee,classe,valeur> in relDonneesIntrants : typedonnee=="ACP"&& variante==0};

//VEP

setof(rvMvtEnergieClasse) relVEP= { <espSource,espDestination,pas,classe,valeur> | <variante, espSource,espDestination,pas,typedonnee,classe,valeur> in relDonneesIntrants : typedonnee=="VEP"&& variante==0};

Updated on 2014-05-01T15:46:19Z at 2014-05-01T15:46:19Z by BLAIS
  • AlexFleischer
    AlexFleischer
    1729 Posts
    ACCEPTED ANSWER

    Re: Extracting efficiently multiple sub-tupleset from a unique tupleset

    ‏2014-05-21T09:51:14Z  
    • BLAIS
    • ‏2014-05-06T20:04:25Z

    Your right, but this didn't resolve my problem. I cut some useless information from the example:

     

    setof(rvDonneesContinuesIntrants) relDonneesIntrants= ... ;

    //APH

    setof(rvMvtEau) relAPH= { <espSource,espDestination,pas,valeur> | <variante, espSource,espDestination,pas,typedonnee,0,valeur> in relDonneesIntrants : typedonnee=="APH};

    //DEM

    setof(rvMvtEnergieClasse) relDEM= { <espSource,espDestination,pas,classe,valeur> | <variante, espSource,espDestination,pas,typedonnee,classe,valeur> in relDonneesIntrants : typedonnee=="DEM"};

    //ACP

    setof(rvMvtEnergieClasse) relACP= { <espSource,espDestination,pas,classe,valeur> | <variante, espSource,espDestination,pas,typedonnee,classe,valeur> in relDonneesIntrants : typedonnee=="ACP"};

    //VEP

    setof(rvMvtEnergieClasse) relVEP= { <espSource,espDestination,pas,classe,valeur> | <variante, espSource,espDestination,pas,typedonnee,classe,valeur> in relDonneesIntrants : typedonnee=="VEP"};

     

    What I want to know is how can I split a tupleset in 4 tupleset in one step. The above code read and filter 4 times the same tupleset and this is time consuming.

     

    MB

    Hi,

    to do the split in one step, I suggest the use of generic indexed array.

    Example:

    tuple t
    {
      int a;
      string name;
    }

    {t} s={<1,"1">,<2,"3">,<3,"3">};

    int rank[s]= [ i : ((i.name=="1")?1:(i.name=="2")?2:3) | i in s ];

    {t} s2[k in 1..3]={ i | i in s : rank[i]==k};

    execute
    {
      writeln(s2);
    }

     

    which gives [{<1 "1">} {} {<2 "3"> <3 "3">}]

     

    regards

  • AlexFleischer
    AlexFleischer
    1729 Posts

    Re: Extracting efficiently multiple sub-tupleset from a unique tupleset

    ‏2014-05-01T19:23:06Z  

    Hi,

     

    instead of using 3 times setof(rvDonneesContinuesIntrants) relDonneesIntrants, why do not you build the subset of this set with variante==0 and then you use this subset ?

    regards

  • BLAIS
    BLAIS
    22 Posts

    Re: Extracting efficiently multiple sub-tupleset from a unique tupleset

    ‏2014-05-06T20:04:25Z  

    Hi,

     

    instead of using 3 times setof(rvDonneesContinuesIntrants) relDonneesIntrants, why do not you build the subset of this set with variante==0 and then you use this subset ?

    regards

    Your right, but this didn't resolve my problem. I cut some useless information from the example:

     

    setof(rvDonneesContinuesIntrants) relDonneesIntrants= ... ;

    //APH

    setof(rvMvtEau) relAPH= { <espSource,espDestination,pas,valeur> | <variante, espSource,espDestination,pas,typedonnee,0,valeur> in relDonneesIntrants : typedonnee=="APH};

    //DEM

    setof(rvMvtEnergieClasse) relDEM= { <espSource,espDestination,pas,classe,valeur> | <variante, espSource,espDestination,pas,typedonnee,classe,valeur> in relDonneesIntrants : typedonnee=="DEM"};

    //ACP

    setof(rvMvtEnergieClasse) relACP= { <espSource,espDestination,pas,classe,valeur> | <variante, espSource,espDestination,pas,typedonnee,classe,valeur> in relDonneesIntrants : typedonnee=="ACP"};

    //VEP

    setof(rvMvtEnergieClasse) relVEP= { <espSource,espDestination,pas,classe,valeur> | <variante, espSource,espDestination,pas,typedonnee,classe,valeur> in relDonneesIntrants : typedonnee=="VEP"};

     

    What I want to know is how can I split a tupleset in 4 tupleset in one step. The above code read and filter 4 times the same tupleset and this is time consuming.

     

    MB

  • AlexFleischer
    AlexFleischer
    1729 Posts

    Re: Extracting efficiently multiple sub-tupleset from a unique tupleset

    ‏2014-05-21T09:51:14Z  
    • BLAIS
    • ‏2014-05-06T20:04:25Z

    Your right, but this didn't resolve my problem. I cut some useless information from the example:

     

    setof(rvDonneesContinuesIntrants) relDonneesIntrants= ... ;

    //APH

    setof(rvMvtEau) relAPH= { <espSource,espDestination,pas,valeur> | <variante, espSource,espDestination,pas,typedonnee,0,valeur> in relDonneesIntrants : typedonnee=="APH};

    //DEM

    setof(rvMvtEnergieClasse) relDEM= { <espSource,espDestination,pas,classe,valeur> | <variante, espSource,espDestination,pas,typedonnee,classe,valeur> in relDonneesIntrants : typedonnee=="DEM"};

    //ACP

    setof(rvMvtEnergieClasse) relACP= { <espSource,espDestination,pas,classe,valeur> | <variante, espSource,espDestination,pas,typedonnee,classe,valeur> in relDonneesIntrants : typedonnee=="ACP"};

    //VEP

    setof(rvMvtEnergieClasse) relVEP= { <espSource,espDestination,pas,classe,valeur> | <variante, espSource,espDestination,pas,typedonnee,classe,valeur> in relDonneesIntrants : typedonnee=="VEP"};

     

    What I want to know is how can I split a tupleset in 4 tupleset in one step. The above code read and filter 4 times the same tupleset and this is time consuming.

     

    MB

    Hi,

    to do the split in one step, I suggest the use of generic indexed array.

    Example:

    tuple t
    {
      int a;
      string name;
    }

    {t} s={<1,"1">,<2,"3">,<3,"3">};

    int rank[s]= [ i : ((i.name=="1")?1:(i.name=="2")?2:3) | i in s ];

    {t} s2[k in 1..3]={ i | i in s : rank[i]==k};

    execute
    {
      writeln(s2);
    }

     

    which gives [{<1 "1">} {} {<2 "3"> <3 "3">}]

     

    regards

  • BLAIS
    BLAIS
    22 Posts

    Re: Extracting efficiently multiple sub-tupleset from a unique tupleset

    ‏2014-05-22T13:58:16Z  

    Hi,

    to do the split in one step, I suggest the use of generic indexed array.

    Example:

    tuple t
    {
      int a;
      string name;
    }

    {t} s={<1,"1">,<2,"3">,<3,"3">};

    int rank[s]= [ i : ((i.name=="1")?1:(i.name=="2")?2:3) | i in s ];

    {t} s2[k in 1..3]={ i | i in s : rank[i]==k};

    execute
    {
      writeln(s2);
    }

     

    which gives [{<1 "1">} {} {<2 "3"> <3 "3">}]

     

    regards

    Thank you for your answer. This was what I was looking for.