I want to know, in AMPL, can it possibly declare a variable or
parameter with 3 dimension?
For example, I have a variable defined as:
Q(ij,t): the product quantity carried by the vehicle from customer i
to customer j in day t.
In the model, I only declare:
set Locations = 1..15 ;
.
.
param Q {Locations, Locations} >= 0;
so how to declare Q{i, j} with t together and how to specify the
data(3 dimension, not a matrix any more)??
Thanks a lot for your help!
Terry Zhong
Terry
Bob Fourer
4...@ampl.com
### multi.mod ###
set ORIG; # origins
set DEST; # destinations
set PROD; # products
param supply {ORIG,PROD} >= 0; # amounts available at origins
param demand {DEST,PROD} >= 0; # amounts required at destinations
check {p in PROD}:
sum {i in ORIG} supply[i,p] = sum {j in DEST} demand[j,p];
param limit {ORIG,DEST} >= 0;
param cost {ORIG,DEST,PROD} >= 0; # shipment costs per unit
var Trans {ORIG,DEST,PROD} >= 0; # units to be shipped
minimize Total_Cost:
sum {i in ORIG, j in DEST, p in PROD}
cost[i,j,p] * Trans[i,j,p];
subject to Supply {i in ORIG, p in PROD}:
sum {j in DEST} Trans[i,j,p] = supply[i,p];
subject to Demand {j in DEST, p in PROD}:
sum {i in ORIG} Trans[i,j,p] = demand[j,p];
subject to Multi {i in ORIG, j in DEST}:
sum {p in PROD} Trans[i,j,p] <= limit[i,j];
### multi.dat ###
set ORIG := GARY CLEV PITT ;
set DEST := FRA DET LAN WIN STL FRE LAF ;
set PROD := bands coils plate ;
param supply (tr): GARY CLEV PITT :=
bands 400 700 800
coils 800 1600 1800
plate 200 300 300 ;
param demand (tr):
FRA DET LAN WIN STL FRE LAF :=
bands 300 300 100 75 650 225 250
coils 500 750 400 250 950 850 500
plate 100 100 0 50 200 100 250 ;
param limit default 625 ;
param cost :=
[*,*,bands]: FRA DET LAN WIN STL FRE LAF :=
GARY 30 10 8 10 11 71 6
CLEV 22 7 10 7 21 82 13
PITT 19 11 12 10 25 83 15
[*,*,coils]: FRA DET LAN WIN STL FRE LAF :=
GARY 39 14 11 14 16 82 8
CLEV 27 9 12 9 26 95 17
PITT 24 14 17 13 28 99 20
[*,*,plate]: FRA DET LAN WIN STL FRE LAF :=
GARY 41 15 12 16 17 86 8
CLEV 29 9 13 9 28 99 18
PITT 26 14 17 13 31 104 20 ;
Terry
The cost from the plants to the DCs (costs) as well as the cost from the DC to the regions (costr) are presented in a 3-dimensional parameter. That is, param costs{PLANTS, DCS, PRODUCTS) >= 0; The access to elements is similar to the 2-dimensional with costs[i,j,k].
param costs := [*,*,P1]: A B :=
C65 D47 M69
The code-snippet shows the cost for product 1 from the plants C, D, and M to the DC A and B.
Otherwise, the following constraints are given:
Supply per plant per product is limited according to “supply”
Minimum demand per region is given in “demand”
All incoming orders to the DC are fully forwarded to the regions
The DCs have a capacity
Even though there is a capacity for the supply per plant and product, there is also an
overall max supply per plant (maxsupply)
The overall goal is to minimise the cost of transport. Note that there are no fixcosts.
Hints: Even though there might be other solutions, I am looking for the objective function, the variable and parameter definitions, and constraints (5 in my solution).
Hint 2: Objective function is 6150, the transport quantities for B (DC) to NY (region) for product P3 is 25, C to A for P1 = 0, M to A for P3 150.
I just have the question and data ample which is:
The cost from the plants to the DCs (costs) as well as the cost from the DC to the regions (costr) are presented in a 3-dimensional parameter. That is, param costs{PLANTS, DCS, PRODUCTS) >= 0; The access to elements is similar to the 2-dimensional with costs[i,j,k].
param costs := [*,*,P1]: A B :=
C65 D47 M69
The code-snippet shows the cost for product 1 from the plants C, D, and M to the DC A and B.
Otherwise, the following constraints are given:
Supply per plant per product is limited according to “supply”
Minimum demand per region is given in “demand”
All incoming orders to the DC are fully forwarded to the regions
The DCs have a capacity
Even though there is a capacity for the supply per plant and product, there is also an
overall max supply per plant (maxsupply)
The overall goal is to minimise the cost of transport. Note that there are no fixcosts.
Hints: Even though there might be other solutions, I am looking for the objective function, the variable and parameter definitions, and constraints (5 in my solution).
Hint 2: Objective function is 6150, the transport quantities for B (DC) to NY (region) for product P3 is 25, C to A for P1 = 0, M to A for P3 150.
then according the data we have,I am trying mod file for it
param maxsupply :=
C 10000
D 250
M 10000;
param costs :=
[*,*,P1]: A B :=
C 6 5
D 4 7
M 6 9
[*,*,P2]: A B :=
C 6 5
D 4 7
M 6 9
[*,*,P3]: A B :=
C 6 5
D 4 7
M 4 7
;
param costr :=
[*,*,P1]: A B :=
NY 8 9
VA 5 7
PA 6 6
[*,*,P2]: A B :=
NY 7 3
VA 8 8
PA 5 6
[*,*,P3]: A B :=
NY 7 4
VA 4 5
PA 4 4
;
∑i∑j D ijk * Y ijk ≤ CAP k
∑j X1jk = 1 ꓯ k E K
these are the data of an example I did in excel. it worked but the solver is not good that's why I need to program in ampl to add an extensive data base
.mod
explained this, now my doubts, sorry I know that this is very long.
I do not know how to define the variables if I have to put X (ijk) X (path) nose how to define my objective function to minimize or the restriction.
I hope you can help me because I really have no idea how to do it.
I thank you in advance
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.