Originally posted by: K__U
Hi,
I defined a tuple in my master problem (outside the main script):
tuple sub_prob_tup {
string dc;
{string} demand;
}
{sub_prob_tup} sub_prob_control;
I would like to update (add) my sub problem solutions to this master tuple with below line in the main script:
thisOplModel.sub_prob_control.add(opl3.sub_prob_control_tmp);
Additionally, in the sub model the elements are defined as below:
{string} DC=...;
{string} Demand_N=...;
tuple sub_prob_tup {
string dc;
{string} demand;
}
{sub_prob_tup} sub_prob_control_tmp;
string tmp1 = first(DC);
execute{
sub_prob_control_tmp.add(tmp1,Demand_N);
writeln("sub_prob_control_tmp:", sub_prob_control_tmp)
};
The sub tuple seems to be OK, and it's giving me the results that I want, but the problem is I cannot update the master tuple.
I have other tuples which I can add with the same method, but this master is not working. (It is deleting previously added elements, deleting the sets etc.)
Is it related to set {} type that I am using? Any suggestions?
>>>>>
I added my results and tried to explain the problem:
First iteration everything seems to be OK:
opl3.sub_prob_control_tmp >>>
{<"6037" {"6019" "6029" "6037" "6059" "6065" "6071" "6073" "6111" "32003"}>}
thisOplModel.sub_prob_control >>>
{<"6037" {"6019" "6029" "6037" "6059" "6065" "6071" "6073" "6111" "32003"}>}
In the second iteration sub problem solution:
opl3.sub_prob_control_tmp >>>
{<"4013" {"4013" "4019"}>}
While I was expecting the main tuple as below:
thisOplModel.sub_prob_control >>>
{<"6037" {"6019" "6029" "6037" "6059" "6065" "6071" "6073" "6111" "32003"}>
<"4013" {"4013" "4019"}>}
it returns:
thisOplModel.sub_prob_control >>>
{<"6037" {"4013" "4019"}> <"4013" {"4013" "4019"}>}
First element is added properly (dc) however second element {demand} is updated in both.
This problem is continuing for all iterations. (it adds dc properly but replaces all {demand} with the latest added one)
Thanks,
#DecisionOptimization#OPLusingCPLEXOptimizer