在JuMPeR

时间:2016-06-13 21:49:41

标签: julia julia-jump

这是代码:

    s=5
    k=3
    mod= RobustModel(solver=GurobiSolver())
    @defUnc(mod,ξ[i=1:k,j=1:s])
    adaptive(mod,ext[1:k], policy=Affine, depends_on=ξ[1:k])
    @defVar(mod, obj)
    @setObjective(mod, Max, obj)

错误是:

    UndefVarError: Affine not defined.

为什么会出现这个问题?

1 个答案:

答案 0 :(得分:1)

您似乎错过了@前面的adaptive

以下是使用更新的JuMP宏语法的操作示例:

julia> using JuMP, JuMPeR, Gurobi

julia> s = 5
5

julia> k = 3
3

julia> mod = RobustModel(solver=GurobiSolver())
Feasibility problem with:
 * 0 linear constraints
 * 0 variables
Solver is Gurobi

julia> @uncertain(mod,ξ[i=1:k,j=1:s])
3x5 Array{JuMPeR.Uncertain,2}:
 ξ[1,1]  ξ[1,2]  ξ[1,3]  ξ[1,4]  ξ[1,5]
 ξ[2,1]  ξ[2,2]  ξ[2,3]  ξ[2,4]  ξ[2,5]
 ξ[3,1]  ξ[3,2]  ξ[3,3]  ξ[3,4]  ξ[3,5]

julia> @adaptive(mod,ext[1:k], policy=Affine, depends_on=ξ[1:k])
3-element Array{JuMPeR.Adaptive,1}:
 JuMPeR.Adaptive(Feasibility problem with:
 * 0 linear constraints
 * 0 variables
Solver is Gurobi,1)
 JuMPeR.Adaptive(Feasibility problem with:
 * 0 linear constraints
 * 0 variables
Solver is Gurobi,2)
 JuMPeR.Adaptive(Feasibility problem with:
 * 0 linear constraints
 * 0 variables
Solver is Gurobi,3)

julia> @variable(mod, obj)
obj

julia> @objective(mod, Max, obj)
obj