0

I have a tuple for reading a set of paths.

tuple Path {
int id;
string source;
string dest;
{string} pitblockSet;
{string} roadPoints; // not used
{string} dumpblockSet;
{string} others;
float dist;
};
{Path} Pbd= {} // a set read using into Pbd

There is another tuple blockType

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

{blockType} PitBlocksType = ...; This is read from excel..and the data looks 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

BlockBelow is defined as below.

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

I am using constraints such as the two below. But I am getting error. I want to have the sum of BlockBelow for all blocks in the pitblockSet as shown below. But I am making some mistake in accessing the pitblockSet in the tuple Pbd ( of type Path)

forall( i in Pbd.pitblockSet,  t in TimePeriods) { 
       // blockabove exposed Pbd:
        sum(j in BlockBelow[i]) schedulePit[j.id][t] * totalVolume[j.id] <= 
        (sum(j in BlockBelow[i],r in TimePeriods : r <= t,d in DumpBlocks)(Xbdt[j.id][d][r])  
        + sum(j in BlockBelow[i],r in TimePeriods : r <= t, s in Stockpiles)(Xbst[j.id][s][r]/density[j.id])
        +sum(j in BlockBelow[i],r in TimePeriods : r <= t, m in Plants)(Xbmt[j.id][m][r]/density[j.id]))  ;      
        }        



 forall(d in Pbd.dumpblockSet, t in TimePeriods) {   
  //DumpblocksBelow
  sum( b in PitBlocks,j in OnBelowDump[d],  r in TimePeriods: r<=t)(Xbdt[b][j.id][r]*SwellFactor)
 - scheduleDump[d.id][t]* sum(j in OnBelowDump[d])(dumpVolume[j.id]) >= 0;
   }

The error I get is : Expecting a tuple type, found {Path}.
Need suggestions please on how to access the pitblockSet or dumpblockSet in Pbd

Ranajit
  • 49
  • 6

1 Answers1

0

The statement

forall( i in Pbd.pitblockSet,  t in TimePeriods) 

looks wrong. According to your definition, Pbd is a set of paths, so it does not have a pitblockSet property. Only the elements in this set have this property.

I am not sure what youre trying to do here. If you want to have all paths that intersect a certain block type B you can use:

forall (p in Pbd : `B` in p.pitblockSet)

If you want a set with all block types you can form the union over all p.pitblockSet for all paths.

EDIT after you gave some clarification in the comments:

As far as I understand, your blockType is indexed by id. If that is true then I suggest to mark this as key:

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

If you do so, then you can get the block types and block ids below each path as follows:

{blockType} BlockTypeBelowPath[p in Pbd] = union(b in p.pitblockSet) BlockBelow[<b>];
{string} BlockIDBelowPath[p in Pbd] = { b.id | b in BlockTypeBelowPath[p] };
execute {
  writeln("BlockTypeBelowPath: ", BlockTypeBelowPath);
  writeln("BlockIDBelowPath: ", BlockIDBelowPath);
}
Daniel Junglas
  • 5,830
  • 1
  • 5
  • 22
  • Thank you Daniel for your response. Actually its part of a larger problem. pitBlockSet is a subset of a bigger set of blocks. Blocks Below exist for each block. I am trying to find that for all blocks in pitBlockSet the summation of these blocks over several variables. However blocksbleow has block Id and other items, where as pitBlockSet only has block Id. ..Sorry my understanding of OPL is limited. Could not get how to use the 'B' – Ranajit Mar 24 '20 at 13:27
  • I updated my answer. It would really help if you could give a fully worked out example: what is your input? what do you want to construct? how should the result look like? In particular the last point is not clear to me. – Daniel Junglas Mar 24 '20 at 14:15
  • Thank you Daniel. I have tried your edited suggestion, may be I am not doing it right. I have {blockType} BlockTypeBelowPath[p in Pbd] = union(b in p.pitblockSet) BlockBelow[]; and I get error on that line as Index out of bound for array "BlockBelow": <""> – Ranajit Mar 25 '20 at 10:11
  • That would mean that in some of the `pitblockSet` you have a value that does not exist in `BlockBelow`. Make sure that your data is consistent, maybe dump everything to screen to double-check. If you continue to have problems then maybe it is a good idea to start a new question (and close this one because I think the original question was ansered) in which you can show your current state of code. – Daniel Junglas Mar 25 '20 at 10:58