Nasiru Abdullahi
unread,Nov 11, 2012, 10:22:05 AM11/11/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Robert Fourer, ampl
Hi; every one
Below is the replica of AMPL script example given in section 13.7 on
page 273 of the AMPL Book, i save it in a subfolder skripts,in
c:\myfiles with the name cwlpD.run. Ofcourse using my model named
cwlp1a.mod and data cwlp1.dat, cwlp2.dat and cwlp3.dat all located in
c:\myFiles.
model c:\myFiles\cwlp1a.mod;
set CASES = 1 .. 3;
for {j in CASES} {
reset data;
data ("cwlp" & j & ".dat");
solve;
display tcost, _solve_time >("cwlp" & j & ".out");
}
when I keyed in the above script as:
ampl: include c:\myFiles\skripts\cwlpD.run;
I got the following error messages from AMPL:
Error at _cmdno 3 executing "data" command (file
c:\myFiles\skripts\cwlpD.run, line 5, offset 84):
c:\myFiles\skripts\cwlpD.run, line 8 (offset 173): can't find file
"cwlp1.dat" context: >>>}<<<
include stack.....
_,line 0 includes c:\myFiles\skripts\cwlpD.run.
please can someone identify what is wrong. thanks. below is the model
and the data
Model: cwlp1a.mod
## warehouse location problem with capacity constraints formulation 1a
/* Akinc and Khumawala (1977), Nauss (1978), Barrie and Amandio
(1995), John and Hannan (1986), Barrie (1986) and Lai etal (2010) */
###SETS###
set Warehouses; # number of warehouses i
set Customers; # number of customers i.e demand j
### PARAMETERS###
param cost{i in Warehouses,j in Customers}; # c[i,j]
param supply{i in Warehouses}; # supply capacity at warehouse i
param demand{j in Customers}; # demand of customer j
param fixed_charge{i in Warehouses}; # cost of opening warehouses i
### VARIABLES###
var amount{i in Warehouses, j in Customers}; # x[i,j];
var open{i in Warehouses} binary; # equal 1 if warehouse i is opened,0 otherwise
### OBJECTIVE###
minimize tcost:
sum{i in Warehouses,j in Customers} cost[i,j]*amount[i,j] + sum{i
in Warehouses} fixed_charge[i]*open[i];
###CONSTRAINTS###
subject to tsupply{i in Warehouses}:sum{j in
Customers}amount[i,j]<=supply[i]*open[i];
subject to tdemand{j in Customers}:sum{i in Warehouses}amount[i,j]=demand[j];
subject to positive{i in Warehouses,j in Customers}:amount[i,j]>=0;
cwlp1.dat
## Warehouse location problem data file 3x4
set Warehouses:= wh1 wh2 wh3;
set Customers:= ctm1 ctm2 ctm3 ctm4;
param cost: ctm1 ctm2 ctm3 ctm4:=
wh1 1 2 1 3
wh2 3 5 1 4
wh3 2 2 2 2;
param supply:= wh1 550
wh2 1100
wh3 1060;
param demand:= ctm1 300
ctm2 320
ctm3 800
ctm4 390;
param fixed_charge:= wh1 500
wh2 500
wh3 500;
cwlp2.dat
## Warehouse location problem data file size (5x4)
set Warehouses:= wh1 wh2 wh3 wh4 wh5;
set Customers:= ctm1 ctm2 ctm3 ctm4;
param cost: ctm1 ctm2 ctm3 ctm4:=
wh1 2 10 9 8
wh2 9 7 9 2
wh3 9 7 6 2
wh4 7 10 7 5
wh5 1 9 15 4;
param supply:= wh1 13
wh2 13
wh3 13
wh4 13
wh5 13;
param demand:= ctm1 12
ctm2 12
ctm3 12
ctm4 12;
param fixed_charge:= wh1 60
wh2 60
wh3 70
wh4 30
wh5 50;
cwlp3.dat
## Warehouse location problem data file size (5x6)
set Warehouses:= wh1 wh2 wh3 wh4 wh5;
set Customers:= ctm1 ctm2 ctm3 ctm4 ctm5 ctm6;
param cost: ctm1 ctm2 ctm3 ctm4 ctm5 ctm6:=
wh1 2 15 8 22 37 12
wh2 14 1 21 18 31 22
wh3 9 20 4 12 25 20
wh4 36 30 23 7 2 40
wh5 12 24 19 15 35 3;
param supply:= wh1 20
wh2 30
wh3 38
wh4 42
wh5 55;
param demand:= ctm1 15
ctm2 12
ctm3 18
ctm4 19
ctm5 16
ctm6 20;
param fixed_charge:= wh1 300
wh2 500
wh3 600
wh4 800
wh5 1100;