1

我对 AMPL 的数学问题的处方有疑问。

我试图解决这个问题:

在具有一组节点 N 和一组边 E 的网络中,每个节点都有存储来缓存内容。有一组内容对象可供客户端访问,如果需要可以缓存。令 o ∈ O 的大小等于 h_o 存储单元。假设每个节点 n ∈ N 都有请求对象 o ∈ O 的客户端,因此向 n 下载 o 的流量等于 d_n;o。在托管内容交付网络 (CDN) 中,CDN 运营商可以采用各种策略在缓存之间分配内容副本。这些策略可能取决于许多可能是技术或业务性质的因素,这会导致不同的优化问题。令 h_max 为 CDN 可以使用的最大总存储量(即 CDN 在所有节点上使用的存储量之和)。寻找:

放大文件:

    #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
4

1 回答 1

1

该错误是由 AMPL 错误地在_ncons. 它在 AMPL 版本 20130510 中得到修复(参见http://www.netlib.org/ampl/changes)。模型中的逻辑约束是指标约束c1a

于 2013-05-11T14:02:05.717 回答