I am trying to solve a single model multiple times with different parameters. My parameters are c(j) and d(j). Their distributions are UNI(50,200) and UNI(20,200). In each iteration, I want to generate a value between those given values for each parameter based on uniform distribution. After defining the problem I created a loop to solve the problem iteratively. However, the problem keeps solving the same problem based on exactly the same parameters, the parameters do not change. I thought it is because I define the parameters before solving the next iteration and tried defining parameters inside the loop, but GAMS gives an error saying that it is not possible to make definitions inside a loop. What do you think I am doing wrong?

Edit: In addition, I want d(j) to take a value according to UNI(20,200) with 0.2 probability and 0 with 0.8 probability. Do you think it is also possible?

Hey, this is the model. The issue I am facing is finding the optimal solution gets increasingly slower in each iteration. While single iteration takes like 1 minute, 100 iteration takes 9-10 hours.

Sometimes it is useful to simply put your eyes on the data. In this case, to display and look at the c(j) and d(j) values in each pass of the loop. My guess is that you’ll see the d(j) filling up or becoming less sparse.

The assignment

d(j)$onoff(j) = uniform(20,200);

does the expected thing if d is zero, but when used in a loop, it does not. It assigns nonzero values to around 20% of d, but it doesn’t zero the other 80%. Since you do this in a loop, it gets fuller and fuller because nonzero values from previous loops are never set back to zero. You should probably use this one:

d(j) = uniform(20,200)$onoff(j);

which assigns every value of d: either to 0 or to uniform(20,200), as dictated by onoff(j).