由具有变量的比较索引(集合的元素)引起的AMPL ecopy()错误 [英] AMPL ecopy() error causing by comparison indices (element of set) with variable

查看:74
本文介绍了由具有变量的比较索引(集合的元素)引起的AMPL ecopy()错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是另一个错误,如下所示:

I another bug as you can see below:

Error at _cmdno 8 executing "solve" command
(file ./script/runConfiguration.run, line 5, offset 127):
error processing constraint c1a[2,'o1',1]:
unexpected type 0x14205 in ecopy()

我想是导致与c1a约束中的索引(集合元素)比较的问题。

I guess that the problem causing comparison with the index (element of set) variable in c1a constraint. Is it possible to avoid this bug?

我的新放大器模型:

#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
var s {K,O} symbolic in N;                #source nodes

#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 c1a {k in K, o in O, n in N: n!=t[k,o]}:
(s[k,o]==n)
 ==>
        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 c1b {k in K, o in O, n in N: n!=t[k,o]}:
(s[k,o]!=n)
    ==>
        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;

subject to c5 {k in K, o in O}:
    s[k,o]=
        2-sum{n in N}(r[n,k]*f[n,o])
        +(sum{n in N}
                (r[n,k]*f[n,o])-1)
        *(sum{i in K}(r[i,k]*f[i,o]*i));

subject to c0 {e in E, k in K, o in O}:
    x[e,k,o]>=0;

这是非常简单的数据:

#Data file for 'CDN allocation copies' problem simple example

#indices
set K := 2 3 4;               #index of nodes with group of clients
set N := 1 2 3 4;             #nodes
set E := 1_2 2_3 2_4;         #edges
set O := o1;                  #objects

#parameters
param d (tr):                  #demands for object o
        2       3       4    :=
o1      0       512     512;
#opt= 63 + 75 = 138

param t (tr):                  #destination nodes
        2       3       4    :=
o1      2       3       4;

param r (tr):                   #1 if node n is ancestor of node k, 0 otherwise
        1       2       3       4   :=  
2       1       0       0       0       
3       1       1       0       0
4       1       1       0       0;

param a (tr):                   #1 if edge begins in vertex, 0 otherwise
        1       2       3       4   :=
1_2     1       0       0       0
2_3     0       1       0       0
2_4     0       1       0       0;

param b (tr):                   #1 if edge ends in vertex, 0 otherwise
        1       2       3       4   :=
1_2     0       1       0       0
2_3     0       0       1       0
2_4     0       0       0       1;

param c :=      #cost of using an edge
1_2     3
2_3     1
2_4     1;

param Hmax := 1; #available capacity for allocation object in proxy servers

此数据文件描述了具有4个具有此类拓扑的节点的网络:

This data file describe network with 4 nodes with topology like this:

     1
     |
     2
    / \
    3 4

这很容易猜测最好的解决方案是仅保存节点2的内容。对象函数= 1024并且f_2,o1 = 1。

It is easy to guess that the best solution is to save only the content of the node 2. The object function = 1024 and f_2,o1=1.

该模型尝试求解Strorage容量分配问题,我在另一篇文章中对此进行了描述:
解决CDN时出现错误分配规则

Whis model try to solve Strorage Capacity Allocation problem, which I described in another my post: Bug when solving CDN allocation rule

推荐答案

我和我的朋友们发现了重新定义CDN SCAP问题的解决方案,如下所示对于CPLEX解析器:

I with my friends found solution for redefine CDN SCAP problem as it shown below, which is applicable for CPLEX resolver:

#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} >= 0;              #value of the demand realised over edge for object
var s {K,O} binary;                #source nodes

#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 c1a {k in K, o in O, n in N: n==1}:
s[k,o] = 0
  ==>       
        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]) = 0
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 c1b1 {k in K, o in O, n in N: n!=t[k,o] and n!=1}:      
        sum{e in E}
            (a[n,e]*x[e,k,o]) -
        sum{e in E}
            (b[n,e]*x[e,k,o]) -
                                r[n,k]*d[k,o]*(1-f[k,o]) <= 0;

subject to c1b2 {k in K, o in O, n in N: n!=t[k,o] and n!=1}:
        sum{e in E}
            (a[n,e]*x[e,k,o]) - 
        sum{e in E}
            (b[n,e]*x[e,k,o]) -
                                r[n,k]*d[k,o]*s[k,o] <= 0;

subject to c1b3 {k in K, o in O, n in N: n!=t[k,o] and n!=1}:    
        sum{e in E}
            (a[n,e]*x[e,k,o]) -
        sum{e in E}
            (b[n,e]*x[e,k,o]) -
                                r[n,k]*d[k,o]*f[n,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;

subject to c5 {k in K, o in O}:
    s[k,o]=sum{n in N}(r[n,k]*f[n,o])-1;

这篇关于由具有变量的比较索引(集合的元素)引起的AMPL ecopy()错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