It is basically a constraint over a binary variable 'h' as;
retro(i) .. sum(tc, h(i,tc)) =l= 1;
It should run only once (means 'sum of h < 1'). Summation is working but this summation appears in every loop for "t" which is not required.
It is basically a constraint over a binary variable 'h' as;
Hi Renger!
Code: Select all
if(h(i) = 1; h.FX(i) = 1;);
Hi Renger,Renger wrote: ↑4 years ago Hi
I think you could do without t in H(i,t). Then, if in year x, H(i) becomes 1, you fix it to that level and it will stay like this in all t afterwards.CheersCode: Select all
if(h(i) = 1; h.FX(i) = 1;);
Renger
Dear Renger,Renger wrote: ↑5 years ago Hi
You should rewrite the set j from your model and treat the variables and parameters independent of j. Here an example:
In your case:Code: Select all
set j /1*2/; parameter p(j) Parameter defined over j, pj Scalar to be used in the loop to replace p; p(j) = ord(j); variable OBJ,X; equation objective, eq1; objective.. OBJ =E= x; eq1.. X=E= pj; model test /all/; loop(j, pj = p(j); solve test maximizing OBJ using nlp; );
becomesCode: Select all
sum(q,(w(q)**n)*(abs(p(j,q)-c('1',q)))**n))**in
and if p(j,g) is a parameter, it is now set in the loop asCode: Select all
sum(q,(w(q)**n)*(abs(pj(q)-c('1',q)))**n))**in
If p(j,g) is a variable, you define it as PJ(g) and save the result in a parameter results("p", j,g) = PJ.L(g);Code: Select all
pj(q) = p(j,g);
Your distance function then becomes L("1").
Hope this helps.
Cheers
Renger
Code: Select all
set t /1*5/
m /1*2/;
parameter a(m) /1 2,2 3/;
parameter b(m) /1 5,2 4.5/;
variables P(m,t),z;
parameter
am
bm
Pm;
loop(m,
am=a(m);
bm=b(m);
Pm(t)=P(m,t);
);
equation o1, c1, c2;
o1.. z=e=am*sum(t,Pm(t))+bm;
c1(t).. Pm(t) =l=5;
c2(t).. Pm(t) =g= 0;
model gg/all/
loop(m,
solve gg using lp minimizaing z;
);
Hello,
Code: Select all
set t /1*5/
m /1*2/;
parameter a(m) /1 2,2 3/;
parameter b(m) /1 5,2 4.5/;
variables Pm(t),z;
parameter am, bm, resultsm, resultsmt;
equation o1, c1, c2;
o1.. z =e= am*sum(t,Pm(t))+bm;
c1(t).. Pm(t) =l= 5;
c2(t).. Pm(t) =g= 0;
model gg /all/;
loop(m,
am = a(m);
bm = b(m);
solve gg using lp minimizaing z;
resultsmt(m,t, "PM") = PM.L(t);
resultsm(m, "z") = Z.L;
);
display resultsm, resultsmt;
Impressive!!! thanks you so much.Renger wrote: ↑3 years agoCheersCode: Select all
set t /1*5/ m /1*2/; parameter a(m) /1 2,2 3/; parameter b(m) /1 5,2 4.5/; variables Pm(t),z; parameter am, bm, resultsm, resultsmt; equation o1, c1, c2; o1.. z =e= am*sum(t,Pm(t))+bm; c1(t).. Pm(t) =l= 5; c2(t).. Pm(t) =g= 0; model gg /all/; loop(m, am = a(m); bm = b(m); solve gg using lp minimizaing z; resultsmt(m,t, "PM") = PM.L(t); resultsm(m, "z") = Z.L; ); display resultsm, resultsmt;
Renger