我学习使用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,第3行(偏移30): 语法错误
我查看了代码,但我不明白错误是什么。 请!帮助我。
答案 0 :(得分:1)
您还必须以分号;
结束该行,以便定义集合和参数,而不仅仅是变量和方程式。