You could introduce a flag like this
Parameter flag(i);
Flag(i) = 1;
loop(i$flag(i),
Lamda(i)=max(0,Lamda(i)+Schrittweite*(sum(l,d*q.l(i,l))-QM(i)*sq.l));
display Lamda;
epsilon=schrittweitesum(iii,smax(ii,abs(sum(l, dq.l(i,l))-QM(i)*sq.l)));
display epsilon;
if( epsilon o, then the alpha(i) should be calculated, for example, in the first iteration lambda(2)=1500, then just alpha(2) should be calculated and in the next iteration i=2 should be eliminated( for example there are i /1,2,3/ and for the next Iteration we just have to consider i/1,3/). i hope i’ve explain it clearly, thank you for you time.
在 2015å¹´10月7日,12:03,Renger van Nieuwkoop 写é“:
Hi Yu
I still don’t get what you exactly want with alpha. If I run the model, I get Lambdas at the end equal to 0 and 375. These values are used for the calculation of alpha.
(Lambda going from 0 → 250 → 0 for L1 and from 0 ->1125 → 1125 → 375)
Cheers
Renger
Von: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] Im Auftrag von Yu Li
Gesendet: Mittwoch, 7. Oktober 2015 11:37
An: gamsworld
Betreff: Re: how to fit this problem
Hi Renger,
thank you for your consideration. Actually i receive the Lambda which i need from this codes:
if(d>0,
loop(Iteration$Fortsetzung,
option optcr=0;
solve ladual using minlp minimizing Umfang;
display q.l;
Schrittweite=Schrittweite/ord(iteration);
loop(i,
Lamda(i)=max(0,Lamda(i)+Schrittweite*(sum(l,d*q.l(i,l))-QM(i)*sq.l));
display Lamda;
epsilon=schrittweitesum(iii,smax(ii,abs(sum(l, dq.l(i,l))-QM(i)*sq.l)));
if( epsilon 0;
integer Variable q;
binary variable y;
Equations
LR Lagrange-Relaxation
NB1 gesamte Bestellmenge
NB2(i,l) Untergrenze von Bestellmenge
NB3(i,l) Obergrenze von Bestellmenge
NB4(i) Eindeutigkeit ;
LR… Umfang =e= sum((i,l),P(i,l)q(i,l)d/sq + (lzP(i,l)+2(d*Lamda(i)- sum(ii,Lamda(ii)QM(ii)))) q(i,l)/2 + K(i)*y(i,l)*d/sq);
NB1… sq =e= sum((i,l),q(i,l));
NB2(i,l)… q(i,l) =g= QU(i,l)*y(i,l) ;
NB3(i,l)… q(i,l) =l= QO(i,l)*y(i,l) ;
NB4(i)… sum(l,y(i,l))=l=1;
Model Ladual /LR,NB1,NB2,NB3,NB4/ ;
Set Iteration /iter1*iter10/;
scalar Fortsetzung /1/;
scalar epsilon;
Parameter Schrittweite;
Schrittweite=1;
Parameter alpha(i);
Parameter Ergebnis(iteration,);
sq.lo=1;
Lamda(i)=0;
if(d>0,
loop(Iteration$Fortsetzung,
option optcr=0;
solve ladual using minlp minimizing Umfang;
display q.l;
Schrittweite=Schrittweite/ord(iteration);
loop(i,
Lamda(i)=max(0,Lamda(i)+Schrittweite*(sum(l,d*q.l(i,l))-QM(i)*sq.l));
display Lamda;
epsilon=schrittweitesum(iii,smax(ii,abs(sum(l, dq.l(i,l))-QM(i)*sq.l)));
if( epsilon 0
sqq Entscheidungsvariable
Kosten Gesamtkosten;
sqq.lo=1;
integer Variable qq;
binary variable z;
Equations
cost Gesamtkosten
NB5(i) Nebenbedingung
NB6(i) Eindeutigkeit
NB7(i,l) Untergrenze von Bestellmenge
NB8(i,l) obergrenze von Bestellmenge
NB9(i) Maximale Liefermenge;
cost… Kosten =e= sum(i,(alpha(i)d+ (alpha(i)lz)/2sqq) sum(l,P(i,l)*z(i,l)) +K(i)*d/sqq);
NB5(i)$(Lamda(i)>=0)…sqq=g=QU(i,“R1”)/alpha(i);
NB6(i)$(Lamda(i)>=0)…sum(l,z(i,l))=l=1;
NB7(i,l)$(Lamda(i)>=0)…qq(i,l) =g= QU(i,l)*z(i,l);
NB8(i,l)$(Lamda(i)>=0)…qq(i,l) =l= QO(i,l)*z(i,l);
NB9(i)$(Lamda(i)>=0)…sum(ll,qq(i,ll))=e=alpha(i)*sqq;
model Subgradienten /cost,NB5,NB6,NB7,NB8,NB9/;
sqq.lo=1;
option optcr=0;
solve Subgradienten using minlp minimizing Kosten;
display qq.l,sqq.l;
在 2015å¹´10月7日星期三 UTC+2上åˆ9:31:20,Renger van Nieuwkoop写é“:
Hi Yu
I don’t see how you get the optimal lambda from your loop, so I assumed the following: the optimal lambda is the maximum of all lambdas:
Parameter lambda_opt;
Loop(…
…
Lambda_opt = smax(i, lambda(i));
….
alpha(i)$(lambda(i) =lambda_opt) = QM(i)/d;
);
If you intend to have just one alpha calculated, I would define alpha as alpha_opt without index i.
Cheers
Renger
Von: gams...@googlegroups.com [mailto:gams...@googlegroups.com] Im Auftrag von Yu Li
Gesendet: Dienstag, 6. Oktober 2015 17:07
An: gamsworld
Betreff: how to fit this problem
Dear All,
i need your help!
By Using the loop operation i receive the optimal lamda(i), for example i=2, then i want to calculate alpha(i)=QM(i)/d for just i=2, how should it to be done? i attach my code. In my code are the alpha for all of the i calculated. Can anyone help? thank you in advance!
loop(i,
Lamda(i)=max(0,Lamda(i)+Schrittweite*(sum(l,d*q.l(i,l))-QM(i)*sq.l));
display Lamda; c
epsilon=schrittweitesum(iii,smax(ii,abs(sum(l, dq.l(i,l))-QM(i)*sq.l)));
if( epsilon <1,
display “converged”;
Fortsetzung=0;
);
alpha(i)= QM(i)/d;
d=d-QM(i);
);
display alpha;
);
\
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.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
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.
–
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.