Identify parameter as computable

Hello,

I’m writing my master thesis about the “vehicle routing problem with pickup and delivery and time windows” and I am trying to realise my model in GAMS.

  1. In order to get the time the truck arrives at a knot, I used the parameter w(i,k) which isn’t given in the beginning but can be computed through the other parameters. The formula says: (binary variable)(time of arrival at knot i + service time + transporting time - time of arrival at following knot j)=0.
    In GAMS: x(i,j,k)
    (w(i,k)+1.75+t(i,j)-w(j,k))=e=0; and to arrive between the earliest and latest possible time at the knot: a(i)=l=w(i,k) and w(i,k)=l=b(i). If I just write it down like this and define w(i,k) as a parameter I get “error 66: symbol shown has not been defined or assigned” after the solve statement. I get also an error if I define w(i,k) as a variable. I couldn’t find any command in the handbook or web or so to tell GAMS it should compute the parameter. Is there a command or something to tell GAMS that it should compute w(i,k)? If no, do you have any idea how to define w(i,k)?

  2. I also got the same problem with the load on the truck. The truck can be either empty or full, so l(i,k) is binary. It should be computed, so that the load before knot j is exactly the demand of knot j. After visiting knot j the truck is empty again. In GAMS: x(i,j,k)*(l(i,k)+d(j)-l(j,k))=e=0.

Thank you very much for your help,
Julia

\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/z6dE74sWWtMJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Hi Julia



If w(i,k) is a result of the model equations it should be a variable. If w(I,k) is a parameter, it should be initialized before you run the model.

What is the error, if you use a variable for w(I,k)?

Cheers

Renger



Von: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] Im Auftrag von Julia
Gesendet: Wednesday, October 24, 2012 8:23 AM
An: gamsworld@googlegroups.com
Betreff: Identify parameter as computable



Hello,



I’m writing my master thesis about the “vehicle routing problem with pickup and delivery and time windows” and I am trying to realise my model in GAMS.


\

  1. In order to get the time the truck arrives at a knot, I used the parameter w(i,k) which isn’t given in the beginning but can be computed through the other parameters. The formula says: (binary variable)*(time of arrival at knot i + service time + transporting time - time of arrival at following knot j)=0.

In GAMS: x(i,j,k)(w(i,k)+1.75+t(i,j)-w(j,k))=e=0; and to arrive between the earliest and latest possible time at the knot: a(i)=l=w(i,k) and w(i,k)=l=b(i). If I just write it down like this and define w(i,k) as a parameter I get “error 66: symbol shown has not been defined or assigned” after the solve statement. I get also an error if I define w(i,k) as a variable. I couldn’t find any command in the handbook or web or so to tell GAMS it should compute the parameter. Is there a command or something to tell GAMS that it should compute w(i,k)? If no, do you have any idea how to define w(i,k)?



2. I also got the same problem with the load on the truck. The truck can be either empty or full, so l(i,k) is binary. It should be computed, so that the load before knot j is exactly the demand of knot j. After visiting knot j the truck is empty again. In GAMS: x(i,j,k)
(l(i,k)+d(j)-l(j,k))=e=0.



Thank you very much for your help,

Julia


\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/z6dE74sWWtMJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Hi Renger,


It is not a variable because I don’t need the result. I just need w(i,k) and l(i,k) to arrive within the time window and to fullfill the demand.

If I use them as variable the error ist “error 56: endogenous operands for * not allowed in linear models” after the solve statement. The model is definitely linear and mixed integer programming. Therefore I used the mip-solver.

regards,

Julia


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/B4fkNWKRbMIJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

I am no Mip expert but perhaps you should post your model do somebody can have a look
Renget

Sent from my iPhone

On 24.10.2012, at 15:41, “Julia” wrote:

Hi Renger,

It is not a variable because I don’t need the result. I just need w(i,k) and l(i,k) to arrive within the time window and to fullfill the demand.

If I use them as variable the error ist “error 56: endogenous operands for * not allowed in linear models” after the solve statement. The model is definitely linear and mixed integer programming. Therefore I used the mip-solver.

regards,

Julia


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/B4fkNWKRbMIJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

This is the typical VRPDDTW how it is in journals and books.

$title the vehicle routing problem with pickup and delivery and time windows

sets

i costumers

k trucks ;

alias (i,j)

$include …



parameters

t(i,j) travelling time

a(i) earliest time of arrival

b(i) latest time of arrival

w(i,k) time of arrival at knot i

w(j,k) time of arrival at knot j

l(i,k) truck load after knot i

l(j,k) truck load after knot j

d(j) demand at knot j

s(i) service time at knot j



variables

x(i,j,k) knot i is visited right after knot j by the truck k

z travelling time

binary variable x;



equations

time

arriveknot(i)

leaveknot(j)

start(i)

end(j)

arrival(i,j,k)

timeearly(i,k)

timelate(i,k)

order(i,j,k)

loadbinary(i,k)

loaddemand(i,j,k)

emptyback(i,k)

;

  • minimise the travelling time

