I did not spot anything obvious, hence one would need more to see what’s going on. We would need some example (so one can reproduce) that shows that you get a change when doing this outside the loop versus no change with the loop. If the objective change is small between scenarios, make sure you have set optcr to 0 (default is 0.1) to really get the global optimal solution.
-Michael