## assign parameters in sequence Topic is solved

Problems with modeling
Bingo LI
User Posts: 15
Joined: 1 year ago

### assign parameters in sequence

Hello all,
I'm working on assigning a parameter in sequence. In my purpose, the sequence of the parameters is:
i=1
P_1= 13
i=2
P_1= 24
i=3
P_1= 15.

However. the result in my programm is
i=1
P_1= 13
i=2
P_1=1 13
2 24
i=3
P_1=1 13
2 24
3 15.

The code is attached. Could someone help me with this problem? thank you.
Attachments
Untitled_2.gms

Renger
Posts: 378
Joined: 3 years ago

### Re: assign parameters in sequence

Hi
You are assigning the value to a vector (P_1(ii)) and not to a scalar P_1=P_rec(ii). So,just replace P_1(ii) in your loop by P_1.
Cheers
Renger
____________________________________
Enjoy modeling even more: The lazy economist

Bingo LI
User Posts: 15
Joined: 1 year ago

### Re: assign parameters in sequence

However, a vector (P_1(ii)) is needed as there are other variables in my programm.
The purpose of this programm is that I want to eliminate P_1(1) when ii=2.
Could it be done?

Renger
Posts: 378
Joined: 3 years ago

### Re: assign parameters in sequence

Hi
I assume that after assigning the value to P_1(ii) you have some more code that uses the single-valued P_1(ii). You could do this by setting all the values to zero before you assign the single-value and set them after your additional code once again to zero.

Code: Select all

``````loop (ii,
P_1(ii) = 0;
subi(ii)=yes;
P_1(ii)=P_rec(ii);
* your other code using the P_1(ii) single value
display subi,P_1;
subi(ii)=no;
P_1(ii) = 0;
);
``````
This gives:

Code: Select all

``````1
----     27 PARAMETER P_1
1 13.000
----     27 SET subi
2
----     27 PARAMETER P_1
2 24.000
----     27 SET subi
3
----     27 PARAMETER P_1
3 15.000
``````
I hope this helps
Renger
____________________________________
Enjoy modeling even more: The lazy economist

Bingo LI
User Posts: 15
Joined: 1 year ago

### Re: assign parameters in sequence

Hi Renger,
It solves my problem perfectly.
Thank you.
Li