Originally posted by: TracyLLL
Hi There
I am working on the main block for flow control to do the following:
1. In each iteration, use a vector with only one element =1 and other elements =0, i.e. UDC[i in 1..3], in iteration 1: UDC=[1 0 0], iteration 2: UDC=[0 1 0]...to run the optimization model to get some results.
2. After all iterations, only some of iterations yeild good results. I want to store UDC of each of the good iterations in a new vector, which could be the sum of these good UDC. e.g. if UDC=[0 1 0] and UDC[0 0 1] are good, UDCnew[i in 1..3]=[0 1 1]
3. Use UDCnew to run one last time the model to get a final result.
Note that the whole process involves the same .mod and .dat files, i.e., thisOplModel. I tried defining UDC and UDCnew by accessing the same opl model. But found that the two variables always contains the same elements, no matter what (I guess when UDC and UDCnew are pointing to the same model object, every time I change any one of them, the object has been changed, so does the other variable).
I know I can achieve what I want through defining UDCnew by pointing it to a second OPL model. But since the second model would be exactly the same as the master model, this way doesn't look concise. I was wondering if there is a better alternative.
I also tried to define a vector or array in the main block, but couldn't find a proper way. Does OPL allow defining a vector or array variable in script blocks? How?
Thanks!
#DecisionOptimization#OPLusingCPLEXOptimizer