Error 171: Domain violation for set

Hello, I have implemented the following relationship in GAMS, but after running it, I receive the error “Domain violation for set” for Pchp(k, t, r). where is the problem?

k is defined as a set as follow:
/2.47, 0.0/
t represents a 24-hours time period.
r has 12 elements.

I would appreciate your guidance.

The variables pchp(t, r) cannot be defined at the same time over (K, T, R).

You need the create another variable such as pch(K, T, R) to be used on the right hand side of the equation.

This supposes that you have declared 3 sets upstream : K, T, R.

Thank you. I also tried your method, but it didn’t work, and it gives an error for the symbol k in the new variable. Could it be because k is defined as a set?

You can do this:

Set t /t1*t9/

r  /r1*r7/

k /k1*k14/
;

Parameter 
alpha(k, t, r)
;

alpha(k, t, r) = 2;

Variable
Pchp(t, r) 
Pch(k, t, r) 
;

Equation
E3_b(t, r) 
;

E3_b(t, r)..  Pchp(t, r) =e= sum(k, alpha(k, t, r)*Pch(k, t, r)) ;

It could be necessary to initialize the two variables. In that case you will need to create the corresponding parameter first that store the initial values.

Best regards