### binary variable fixed value for 1 place - solution searched

Posted:

**Wed Aug 15, 2018 11:28 pm**Hi together,

Following a standard library model I like to add just 1 restriction. A binary variable for one factory shall be fixed on value 1 (=open).

I added "ow.fx(i) = 1;" (2nd last line) - that works. However if I like to name it "ow.fx(w1) = 1;" it ends in error. Than I get following error message:

ow.fx(w1) = 1;

**** $120,340,171

**** 120 Unknown identifier entered as set

**** 171 Domain violation for set

**** 340 A label/element with the same name exist. You may have forgotten

**** to quote a label/element reference. For example,

**** set i / a,b,c /; parameter x(i); x('a') = 10;[/i][/i]

Is there something wrong in my adaptations or do I need to define more?

Can someone support me, please. Thank you

Set

i 'speedfactory' / w1*w4 /

j 'regions' / r1*r9 /;

Parameter

f(i) 'fixed costs' / w1 130, w2 150, w3 170, w4 180 /

c(i) 'capacity' / w1 90, w2 110, w3 130, w4 150 /

d(j) 'demand' / r1 10, r2 10, r3 12, r4 15, r5 15

r6 15, r7 20, r8 20, r9 30 /;

Table t(j,i) 'transport costs'

w1 w2 w3 w4

r1 10 30 25 55

r2 10 25 25 45

r3 20 23 30 40

r4 25 10 26 40

r5 28 12 20 29

r6 36 19 16 22

r7 40 39 22 27

r8 75 65 55 35

r9 34 43 41 62;

Variable

totcost 'total cost'

fcost 'fixed cost'

tcost 'transportation cost'

ow(i) 'indicator for open speedfactory'

oa(i,j) 'indicator for open shipment arc speedfactory to region';

Binary Variable ow, oa;

Equation

deftotcost 'definition total cost'

deffcost 'definition fixed cost'

deftcost 'definition transportation cost'

defwcap(i) 'limit utilization of wspeedfactory by its capacity'

onew(j) 'only one speedfactory per region'

defow(i,j) 'speedfactory open if shipment from i to j';

deftotcost.. totcost =e= fcost + tcost;

deffcost.. fcost =e= sum(i, f(i)*ow(i));

deftcost.. tcost =e= sum((i,j), t(j,i)*oa(i,j));

defwcap(i).. sum(j, d(j)*oa(i,j)) =l= c(i);

onew(j).. sum(i, oa(i,j)) =e= 1;

defow(i,j).. ow(i) =g= oa(i,j);

ow.fx(i) = 1;

Model loc / all /;

Following a standard library model I like to add just 1 restriction. A binary variable for one factory shall be fixed on value 1 (=open).

I added "ow.fx(i) = 1;" (2nd last line) - that works. However if I like to name it "ow.fx(w1) = 1;" it ends in error. Than I get following error message:

ow.fx(w1) = 1;

**** $120,340,171

**** 120 Unknown identifier entered as set

**** 171 Domain violation for set

**** 340 A label/element with the same name exist. You may have forgotten

**** to quote a label/element reference. For example,

**** set i / a,b,c /; parameter x(i); x('a') = 10;[/i][/i]

Is there something wrong in my adaptations or do I need to define more?

Can someone support me, please. Thank you

Set

i 'speedfactory' / w1*w4 /

j 'regions' / r1*r9 /;

Parameter

f(i) 'fixed costs' / w1 130, w2 150, w3 170, w4 180 /

c(i) 'capacity' / w1 90, w2 110, w3 130, w4 150 /

d(j) 'demand' / r1 10, r2 10, r3 12, r4 15, r5 15

r6 15, r7 20, r8 20, r9 30 /;

Table t(j,i) 'transport costs'

w1 w2 w3 w4

r1 10 30 25 55

r2 10 25 25 45

r3 20 23 30 40

r4 25 10 26 40

r5 28 12 20 29

r6 36 19 16 22

r7 40 39 22 27

r8 75 65 55 35

r9 34 43 41 62;

Variable

totcost 'total cost'

fcost 'fixed cost'

tcost 'transportation cost'

ow(i) 'indicator for open speedfactory'

oa(i,j) 'indicator for open shipment arc speedfactory to region';

Binary Variable ow, oa;

Equation

deftotcost 'definition total cost'

deffcost 'definition fixed cost'

deftcost 'definition transportation cost'

defwcap(i) 'limit utilization of wspeedfactory by its capacity'

onew(j) 'only one speedfactory per region'

defow(i,j) 'speedfactory open if shipment from i to j';

deftotcost.. totcost =e= fcost + tcost;

deffcost.. fcost =e= sum(i, f(i)*ow(i));

deftcost.. tcost =e= sum((i,j), t(j,i)*oa(i,j));

defwcap(i).. sum(j, d(j)*oa(i,j)) =l= c(i);

onew(j).. sum(i, oa(i,j)) =e= 1;

defow(i,j).. ow(i) =g= oa(i,j);

ow.fx(i) = 1;

Model loc / all /;