Originally posted by: SystemAdmin
[Didier Vidal said:]
Iikoryoko,
When I want to write an arbitrary dimension array into a database, I translate it before into a tupleset. Tuplesets are easier to export to a database.
See example of code below:
dvar float myValues[1..10][1..50][1..20];
maximize...
subject to {
...
}
// Here start the posprocessing code
tuple resultTuple {
key int i;
key int j;
key int k;
float value;
};
// The tupleset is created as follows
{resultTuple} myResult = {<i, j, k, myValues[i][j][k]> | i in 1..10, j in 1..50, k in 1..20};
// Sometimes, you may want to filter the output, for instance not exporting null values. You can do this as follow
{resultTuple} myFilteredResult = {<i, j, k, myValues[i][j][k]> | i in 1..10, j in 1..50, k in 1..20 : abs(<myValues[i][j][k]) > myEpsilon};
Hope this helps,
Didier.
#DecisionOptimization#OPLusingCPLEXOptimizer