Hi Renger,

Thanks for the reminder. Now it works fine. Since previously I used “positive variable” for the variables such as “XH”, “AH” etc. Now I used “XH.lo=0 and XH.up=+inf”, it seems that the optimal result from GAMS for these two ways of restricting variables are different with each other ( the difference is within 10% variance). Is this normal?

On Monday, January 28, 2013 4:20:34 AM UTC-5, Renger van Nieuwkoop wrote:

Hi Mark

Be aware, that if you solve within a loop, all your variables that were fixed in the previous loops are still fixed. I donâ€™t know, if that is what you want. If not, you should free them again, by setting the lower and upper bound accordingly (eg. XH.lo(â€¦.) = -INF or 0 (if a positive variable) and XH.UP(â€¦) = +INF.

Cheers

Renger

From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Mark Wang

Sent: Montag, 28. Januar 2013 03:53

To: gams...@googlegroups.com

Subject: Re: dynamic sets as constraint for variable. Thanks a lot!!

Hi Renger,

Can I ask you another question.

I used a do-loop command with the dynamic set constraint as follows:

loop(j,

Theta1(i,b)=theta(i,j,b);

XH.fx(i,m,crop,b)$dynamic(i,j)=0;

AH.fx(i,m,crop,b)$dynamic(i,j)=0;

XTN.fx(i,m,crop,b)$dynamic(i,j)=0;

XTO.fx(i,m,crop,b,t)$dynamic(i,j)=0;

NXS.fx(i,m,crop,b,t)$dynamic(i,j)=0;

XS.fx(i,m,crop,b,t)$dynamic(i,j)=0;

Solve Ethanol Minmizing COST USING MIP;

CostL(j) = Cost.l;

);

I basically fixed all the flow variables in the model to be within the distance constraint. For example, XH is the weight of feedstock and AH is the area of land used to produce the feedstock. This decreased memory and fastened the model significantly.

However I also used the “big fictive numbers” approach you suggested to make comparison. There are 82 loops in total however only the first 7 loops had identical results. After 7 loops, the optimal cost of the “dynamic constraint” one were getting bigger and bigger compared with the "fixed fictive numberâ€œ one, and it exited on the 15th loop showing “equation infeasible due to rhs value”.

Do you think it is because I set to many constraint in the do-loop command?

display costL;

On Friday, January 25, 2013 10:30:23 AM UTC-5, Renger van Nieuwkoop wrote:

Hi Mark

If you want to constrain something, shouldnâ€™t it be the flows from I to j where the distance is bigger than 30 and not the supply node itself, because this node might be connected to jâ€™s that are not farther away than 30 units.

I donâ€™t see any flows in your model. X(i) is the total supply from node I, which probably should be equal to the sum over all flows from this node to all connected nodes

Cheers

Renger

Von: gams...@googlegroups.com [mailto:gams...@googlegroups.com] Im Auftrag von Mark Wang

Gesendet: Freitag, 25. Januar 2013 16:14

An: gams...@googlegroups.com

Betreff: Re: dynamic sets as constraint for variable. Thanks a lot!!

Hi Renger,

Thanks a lot for your reply. Actually I have ready tried the method of imposing a fictive large number. The reason why I want to try this dynamic set method is that when I use a this model for my thesis, there are more than 8000 entries for i dimension and more than 200 entries for j dimension. Again I have to consider other constraints in my model so it takes a long time to solve the model. I think maybe by imposing x(i) from supply regions further way to be fixed at 0, the model will solve faster.

Do you think I can impose some constraint like x.fx(i)$(dist(i,j)>30)=0 ? or a dimension j is still needed?

On Thursday, January 24, 2013 4:21:58 PM UTC-5, Mark Wang wrote:

Greetings. There is a simple model to choose a optimal site out of 7 candidates to build a factory. I want to add a constraint that only those within the distance of 30 of the candidate can be selected as supply region by x.fx(i$dd(i,j))=0; However it does not work. Anyone can give me some advice? The detailed model is below:

set i 30 feedstock supply regions /1*30/

j 7 candidates to build the factory /j1*j7/;

table dist(i,j) distance between i and j

$include distance.inc;

parameter supply(i) feedstock supply from each supply region

/

1 14

2 35

3 11

4 24

5 44

6 42

7 17

8 24

9 12

10 17

11 34

12 22

13 27

14 43

15 10

16 45

17 50

18 15

19 14

20 32

21 17

22 31

23 10

24 24

25 18

26 33

27 37

28 33

29 18

30 47/;

scalars

demand minimal demand from factory /200/

unitcost travel cost per unit /5/;

variable

x(i) number of units from supply i

z total cost

dummy(j) dummy variable;

positive variable x;

binary variable d;

equations

meetdemand

meetsupply(i)

definecost

plantnumb only one out of the 7 candidates is selected

;

set dd(i,j);

dd(i,j)=(dist(i,j)>=30);

display dd;

*only supply regions which is within the distance of 30 can be used…

x.fx(i$dd(i,j))=0;

meetdemand… sum(i,x(i))=g=demand;

meetsupply(i)… x(i)=l=supply(i);

definecost… sum(j,sum(i,unitcost*dist(i,j)*x(i))*d(j))=e=z;

plantnumb… sum(j,d(j))=e=1;

model trial /all/;

option MIP=CPLEX ;

## solve trial using minlp minimizing z;

display x.l,z.l,d.l;

\

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?hl=en.

For more options, visit https://groups.google.com/groups/opt_out.

\