0

I have a tuple called blockType

tuple blockType {
    key string id;
    int i;
    int j;
    int k;
 };
{blockType} PitBlocksType =…; \\read from excel

A snapshot of the data is like below

P1  1   1   2
P2  1   1   3
P3  1   1   4
P4  1   1   5
P5  1   1   6
P6  1   1   7
P7  1   1   8
P8  1   1   9
P9  1   1   10
P10 1   1   11

And another tuple

tuple Path {
int id;
string source;
string dest;
{string} pitblockSet;
{string} roadPoints; // not used
{string} dumpblockSet;
{string} others;
float dist;
};

{Path} Pbd is read from excel and the data looks as below:

PathId  Source  Destination pitBlockSet Road    DumpBlockSet         Others Distance
1       P1      D1         P1           R8       D45 D42 D39 D14 D1         581.3956
2       P1      D1         P1           R8       D40 D14 D1                 587.1185
3       P1      D1         P1           R8       D43 D16 D2 D1              588.7774
4       P2      D1         P2 P44       R8       D45 D42 D39 D14 D1         539.7307

In this case my particular interest is on pitBlockSet which just contains the id of the blockType, it can have one or more Ids like P1 P23 etc . I need to create a set which is of type {blockType}, and has the ids from pitBlockSet of Path and the rest of it from pitBlocksType. So it is an union of Path.pitBlockSet and of PitBlocksType.

I tried the following options :

{blockType} PitBlocksInPath[p in Pbd] = union(b in p.pitblockSet) PitBlocksType [<b>];

The errors I get is :

Not an array type 

Is this a syntax error or it should not be union

Ranajit
  • 49
  • 6

1 Answers1

0

As the error message indicates, the problem is that PitBlocksType is not an array. It is a set. You can turn this into an array, to fix the error. If that is not an option then instead of PitBlocksType[<b>] you can write something like {b2 | b2 in PitBlockType : b2.id == n}, i.e., explicity create the singleton set of blocks that have id b.

Daniel Junglas
  • 5,830
  • 1
  • 5
  • 22