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.
assign parameters in sequence Topic is solved
assign parameters in sequence
- Attachments
-
- Untitled_2.gms
- (445 Bytes) Downloaded 248 times
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
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: Read my blog on modeling at The lazy economist
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Re: assign parameters in sequence
Thanks for your answer.
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?
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?
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.
This gives:
I hope this helps
Renger
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;
);
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
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Re: assign parameters in sequence
Hi Renger,
It solves my problem perfectly.
Thank you.
Li
It solves my problem perfectly.
Thank you.
Li