0

I have a model reading data from an excel file. Below is part of the model.

I use the below code to read data as below

tuple blockType {
    string id;
    int i;
    int j;
    int k;
 };
 


{blockType} PitBlocksType = ...;

A snap shot of the data being read from excel is

Block Id    Bench(i)    Strip(j)    Block(k)
P52         1          5            3
P135        2          5            3
P210        3          5            3
P374        8          5            3
P487        9          5            3

The above is a selection of data filtered in excel for j=5 and k=3. Hence the Block Id is seen an contiguous. The Bench or i varies from 1 to 9 in the data. i, j, k represent data like in a 3D space where i is the vertical axis or z axis, and j and k represent in the x and y direction. As you can see in the sequence above i is present for 1-3 and missing from 4-7, then again present for 8 and 9 instead of being present for all 1 to 9..this is creating me problem.

I am running a piece of code in my model which assumes that i is continuous and hence my model fails for this above data. I want my model to be able to tackle this type of data as well. I was trying to see would a for - next loop be of help here..but I don't think so. What is the best way to handle this.

{blockType} OntopPit[b1 in PitBlocksType] =
     {b | b in PitBlocksType: b1.i == b.i +1 &&
                        ((b1.k  == b.k-1 ) ||
                         (b1.k  == b.k+1 ) ||
                         (b1.k  == b.k )  ) &&
                        ((b1.j  == b.j-1 ) ||
                         (b1.j  == b.j+1 ) ||
                         (b1.j  == b.j )  ) };

In the above part of the model I am using the b1.i == b.i +1 finds all i value, but sometimes the b.i +1 is not present in the data - as we saw in the above snapshot.

When a certain i is missing I want the code to consider the next i, say 4 is missing then look for 5, if 5 is also missing look for 6 and so on. I am not able to create this in the model.

Request for your suggestions please.

Ranajit
  • 49
  • 6

1 Answers1

1

Instead of +1 you could use next in a set:

tuple jk
{
  int j;
  int k;
}

{jk} jks={<5,3>};

{int} BenchPerjk[jks]=[{1,2,3,8,9}];

int succ3=next(BenchPerjk[<5,3>],3);

execute
{
writeln(succ3);
}

gives

8
halfer
  • 19,824
  • 17
  • 99
  • 186
Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15
  • Thank you Alex, that is very helpful. I will implement it. – Ranajit Jul 20 '20 at 12:21
  • Hi Alex, Sorry for pulling up this thread so late. I tried implementing this but there are some issue - can you please help me a little more on the two questions arising out of this...One how to filter the tuple data containing i, j, k for a particular combination of only i and j...Following this is an issue in implementing the Next command in my code. I am posting the in a new thread if you can please have a look. Thank you for your help. – Ranajit Sep 16 '20 at 03:44