time … z=e=sum((i,j,k)$(ord(i) ne ord(j)),(t(i,j)*x(i,j,k)) ;

*arrive at every knot once but the depot

arriveknot(i) … sum((j,k)$(ord(i) ne ord(j) and not ord(j)=1),x(i,j,k)) =e=1 ;

  • leave every knot once but the depot

leaveknot(j) … sum((i,k)$(ord(i) ne ord(j) and not ord(i)=1) ,x(i,j,k)) =l= 1;

  • all trucks must start and end at the depot

start(i) … sum((j,k),x(‘depot’,j,k)) =e= 6;

end(j) … sum((i,k),x(i,‘depot’,k)) =e= 6 ;

  • compute the time of arrival through the arrival at knot i, service time and travelling time

arrival(i,j,k) … (x(i,j,k))*(w(i,k)+s(i)+t(i,j)-w(j,k))=l= 0 ;

  • fullfill the wish of the costumer to arrive within a time window

timeearly(i,k) … a(i)=l=w(i,k) ;

timelate(i,k) … w(i,k)=l=b(i) ;

*pickup the load before the delivery

order(i,j,k) … w(i,k)+t(i,j)=l=w(j,k) ;

  • the load ist binary/ the truck can be full or empty

loadbinary(i,k) … l(i,k)=l=1 ;

*the pickup load is exactly the amount of the demand at knot j

loaddemand(i,j,k) … x(i,j,k)*(l(i,k)+d(j)-l(j,k))=e=0 ;

  • the truck comes back empty to the depot

emptyback(j,k) … l(‘depot’,k)=e=0 ;



model Grundmodell /all/;

solve Grundmodell using mip minimizing z;


\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/6p73lcYGp9AJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Hi Julia



Some remarks:

  •      It looks like you don’t understand the difference between parameters and variables. What results will your model give as a solution depending on the given parameters? For me these are: the arrival time (w(I,k), somewhere between the parameter earliest and latest arrival time), the load, the number of trucks (li,k)on the arcs (x(I,j,k)), and the total time (z)are the variables in your model. At the moment w, l are defined as parameters, but they are a result of your optimization.
    
  •      You don’t have to define l(I,k) and then l(j,k), this is exactly the same variable (both defined over the set I (alias j) and k. The same is true for the variable w.
    
  •      In your first equation there is a missing closing parenthesis.
    

Cheers



Renger



Von: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] Im Auftrag von Julia
Gesendet: Thursday, October 25, 2012 9:53 AM
An: gamsworld@googlegroups.com
Betreff: Re: Identify parameter as computable



This is the typical VRPDDTW how it is in journals and books.



$title the vehicle routing problem with pickup and delivery and time windows

sets

i costumers

k trucks ;

alias (i,j)

$include …



parameters

t(i,j) travelling time

a(i) earliest time of arrival

b(i) latest time of arrival

w(i,k) time of arrival at knot i

w(j,k) time of arrival at knot j

l(i,k) truck load after knot i

l(j,k) truck load after knot j

d(j) demand at knot j

s(i) service time at knot j



variables

x(i,j,k) knot i is visited right after knot j by the truck k

z travelling time

binary variable x;



equations

time

arriveknot(i)

leaveknot(j)

start(i)

end(j)

arrival(i,j,k)

timeearly(i,k)

timelate(i,k)

order(i,j,k)

loadbinary(i,k)

loaddemand(i,j,k)

emptyback(i,k)

;

  • minimise the travelling time

time … z=e=sum((i,j,k)$(ord(i) ne ord(j)),(t(i,j)*x(i,j,k)) ;

*arrive at every knot once but the depot

arriveknot(i) … sum((j,k)$(ord(i) ne ord(j) and not ord(j)=1),x(i,j,k)) =e=1 ;

  • leave every knot once but the depot

leaveknot(j) … sum((i,k)$(ord(i) ne ord(j) and not ord(i)=1) ,x(i,j,k)) =l= 1;

  • all trucks must start and end at the depot

start(i) … sum((j,k),x(‘depot’,j,k)) =e= 6;

end(j) … sum((i,k),x(i,‘depot’,k)) =e= 6 ;

  • compute the time of arrival through the arrival at knot i, service time and travelling time

arrival(i,j,k) … (x(i,j,k))*(w(i,k)+s(i)+t(i,j)-w(j,k))=l= 0 ;

  • fullfill the wish of the costumer to arrive within a time window

timeearly(i,k) … a(i)=l=w(i,k) ;

timelate(i,k) … w(i,k)=l=b(i) ;

*pickup the load before the delivery

order(i,j,k) … w(i,k)+t(i,j)=l=w(j,k) ;

  • the load ist binary/ the truck can be full or empty

loadbinary(i,k) … l(i,k)=l=1 ;

*the pickup load is exactly the amount of the demand at knot j

loaddemand(i,j,k) … x(i,j,k)*(l(i,k)+d(j)-l(j,k))=e=0 ;

  • the truck comes back empty to the depot

emptyback(j,k) … l(‘depot’,k)=e=0 ;



model Grundmodell /all/;

solve Grundmodell using mip minimizing z;


\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/6p73lcYGp9AJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Hi Renger,

Thanks for your remarks. especially the second one :wink:

If I define w and l as variables I have to use a nonlinear solver although the model is linear. In that case the model works but the result makes no sense. The trucks don’t drive anywhere and don’t have a load (so both binary values didn’t work). But the arrival times are computed.

Is there even a thing like a computable parameter or a command for that? Something like ‘scalar’ at the end of the parameters eventualy?

Julia


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/hklET595q44J.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

I don’t get it. But I think, if the model results don’t make sense, there is a problem with your model formulation.

Renger



Von: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] Im Auftrag von Julia
Gesendet: Thursday, October 25, 2012 11:33 AM
An: gamsworld@googlegroups.com
Betreff: Re: Identify parameter as computable



Hi Renger,



Thanks for your remarks. especially the second one :wink:



If I define w and l as variables I have to use a nonlinear solver although the model is linear. In that case the model works but the result makes no sense. The trucks don’t drive anywhere and don’t have a load (so both binary values didn’t work). But the arrival times are computed.



Is there even a thing like a computable parameter or a command for that? Something like ‘scalar’ at the end of the parameters eventualy?



Julia


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/hklET595q44J.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

hi

i have a problem with my written vrptw model in gams, it seems my model has written correct in general but some of its constraints shows infeasible, can anybody help me kindly?

my id is : nasima_354@yahoo.com


tnx

\

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.