我给AMPL的一个数学问题的处方出了问题。
我想解决这个问题:
在具有节点集N和边集E的网络中,每个节点都有存储空间来缓存内容。有一组内容对象可供客户端访问,并且可以在需要时进行缓存。设o∈o的大小等于h_o个存储单元。假设每个节点n∈n都有请求对象o∈o的客户端,则从n到下载o的传输流量等于d_n;o。在托管内容分发网络(CDN)中,CDN运营商可以采用各种策略在缓存中分配内容副本。这些策略可能依赖于许多本质上可能是技术或业务的因素,这会导致不同的优化问题。设h_max为CDN可以使用的最大总存储空间(即,CDN在所有节点上使用的存储空间总和)。查找:每个对象o∈o的副本分配,使得CDN使用的总存储限制为satised,同时最小化网络中的总体传输c(即从缓存到客户端节点的路由成本)
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 FilesAMPLDevX64 Evaluationpluginscom.ampldev_2.3.0.201211162252 include/writesol.ampl, line 22, offset 783):
Can't evaluate _con[92]:
subscript not in 1 .. 91
此错误是由AMPL错误地包括_ncons
中的逻辑约束数量引起的。它是固定在AMPL版本20130510(见http://www.netlib.org/ampl/changes)。模型中的逻辑约束是指示符约束c1a
。