But as shown in the data set for d is 1 dimensional. How can i tell ampl, that is should calculate d[u,v] as sum of d[v]For example d[1,5] = d[1] +d[2]+ d[3]+d[4]
Have you looked at the example of a shortest path model in the AMPL book (www.ampl.com/BOOK/download.html)? It's in chapter 15, beginning on page 329.
If you write
subject to Flusserhaltung {(u,v) in E}: ...
then you are defining a separate constraint for each pair (u,v) in the set E. Thus the indexes u and v are already fixed inside the constraint expression, and it doesn't make sense to write
sum {(u,v) in E} x[u,v]
inside the constraint -- that is what gives rise to a "zero-dimensional slice" message. The example in the book shows how to properly constrain the path to start at a specific node.
Bob Fourer
From: am...@googlegroups.com [mailto:am...@googlegroups.com]
On Behalf Of Anke
Sent: Wednesday, December 12, 2012 3:35 AM
To: am...@googlegroups.com
Subject: [AMPL 6382] Re: dynamic optimization: wagner whitin problem as shortest path problem
Hey Paul,
thanks again. Another question:
How can i tell ampl, that it should minimize the costs: sum{(u,v) in E} c[u,v] * x[u,v];
subject to that xuv discribes a way from 1 to T+1
Furthermore i have to tell ampl, that a best path (u=1,v) has to be used to cover the demand in the first period!
Could you help me again, and tell me what is wrong in the model:
I always get the information, that the subject is a conditional 0 slice!
Here is my latest try:
param T integer;
set V:= 1..T;
set E:= {u in V, v in V:u<v};
param d{v in V};
param dsum{u in V, v in V:u<v}:=sum{w in V:w>=u and w<=v} d[w];
param s;
param h;
param c{(u,v) in E}:= h* dsum[u,v]+ s;
var x{(u,v) in E} binary;
minimize Kosten: sum{(u,v) in E} c[u,v] * x[u,v];
subject to Flusserhaltung{(u,v) in E}: sum{(u,v) in E} x[u,v] - (sum{(v,w) in E} x[v,w]=dsum[u,v]
.