I have a problem with my prescription of a mathematical problem to AMPL.

I trying to solve this problem:

In a network with a set of nodes N and a set of edges E each node has storage to cache content. There is a set O of content objects that are accesses by the clients and can be cached if needed. Let the size of o ∈ O be equal to h_o storage units. Assume each node n ∈ N has clients that request object o ∈ O so that the traffic towards n to download o equals d_n;o. In a managed content delivery network (CDN), the CDN operator can adopt various policies to allocate content copies among the caches. These policies may depend on many factors that can be technical or business in nature, which gives rise to di erent optimisation problems. Let h_max be the maximum total storage that can be used by the CDN (i.e., the sum of storage used bythe CDN over all nodes). Find: the allocation of copies of each object o ∈ O such that the limit on the total storage used by CDN is satis ed while minimising the overall trac in the network (i.e., the routing cost from the caches to client nodes)

Ampl Files:

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

And my data file:

#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

When I try to solve my problem i see this bug:

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
有帮助吗?

解决方案

The error was caused by AMPL incorrectly including the number of logical constraints in _ncons. It is fixed in AMPL version 20130510 (see http://www.netlib.org/ampl/changes). The logical constraint in your model is the indicator constraint c1a.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top