Hi there,
I am new to this forum, so I apologize if I make any mistake. I have searched for similar problems but have not managed to find a solution.
I have a model in which a decision variable is indexed by a tuple set, which I define in a .mod file:
//Define tuple tuple fvts { string F; string V; int T; string S; } //Declare tuple set {fvts} fvts_ = ...; //Declare decision variable dvar int+ sh[in fvts_];
In a separate .mod file, I have a flow control script in which I iteratively changes the upper bounds of N of these variables to 1. To select which variables are updated, a sub-problem (defined in yet another .mod file) is solved, and the decision variables are ranked according to a user-defined function which compares the results of the main model and the sub-model. To do so, I’m using the following script:
main { ... //main_model is the main model, m3 is the sub-model // Generate array of tuples from tuple set var list = new Array(); var j = 1; for (var i in main_model.fvts_) { list[j] = i; j++; } // Order array of tuples according to the value a user-defined function list.sort(compareFactor); //Update the upper-bound of the top N variables for (var l = 1; l <= N; l++) { var s = main_model.fvts_.find(list[l]); main_model.sh[s].UB = 1; } ... }
The list is successfully ordered as expected. However, the problem is that at the second iteration of the second loop, I get the error "OPL cannot extract expression: sh#231.". I have isolated this error to the "main_model.sh[s].UB" part, since the "main_model.fvts_.find(list[l])" behaves as expected. However, I know that the decision-variable with that tuple as index exists, and I am not able to access it.
Any ideas on what may causing this error and how to fix it?
Thanks in advance for any help!
Cheers,
Guilherme