AMPL 错误:我收到这个错误,我已经提到并附加了 mod 和 dat 文件

问题描述 投票:0回答:0

下面是我的 ampl 的 dat 和模式文件。 我收到以下错误:

hw3.dat,第 14 行(偏移量 262): b[1] 已经定义 上下文:1 1 >>> ; <<<

hw3.dat,第 14 行(偏移量 262): b[1] 已经定义 上下文:1 1 >>> ; <<<

hw3.dat,第 14 行(偏移量 262): b[1] 已经定义 上下文:1 1 >>> ; <<<

hw3.dat,第 14 行(偏移量 262): b[1] 已经定义 上下文:1 1 >>> ; <<<

hw3.dat,第 14 行(偏移量 262): b[1] 已经定义

MODEL FILE:




# AMPL model for the Minimum Cost Network Flow Problem
#
# By default, this model assumes that b[i] = 0, c[i,j] = 0,
# l[i,j] = 0 and u[i,j] = Infinity.
#
# Parameters not specified in the data file will get their default values.
reset;
options solver cplex;
set NODES;                        # nodes in the network
set ARCS within {NODES, NODES};   # arcs in the network
set english;
set french;
param b {NODES} default 0;        # supply/demand for node i
param c {ARCS}  default 0;        # cost of one of flow on arc(i,j)
param l {ARCS}  default 0;        # lower bound on flow on arc(i,j)
param u {ARCS}  default Infinity; # upper bound on flow on arc(i,j)
var x {ARCS};                     # flow on arc (i,j)
maximize cost: sum{(i,j) in ARCS} c[i,j] * x[i,j];  #objective: minimize 
#arc flow cost


subject to flow_balance {i in NODES}:
sum{j in NODES: (i,j) in ARCS} x[i,j] - sum{j in NODES: (j,i) in ARCS} 
x[j,i] = b[i];A
subject to capacity {(i,j) in ARCS}: l[i,j] <= x[i,j] <= u[i,j];
subject to flow_conservation {i in english}:
    sum{j in french} x[i,j] = 1;
subject to flow_bounds {(i,j) in ARCS}:
    x[i,j] = 0 || x[i,j] <= 1;
#subject to Number: {(i,j) in ARCS} x[i,j]=0 || x[i,j] = 1;



data hw3.dat
solve;
printf "The optimal pair assignments with compatibility scores are: \n";
for {i in english, j in french} {
    printf "English Child %d and French Child %d with compatibility score %d \n", i, j, c[i,j];
}


data;
set NODES :=e1 e2 e3 f1 f2 f3;
set ARCS:= (e1,f1) (e1,f2) (e1,f3) (e2,f1) (e2,f2) (e2,f3) (e3,f1) (e3,f2) (e3,f3);

set english:=e1 e2 e3;
set french:=f1 f2 f3;
param: b:=
          1 1
          1 1
          1 1
          1 1
          1 1
          1 1;
param: c l u:=
        [e1,f1] 6  0 10
        [e1,f2] 3  0 10
        [e1,f3] 2  0 10
        [e2,f1] 9  0 10
        [e2,f2] 5  0 10
        [e2,f3] 1  0 10
        [e3,f1] 4  0 10
        [e3,f2] 10 0 10
        [e3,f3] 8  0 10
 ;

一直说b已经定义了,但是我没有定义。我尝试将名称从 b 更改为其他名称,但仍然显示相同的错误。 有人可以帮忙吗?

meta heuristics ampl
© www.soinside.com 2019 - 2024. All rights reserved.