Domain Violation

Dear GamsWorld Group,

I have problems with sets,

I want to handle domain violations below gams code. I appreciate any help. Thanks in advance,

Nazmi
sets
u /120/
i(u) /1
10/
j /131/
sj(j) /1
30/
sn(j) /31/
k(u) /1120/
t /1
3/
st(t) /1*2/
sk(t) /2/
sx(t) /3/
sc(t) /1/
;

scalars
S /480/
;

parameters
A(k,sk)
d(i,sx)
e(k,sx)
cf
cv
;

A(k,sk)=uniformInt(0,1);
d(i,sx)=normal(25,15);
e(k,sx)=uniform(0,10);
cf=60;
cv=1;


binary variables
x(sj)
y(u,j,st);

positive variables
o(j,sx);

free variables
z1
z2
z3;

equations
obj1
eq1(i,sj,t)
eq2(i)
obj2
eq3(k,sj,sk)
eq4(k,sk)
eq5(k,sk)
eq6(k,sn,sk)
obj3
eq7(sj)
;
obj1… z1=e= sum(sj,cf*x(sj));
eq1(u,j,t)$sj(j)… y(u,j,t)=l=x(j);
eq2(i,st)… sum(sj,y(i,sj,st))=e=1;

obj2… z2=e= z3;
eq3(k,sj,sk)… y(k,sj,sk)=l=x(sj);
eq4(k,sk)… y(k,sn,sk)=l=1;
eq5(k,sk)… sum(j,y(k,j,sk))=e=1;
eq6(k,sn,sk)… A(k,sk)+y(k,sn,sk)=e=1;


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Hi Nazmi,

I hope that following 4 examples how differently you can use subsets will help you solve the problem.

SET
i “Original set” /13/
j(i) “Subset of the first two elements” /1
2/
;

VARIABLE
x(i) “Define this for the whole set i although you want to use it only on subset j”
y(j) “Define this directly as subset”
z(i) “Define this for the whole set i although you want to use it only on subset j”
w(i) “Define this for the whole set i although you want to use it only on subset j”
;

EQUATION
eqX(i) “Defined on the same set as X”
eqY(j) “Defined on the same set as Y”
eqZ(i) “Defined on the same set as Z”
eqW(j) “Defined on the different set as W”
;

  • eqX is defined on set i, so we use set i conditioning on j
    eqX(i)$(j(i)) … x(i) =L= 1;
  • eqY defined on j, so we can use j directly
    eqY(j) … y(j) =L= 1;
  • although eqZ is defined on set i, we can substitute with i’s subset j
    eqZ(j) … z(j) =L= 1;
  • although w is originally defined on set i, we can substitue with subset j
    eqW(j) … w(j) =L= 1;

Best regards,

Pavol

On Monday, 9 February 2015 09:56:56 UTC+1, Nazmi wrote:

Dear GamsWorld Group,

I have problems with sets,

I want to handle domain violations below gams code. I appreciate any help. Thanks in advance,

Nazmi
sets
u /120/
i(u) /1
10/
j /131/
sj(j) /1
30/
sn(j) /31/
k(u) /1120/
t /1
3/
st(t) /1*2/
sk(t) /2/
sx(t) /3/
sc(t) /1/
;

scalars
S /480/
;

parameters
A(k,sk)
d(i,sx)
e(k,sx)
cf
cv
;

A(k,sk)=uniformInt(0,1);
d(i,sx)=normal(25,15);
e(k,sx)=uniform(0,10);
cf=60;
cv=1;


binary variables
x(sj)
y(u,j,st);

positive variables
o(j,sx);

free variables
z1
z2
z3;

equations
obj1
eq1(i,sj,t)
eq2(i)
obj2
eq3(k,sj,sk)
eq4(k,sk)
eq5(k,sk)
eq6(k,sn,sk)
obj3
eq7(sj)
;
obj1… z1=e= sum(sj,cf*x(sj));
eq1(u,j,t)$sj(j)… y(u,j,t)=l=x(j);
eq2(i,st)… sum(sj,y(i,sj,st))=e=1;

obj2… z2=e= z3;
eq3(k,sj,sk)… y(k,sj,sk)=l=x(sj);
eq4(k,sk)… y(k,sn,sk)=l=1;
eq5(k,sk)… sum(j,y(k,j,sk))=e=1;
eq6(k,sn,sk)… A(k,sk)+y(k,sn,sk)=e=1;


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.