Clear variables and parameters to perform a loop

Problems with syntax of GAMS
Post Reply
SapperDoc
User
User
Posts: 13
Joined: 4 years ago

Re: Clear variables and parameters to perform a loop

Post by SapperDoc »

The parameters won't change because they are... parameters... unless you modify them within the loop.

As for the variables, just reset their levels to zero to affect a cold start.

For example...

x.l=0;
y.l=0;
Fred
Posts: 372
Joined: 7 years ago

Re: Clear variables and parameters to perform a loop

Post by Fred »

Hi,

It is hard to guess why you experience problems with your code without being able to reproduce such problems.

In general, if you solve a MIP to optimality (i.e. you have to set the termination criterion accordingly, e.g. optcr=0), the objective function value should be the same. The solution can be different though because there may be multiple optimal solutions. If you obtain a different solution to some models depending on whether you solve them in a loop with all 54 instances or standalone, I would expect that something must be different. That can be for example a different start point (if you instruct the MIP solver to use it) or a parameter value (which might result in a different model).

As I wrote in the beginning. If you want target-oriented help, please share an executable example that allows other forum users to reproduce what you are doing.

Best,
Fred
Fred
Posts: 372
Joined: 7 years ago

Re: Clear variables and parameters to perform a loop

Post by Fred »

Hi,

If you generate the exact same model and pass it with the exact same starting point to the exact same solver and use the exact same options on the exact same machine, you should get the same behavior.
If you think you do all that but get a different behavior, please share your code, so other users can reproduce what you are doing.

Best,
Fred
Post Reply