How do I set the values of a multidimensional parameter step by step (to implement a cutting plane approach)?

Problems with modeling
Post Reply
Avadrus
User
User
Posts: 1
Joined: 3 years ago

How do I set the values of a multidimensional parameter step by step (to implement a cutting plane approach)?

Post by Avadrus »

Hi everyone,

first of all: I am new to GAMS and have only worked with OPL/CPLEX before but was not required to switch languages due to preferences of my professor.
I am currently dealing with the task of implementing a cutting plane approach for solving an LP. This means that I
- solve a subproblem
- evaluate the results
- add a cutting plane (i.e. a constraint) to my problem
- loop until an ending condition is met.

I was able to implement a few simpler problems on my own, but am now struggling with this task. The problem is that I do not know how to define a parameter step by step.
I have defined a set

Code: Select all

Set
j
/j1 * j3/
parameter

Code: Select all

Parameter all_g(*, j);
that has two dimensions: the first dimensions is the number of the current iteration and the second dimension is the number of dimensions that my parameter that I compute in every iteration has. In every iteration I compute one

Code: Select all

Parameter g(j) Subgradient 
like this and count up the number of iterations passed in a variable, say

Code: Select all

Scalar k /1/;
and this scalar is incremented by 1 in each iteration.

What I need to do now is to add the computed single parameter g(j) to the "set of parameters" all_g(*,j) so what I'd like to do is something like

Code: Select all

all_g(k, j) = g(j);
in each iteration. However, I do not manage to get this kind of expression running, there's always a ton of errors turning up and the documentation is not really helpful at all.

Can anybody tell me what my mistake is or how I might implement such an iterative approach in GAMS?

Thanks in advance!
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: How do I set the values of a multidimensional parameter step by step (to implement a cutting plane approach)?

Post by Renger »

Hi
You could define a set i for the number of iterations. ALthough you don't know the maximum number of iterations, you can set it to a very high number, e.g.:

Code: Select all

set i Iterations /1*1000/
Then you can use your assignment as follows:

Code: Select all

parameter itnr Iteration number /0/;

while(...
itnr = itnr + 1;
....
all_g(k, j)$(ord(k) = itnr) = g(j);
I am not sure, if this is what you are looking for. Otherwise, just post your complete code and I have a look at it.
CHeers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Post Reply