我对AMPL处理数学问题有疑问。
我试图解决这个问题:
在具有一组节点N和一组边E的网络中,每个节点具有用于缓存内容的存储。有一组O内容对象是客户端访问的,如果需要可以缓存。令o∈O的大小等于h_o存储单元。假设每个节点n∈N具有请求对象o∈O的客户端,以便向n下载o的流量等于d_n; o。在托管内容传递网络(CDN)中,CDN运营商可以采用各种策略来在缓存之间分配内容副本。这些政策可能取决于许多可能是技术或商业性质的因素,这些因素会产生不同的优化问题。令h_max是CDN可以使用的最大总存储量(即,CDN在所有节点上使用的存储总和)。查找:每个对象的副本分配o∈O,以便在最小化网络中的整体trac(即从缓存到客户端节点的路由成本)的同时,对CDN使用的总存储的限制进行评估
Ampl文件:
#Model for 'CDN allocation copies' problem
#sets
#-------------------------------------------------------------------------------------
set K; #index of nodes with group of clients
set N; #nodes
set E; #edges
set O; #objects
#parameters
#-------------------------------------------------------------------------------------
param d {K,O}; #demands for object o
param t {K,O} symbolic; #destination nodes
param r {N,K} binary; #1 if node n is ancestor of node k, 0 otherwise
param a {N,E} binary; #1 if edge begins in vertex, 0 otherwise
param b {N,E} binary; #1 if edge ends in vertex, 0 otherwise
param c {E}; #cost of using an edge
param Hmax; #available capacity for allocation object in proxy servers
#variables
#-------------------------------------------------------------------------------------
var f {N,O} binary; #1 if object saved at node k, 0 otherwise
var x {E,K,O}; #value of the demand realised over edge for object
#goal function
#-------------------------------------------------------------------------------------
#The function minimizes cost of routing
#By saving copies at CDN proxies we minimizing all traffic from all demands
#with all objects
minimize goal:
sum{e in E}
sum{k in K}
sum{o in O}
(x[e,k,o]*c[e]);
#constraints
#-------------------------------------------------------------------------------------
subject to c0 {e in E, k in K, o in O}:
x[e,k,o]>=0;
subject to c1a {k in K, o in O, n in N: n!=t[k,o]}:
(r[n,k]==1 and f[n,o]==1)
==>
sum{e in E}
(a[n,e]*x[e,k,o]) -
sum{e in E}
(b[n,e]*x[e,k,o]) =
d[k,o]*(1-f[k,o])
else
sum{e in E}
(a[n,e]*x[e,k,o]) -
sum{e in E}
(b[n,e]*x[e,k,o]) =
0;
subject to c1c {k in K, o in O, n in N: n==t[k,o]}:
sum{e in E}
(a[n,e]*x[e,k,o]) -
sum{e in E}
(b[n,e]*x[e,k,o]) =
-d[k,o]*(1-f[k,o]);
subject to c2:
sum{k in K}
sum{o in O}
f[k,o] <= Hmax;
subject to c3 {k in K, o in O}:
sum{n in N}
r[n,k]*f[n,o] <= 2;
subject to c4 {o in O}:
f[1,o]=1;
我的数据文件:
#Data file for 'CDN allocation copies' problem simple example
#indices
set K := 2 3; #index of nodes with group of clients
set N := 1 2 3; #nodes
set E := 1_2 1_3; #edges
set O := o1 o2 o3 o4 o5 o6 o7 o8 o9 o10; #objects
#parameters
param d (tr): #demands for object o
2 3 :=
o1 2560 512
o2 1280 256
o3 640 128
o4 320 64
o5 160 32
o6 80 16
o7 40 8
o8 20 4
o9 10 2
o10 5 1;
#opt= 63 + 75 = 138
param t (tr): #destination nodes
2 3 :=
o1 2 3
o2 2 3
o3 2 3
o4 2 3
o5 2 3
o6 2 3
o7 2 3
o8 2 3
o9 2 3
o10 2 3;
param r (tr): #1 if node n is ancestor of node k, 0 otherwise
1 2 3 :=
2 1 0 0
3 1 0 0;
param a (tr): #1 if edge begins in vertex, 0 otherwise
1 2 3 :=
1_2 1 0 0
1_3 1 0 0;
param b (tr): #1 if edge ends in vertex, 0 otherwise
1 2 3 :=
1_2 0 1 0
1_3 0 0 1;
param c := #cost of using an edge
1_2 1
1_3 1;
param Hmax := 10; #available capacity for allocation object in proxy servers
当我尝试解决我的问题时,我看到了这个错误:
Error at _cmdno 15 executing "let" command
(file C:\Program Files\AMPLDevX64 Evaluation\plugins\com.ampldev_2.3.0.201211162252 \include/writesol.ampl, line 22, offset 783):
Can't evaluate _con[92]:
subscript not in 1 .. 91
答案 0 :(得分:1)
错误是由AMPL错误地包括_ncons
中的逻辑约束数引起的。它在AMPL版本20130510中修复(请参阅http://www.netlib.org/ampl/changes)。模型中的逻辑约束是指标约束c1a
。