我寫了下面的代碼方法匹配*(::變量):錯誤:`*`沒有
using JuMP
m = Model()
const A =
[ :a0 ,
:a1 ,
:a2 ]
const T = [1:5]
const U =
[
:a0 => [9 9 9 9 999],
:a1 => [11 11 11 11 11],
:a2 => [1 1 1 1 1]
]
@defVar(m, x[A,T], Bin)
@setObjective(m, Max, sum{sum{x[i,j] * U[i,j], i=A}, j=T})
print(m)
status = solve(m)
println("Objective value: ", getObjectiveValue(m))
println("x = ", getValue(x))
當我運行它,我得到以下錯誤
ERROR: `*` has no method matching *(::Variable)
in anonymous at /home/username/.julia/v0.3/JuMP/src/macros.jl:71
in include at ./boot.jl:245
in include_from_node1 at loading.jl:128
in process_options at ./client.jl:285
in _start at ./client.jl:354
while loading /programs/julia-0.2.1/models/a003.jl, in expression starting on line 21
什麼是正確的這樣做的方式?
謝謝你的回答。手冊很清楚也許你可以更加強調這樣一個事實,即係數的意圖是數字和常量。無論如何,這足夠清晰,因爲我在短時間內解決了我的問題,只是推理而已。 – HAL9000