Dear Henry,
I done your advice for ‘division by zero’ eror and ıts run but now I have a new problem
I calculate some parameters under parameters tittle than I want to use this calculated parameters in equation than It done a lot of iteration (610 iteration) but not find feasible solution.After than I try to write this equation any sample number, model fınd some feasible solution.Can I use parameters in equation which is calculated in model?(ı Gave these Situation below here)
Situation 1: caused to ınfeasible solution
Parameters A(i,k,r) ;
A(i,k,‘1’) = floor(b(k,‘1’)/w(i,‘1’))* floor(b(k,‘2’)/w(i,‘2’))* floor(b(k,‘3’)/w(i,‘3’));
A(i,k,‘2’) = floor(b(k,‘1’)/w(i,‘1’))* floor(b(k,‘3’)/w(i,‘2’))* floor(b(k,‘2’)/w(i,‘3’));
A(i,k,‘3’) = floor(b(k,‘3’)/w(i,‘2’))* floor(b(k,‘2’)/w(i,‘1’))* floor(b(k,‘1’)/w(i,‘3’));
A(i,k,‘4’) = floor(b(k,‘1’)/w(i,‘2’))* floor(b(k,‘2’)/w(i,‘1’))* floor(b(k,‘3’)/w(i,‘3’));
A(i,k,‘5’) = floor(b(k,‘1’)/w(i,‘2’))* floor(b(k,‘2’)/w(i,‘3’))* floor(b(k,‘3’)/w(i,‘1’));
A(i,k,‘6’) = floor(b(k,‘3’)/w(i,‘1’))* floor(b(k,‘2’)/w(i,‘2’))* floor(b(k,‘1’)/w(i,‘3’));
e1(i,k,r)… C(i,k)=g=A(i,k,r)*y(i,k)
Situation 2 : gives some solution
e1(i,k)… C(i,k)=g= 10*y(i,k)
** ‘10’ sample number
Thanks for your help and your times again…
2013/2/21 Henry JW Vermue
Dear AyÅŸe,
For reasons I’d like to keep to myself (putting them into words would result in a 2 pages’ response), I think it’s not the bigM constraint. Though I
Have you tried to initialize Amax? Adding this line would do that:
regards,
Henry
PS I’m sorry for misspelling your name before.
On Thursday, February 21, 2013 9:01:11 AM UTC+1, ayse kthnc wrote:
Dear Henry,
I tried your Big M advice but gams gives me “division by zero” eror because Amax(i,k) will be 0 and I want to prevent e3 from this case with using a condition.(ıf y(i,k)=0 ,Amax(i,k)=0 and ı want equation3 is not active ) As your opinion am I thinking wrong?
And in Your other advice ı gave me a adress to prevent Big M eror .I tried this too. So I’m a new user and I have never used Gams with CPLEX before. Colud you give me a link how can I use gams with CPLEX ?
Kind regards,
AyÅŸe
2013/2/18 Henry JW Vermue
Dear Ayse,
How about an either-or (or big-M) combination of equations? This works very well with inequalities (as you are using it for). [And since you’re already using an MINLP, so it won’t make the problem comparitively harder to solve.]
How to do it: I hope you already know, since it’s quite widespread on the internet. The idea is relatively simple, you multiply the big M with y (or (1-y)) and define M in such a way that the inequality is trivial (i.e. always fulfilled) if y has the value of 1 (or 0).
So in your case:
e3(i,k)$(y(i,k) eq 1)…S(i,k)=g=floor(d(i)/Amax(
i,k));
should be:
e3(i,k) … S(i,k)=g=floor(d(i)/Amax(
i,k)) - M*(1-y(i,k));
Now, the only thing you need to do is to find a suitable value for this M, usually that’s the maximum value the other side of the inequality sign can get or an arbitrarily large number. In either case, it is advisable to choose something smaller than 1000.
Kind regards,
Henry Vermue
If I may add a small part: From what I can see (and I might be wrong on this), it is interesting how this MINLP is defined. If you use a slightly different formulation for A(i,k,r) and declare it as it should be (so as a parameter and not as a variable), and remove equation 5 you might reduce the simulation time quite significant as well.
On Monday, February 18, 2013 10:13:33 AM UTC+1, ayse kthnc wrote:
Thanks Dileep ,
I define d(i) in parameters, in my knowledge “floor(x) is a mathematical function and it returns the greatest integer number less than or equal to x”
and in my model y(i,k) is a binary variable and I want to this;
if this binary variable is 1 gams calculate equation3 else its 0 this equation not calculate
how can write this code on gams??
thanks again to your intrest
2013/2/18 Dileep Damayyawar
Dear Ayse,
As per my knowledge we can use on sets, Parameters and variables not on equations. So remove that eq 1 and where you defined floor(d(i) variable?
e3(i,k)(y(i,k) eq 1)…S(i,k)=g=floor(d(i)/Amax(i,k));
–
Regards
Dileep Damayyawar
On 18 February 2013 02:40, ayse kthnc wrote:
Hello! I’m son new in Gams , ı write my gams code but it dosent work and give this eror message “endogenous $-control operations not allowed”
ı will give my code here
my problem is in equation 3 I want to work this equation ıf binary variable “y=1” this eqution will calculate else “y=0” it won’t calculate this equation
sets
i parcalar /120/
k bloklar /18/
r alternatifler /16/
t boyut /13/
variable
A(i,k,r) i
Amax(i,k)
z
binary variable
y(i,k)
integer variable
S(i,k) i parcasının talebinin karsılanması icin gerekli k blok adedi
Positive variable
F(i)
parameters
d(i) talep
/1=75,
2=100,
3=20,
4= 50,
5 =200,
6 =70,
7 =20,
8 =32,
9 =51,
10= 62,
11 =65,
12 =64,
13 =25,
14 =180,
15 =322,
16 =60,
17 =326,
18 =250,
19= 142,
20 =82/;
table w(i,t) i. parca boyutları
1 2 3
1 118 58 7
2 118 58 4
3 138 78 7
4 138 68 4
5 128 68 7
6 66 46 1
7 199 149 5
8 199 179 5
9 175 70 6
10 196 80 6
11 199 119 5
12 199 99 5
13 186 136 7
14 196 146 7
15 200 158 4
16 65 55 7
17 190 160 7
18 200 150 7
19 128 78 4
20 70 40 3;
table b(k,t) k. blok boyutları
1 2 3
1 120 200 75
2 140 190 75
3 150 200 75
4 160 200 75
5 180 200 75
6 180 190 75
7 200 200 75
8 200 240 75;
equations
obj
alt1(i,k) alternatif kesim planları
alt2(i,k)
alt3(i,k)
alt4(i,k)
alt5(i,k)
alt6(i,k)
e1(i,k,r) k.blogun i. parca icin max cıktı sayısını verir
e2(i) 1 i parcası k blogundan kesiliyorsa aksi halde 0
e3(i,k) kesilecek blok optimize eden
e4(i) fire hesaplama
e5(i) fire sıfıra büyük eşit olmalı
e6(i) toplam kesim miktarı talebi karsılamalı ;
obj … z=e=sum(i,F(i)) ;
alt1(i,k)… A(i,k,‘1’) =e= floor(b(k,‘1’)/w(i,‘1’))* floor(b(k,‘2’)/w(i,‘2’))* floor(b(k,‘3’)/w(i,‘3’));
alt2(i,k)… A(i,k,‘2’) =e= floor(b(k,‘1’)/w(i,‘1’))* floor(b(k,‘3’)/w(i,‘2’))* floor(b(k,‘2’)/w(i,‘3’));
alt3(i,k)… A(i,k,‘3’) =e= floor(b(k,‘3’)/w(i,‘1’))* floor(b(k,‘2’)/w(i,‘2’))* floor(b(k,‘1’)/w(i,‘3’));
alt4(i,k)… A(i,k,‘4’) =e= floor(b(k,‘1’)/w(i,‘2’))* floor(b(k,‘2’)/w(i,‘1’))* floor(b(k,‘3’)/w(i,‘3’));
alt5(i,k)… A(i,k,‘5’) =e= floor(b(k,‘1’)/w(i,‘2’))* floor(b(k,‘2’)/w(i,‘3’))* floor(b(k,‘3’)/w(i,‘1’));
alt6(i,k)… A(i,k,‘6’) =e= floor(b(k,‘3’)/w(i,‘1’))* floor(b(k,‘2’)/w(i,‘2’))* floor(b(k,‘3’)/w(i,‘1’));
e1(i,k,r)… Amax(i,k)=g=A(i,k,r)*y(i,k);
e2(i)… sum(k,y(i,k))=e=1;
e3(i,k)$(y(i,k) eq 1)…S(i,k)=g=floor(d(i)/Amax(i,k));
e4(i)… sum(k, y(i,k)S(i,k)(b(k,‘1’)*b(k,‘2’)*b(k,‘3’)-w(i,‘1’)*w(i,‘2’)*w(i,‘3’)*Amax(i,k)))=e=F(i);
e5(i)… F(i)=g=0;
e6(i)… sum(k,S(i,k)*Amax(i,k)*y(i,k))=g= d(i);
option limrow=160;
model sunger/all/
solve sunger using minlp minimizing z;
display z.l,y.l,F.l;
thanks for your intrest
–
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
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.
\