AMPL语法错误
AMPL syntax error
我正在学习使用 AMPL,我编写了下一个脚本
# Problema 2
set P #plantas
set PI #puntos intermedios
set CD # centros de distribucion
set O # origenes
set D # destinos
param coste {i in O , j in D}
param produc {k in P}
param capac {l in PI}
param requiere {m in CD}
var cantidad{O,D}>==0;
check: sum{k in P} produc[k] <= sum{m in CD} requiere[m];
minimize costo_transporte: sum{i in O, j in D} coste[i,j]*cantidad[i,j];
subject to restriccion_produccion{k in P}:
sum{j in D}cantidad[k,j]<=produc[k];
subject to restriccion_intermedio_entrada{l in PI}:
sum{i in O}cantidad[i,l]<=capac[l];
subject to resctriccion_intermedio_salida{l in PI}:
sum{i in O}cantidad[i,j] - sum{j in D}cantidad[l,j]>=0;
subject to restriccion_demanda{m in CD}:
sum{i in O}cantidad[i,m]=requiere[m];
与下一个数据文件
set P:= Rancagua SanPablo Bogota;
set PI:= Lima Mendoza;
set CD:= Santiago RiodeJaneiro Quito Caracas;
set O:= Rancagua SanPablo Bogota Santiago Lima Mendoza;
set D:= Santiago RiodeJaneiro Quito Caracas Lima Mendoza;
param coste:
Santiago RiodeJaneiro Quito Caracas Lima Mendoza:=
Rancagua 3 20 30 30 10 6
SanPablo 15 5 35 40 20 12
Bogota 45 25 10 12 25 30
Santiago 0 15 30 48 12 10
Lima 12 22 8 30 0 15
Mendoza 10 15 12 35 15 0;
param produc:=
Rancagua 300
SanPablo 250
Bogota 200;
param capac:=
Lima 150
Mendoza 180;
param requiere:=
Santiago 120
RiodeJaneiro 300
Quito 80
Caracas 200;
但是当我对 mod 文件充电时,AMPL 打印
ampl: model 'C:\Users\Laura\Desktop\Monserrat\P2\problema2.mod';
C:\Users\Laura\Desktop\Monserrat\P2\problema2.mod, line 3 (offset 30):
syntax error
我检查了代码,但我不明白错误是什么。
请!帮帮我。
对于集合和参数的定义,而不仅仅是变量和方程,您必须以分号结束行 ;
。
我正在学习使用 AMPL,我编写了下一个脚本
# Problema 2
set P #plantas
set PI #puntos intermedios
set CD # centros de distribucion
set O # origenes
set D # destinos
param coste {i in O , j in D}
param produc {k in P}
param capac {l in PI}
param requiere {m in CD}
var cantidad{O,D}>==0;
check: sum{k in P} produc[k] <= sum{m in CD} requiere[m];
minimize costo_transporte: sum{i in O, j in D} coste[i,j]*cantidad[i,j];
subject to restriccion_produccion{k in P}:
sum{j in D}cantidad[k,j]<=produc[k];
subject to restriccion_intermedio_entrada{l in PI}:
sum{i in O}cantidad[i,l]<=capac[l];
subject to resctriccion_intermedio_salida{l in PI}:
sum{i in O}cantidad[i,j] - sum{j in D}cantidad[l,j]>=0;
subject to restriccion_demanda{m in CD}:
sum{i in O}cantidad[i,m]=requiere[m];
与下一个数据文件
set P:= Rancagua SanPablo Bogota;
set PI:= Lima Mendoza;
set CD:= Santiago RiodeJaneiro Quito Caracas;
set O:= Rancagua SanPablo Bogota Santiago Lima Mendoza;
set D:= Santiago RiodeJaneiro Quito Caracas Lima Mendoza;
param coste:
Santiago RiodeJaneiro Quito Caracas Lima Mendoza:=
Rancagua 3 20 30 30 10 6
SanPablo 15 5 35 40 20 12
Bogota 45 25 10 12 25 30
Santiago 0 15 30 48 12 10
Lima 12 22 8 30 0 15
Mendoza 10 15 12 35 15 0;
param produc:=
Rancagua 300
SanPablo 250
Bogota 200;
param capac:=
Lima 150
Mendoza 180;
param requiere:=
Santiago 120
RiodeJaneiro 300
Quito 80
Caracas 200;
但是当我对 mod 文件充电时,AMPL 打印
ampl: model 'C:\Users\Laura\Desktop\Monserrat\P2\problema2.mod';
C:\Users\Laura\Desktop\Monserrat\P2\problema2.mod, line 3 (offset 30): syntax error
我检查了代码,但我不明白错误是什么。 请!帮帮我。
对于集合和参数的定义,而不仅仅是变量和方程,您必须以分号结束行 ;
。