0

我正在尝试运行以下文件。我尝试逐个上传。这就是为什么某些组件被注释掉的原因。无论我激活了哪个组件,我都会收到约束部分的此错误​​。

using JuMP
using Gurobi


pset = ["packaging1", "packaging2"]
size_pset = 2
fset = ["filling1", "filling2"]
size_fset = 2
mset = ["manufacturing1","manufacturing2"]
size_mset = 2
timeset = [1,2,3,4,5,6,7,8,9,10]
size_timeset = 10
fgset = ["product1","product2"]
size_fgset = 2
bulkset = ["bulk1","bulk2"]
size_bulkset = size_fgset
apiset = ["api1","api2"]
size_apiset = 2
scenarioset = ["s1","s2","s3","s4","s5","s6","s7","s8","s9","s10","s11","s12","s13","s14","s15","s16"]
size_scenarioset = 16
CFF = 0.7
CFP = 0.5
SR = 2
RW = 2
KGS = 2

ESTputP= 100
ESTputF= 100
ESTputM= 100

m = Model(solver=GurobiSolver())

@variable(m, ThputM[1:size_mset, 1:size_timeset, 1:size_apiset, 1:size_scenarioset] >= 0) 
@variable(m, InThputM[1:size_fset, 1:size_timeset, 1:size_apiset, 1:size_bulkset, 1:size_scenarioset] >= 0)
@variable(m, XP_p[1:size_pset, 1:size_timeset, 1:size_fgset] >= 0)
@variable(m, XP_n[1:size_pset, 1:size_timeset, 1:size_fgset] >= 0)
@variable(m, XF_p[1:size_fset, 1:size_timeset, 1:size_bulkset] >= 0)
@variable(m, XF_n[1:size_fset, 1:size_timeset, 1:size_bulkset] >= 0)
@variable(m, XM_p[1:size_mset, 1:size_timeset, 1:size_apiset] >= 0)
@variable(m, XM_n[1:size_mset, 1:size_timeset, 1:size_apiset] >= 0)

#objective
@objective(m, Min, sum(XM_p[m,t,a]+XM_n[m,t,a] for m=1:size_mset for t=1:size_timeset for a=1:size_apiset)+
                    sum(XF_p[f,t,b]+XF_n[f,t,b] for f=1:size_fset for t=1:size_timeset for b=1:size_bulkset)+
                    sum(XP_p[p,t,f]+XP_n[p,t,f] for p=1:size_pset for t=1:size_timeset for f=1:size_fgset))

# Constraints:
#@constraint(m, thput_relateM[m=1:size_mset, t=1:size_timeset, a=1:size_apiset, s=1:size_scenarioset],ThputM[m,t,a,s]==SR*RW*KGS)

@constraint(m, thput_relate_M_Bulk_API[m=1:size_mset, t=1:size_timeset, a=1:size_apiset, s=1:size_scenarioset],
              sum(InThputM[m,t,a,b,s] for b=1:size_bulkset)==ThputM[m,t,a,s])

writeLP(m, 'Sifomodel.lp'; genericnames=false)

status = solve(m)

println("Solve status: ", status)
println("Objective value: ", getobjectivevalue(m))

特别是“约束上传”的原因是什么?

4

2 回答 2

1

如果您m用作索引,它将覆盖模型对象m。请注意,错误消息表明您正在尝试addconstraint使用(integer,constraint)参数而不是(model,constraint).

于 2017-02-06T04:14:15.240 回答
0

似乎 JuMP 想要在右侧收集所有常量,而在另一侧收集变量。当以这种方式重新排列约束时,它接受模型。

于 2017-01-31T18:43:05.680 回答