but I do nor understand your code:
Code: Select all
set t /1*1440/ ; alias(t,tp,tpp); binary variable x(t) y(t) ; variable z ; equation eq1,eq2,eq3,eq4,eq5,eq6,eqobj ; eq1(t,tp).. sum(tpp$(ord(tpp) le ord(t)),x(tpp)) =l= ord(tp) + (1-xpos(tp,t))*1440; eq2(t,tp).. sum(tpp$(ord(tpp) le ord(t)),x(tpp)) =g= ord(tp) - (1-xpos(tp,t))*1440; eq3(tp).. sum(t,xpos(tp,t)) =l= 1; *same for y eq4(t,tp).. sum(tpp$(ord(tpp) le ord(t)),y(tpp)) =l= ord(tp) + (1-ypos(tp,t))*1440; eq5(t,tp).. sum(tpp$(ord(tpp) le ord(t)),y(tpp)) =g= ord(tp) - (1-ypos(tp,t))*1440; eq6(tp).. sum(t,ypos(tp,t)) =l= 1; eqobj.. z =e= sum(tp, sum(t,xpos(tp,t)*ord(tp)) - sum(t,ypos(tp,t)*ord(tp)));
1) xpos(tp,t) and ypos(tp,t) are not declared in your model description. They are only unsed in the equations. Is it not necessary to define them?
2) Basically I have to admit that I do not understand much of your code and I am confused (I spend many hours trying to understand). What are eq1, eq2 and eq3 ensuring? On the left side of eq1 and eq2 your are counting the number of times x(t)=1 until t. But on the right side you are using tp which I don't understand. When xpos(tp,t) =0, eq1 and eq2 ensure that the sum equals ord(tp). Let's say tp=1000 and t is any number (lets say t=1010) and xpos(tp,t)=1, then eq1 and eq2 - according to my understandig - force the sum of x(t)=1 for t in [0,..., 1005] to be 1000. That means that x(t) is almost always 1. But when I have constraints that forbid something like this there will not be a feasible solution.
3) I guess I have to insert equations for every timeslot and every binary variable, meaning that I have to insert - taking your suggestion - at least 4*1440 = 5760 equations manually. This is also not really doable for me. It would take a fairly long time and there will surely be mistakes in several of those equations which I'll not be able to find.
I know that this question is a fairly difficult one. But I at least want to try to solve it. This is why I really appreciate your input (and the inputs of others)