Defining mappings or Convert Parameter values to string

Hello friends,

I have three sets and one variable and one equation of the form below:

set m /m1, m2, m3/;
set i /i1, i2/
set C(m,i) / m1.i1, m2.i2/;
set XR /1*10/;
P_X0(m, i, XR);
Equation eq1(m,i);
eq1(m,i) $(C(m,i)).. P_X0(m,i, o(m,i) ) = 1;

In the Gams code above, there is one thing not defined, namely o(m,i), I want to know how I can define o(m,i) to be a subset of XR. There come two possible options, I think:

  1. Defining o(m,i) to be a parameter, i.e.
parameter o(m,i) /m1.i1 3, m2.i2 10/;

However, this is not good , because 1 is not a string!
2. Defining o(m,i) as some kind of function from C to XR, mapping each (m,i) to ‘3’ or '10. I just don’t know how and what the syntax for it might be!

I would very much appreciate it if you could help me find a resolution.

Regards,
Amir

Hi, I think this can help you.

set m /m1, m2, m3/;
set i /i1, i2/
set C(m,i) / m1.i1, m2.i2/;
set XR /1*10/;
set
C_XR(m,i,XR)  /m1.i1.3, m2.i2.10/
;
P_X0(m, i, XR);
Equation eq1(m,i);
eq1(m,i,XR) $(C_XR(m,i,XR)).. P_X0(m,i,XR) = 1;

Anyway, there are other errors in the syntax.
Is the equation part of a model or is it an example? You can set the variable to 1 and that’s it (e.g. P_X0.fx(‘m1’,‘i1’,‘3’) =1;
Best!

Thank you very much. I didn’t think of that. It worked like a charm!
Cheers

1 Like