Hi odow,
Your code indeed improves the speed a lot. I really appreciate it. However, there is a glitch in function solve_lower_bound
. After I add the following code, the speed is basically the same as my original code, is there another way to write this code?
if has_upper_bound(model_lb[:lambda_sum][i, j])
delete_upper_bound(model_lb[:lambda_sum][i, j])
end
if has_lower_bound(model_lb[:lambda_sum][i, j])
delete_lower_bound(model_lb[:lambda_sum][i, j])
end
Without the above code, it solves 10 problem for N=500 in 9 seconds, after I add the above code, the time is nearly doubled. I am not sure why the new code will take so much time.
The reason I need the above code is as follows. For one iteration, it puts bounds on all lambda_sum[i_lb, j_lb]
except for lambda_sum[i, j]
. In the next iteration, say that we are going to solve for W[i',j']
, so that there should be no bounds on W[i',j']
. However, the bounds put on W[i',j']
in the previous iteration are still there. Therefore, I add the following codes to clear bounds before the for-loop in function solve_lower_bound
.