Originally posted by: tjnelso
I have a model with multiple time periods and I receive some data in the format of a tupleset with a time dimension. Thus, the original tupleset is the superset of the tupleset required for each time period. I also have an array of integers which represent the time periods. In preprocessing, I need to iterative over this data separately for each time period, and only the data associated with that time period is relevant during this iteration, so I can reduce preprocessing time significantly by splitting the original tupleset into its subsets which are associated with each time period, and then iterative each of these independently during preprocessing.
In dat file:
timeSet = {1 2};
dataset = {
\\<attribute1, attribute2, time period>
<a,b,1>
<a,c,1>
<a,b,2>
<a,d,2>
};
In mod file:
{int} timeSet = ...;
tuple data {string attribOne; string attribTwo; int time;};
{data} dataset = ...;
I don't know ahead of time how many time periods there will be, so if I can't split up the tupleset on the fly, then I would need to do something like this:
execute{
for(var t in timeSet) {
for(var r in dataSet) {
if(r.Time == t) {
//call a function that executes on r
}
}
}
}
However, if I can split out dataSet into multiple tuples or arrays based on the value of the time field, then I could replace the above with something like the following:
execute{
for(var t in timeSet) {
for(var r in dataSetsCollection[t]) {
//call a function that executes on r
}
}
}
Since I would be working on dataSetsCollection[t] instead of dataSets there should be significantly less data to evaluate. Is it possible to create an item such as dataSetsCollection from the code above? I attempted to do so with a tuple:
tuple TdataSetsCollection {data row;};
{TdataSetsCollection} dataSetsCollection = {<ds> | ds in dataset : ds.Time = t};
and with an array:
tuple TdataSetsCollection {data row;};
TdataSetsCollection DataSetsArr[t in TimeSet] = [t : ds | ds in dataset, t in TimeSet : ds.Time == t];
Neither of the above worked so I'm not sure if this is possible. Please help if you can.
Thanks.
#DecisionOptimization#OPLusingCPLEXOptimizer