julia - MethodError:Julia 中 JuMP 的一些问题
问题描述
我对 JuMP 有一些问题。当我运行它时,它说:
MethodError: no method matching (::Interpolations.Extrapolation{Float64, 1, ScaledInterpolation{Float64, 1, Interpolations.BSplineInterpolation{Float64, 1, Vector{Float64}, BSpline{Linear{Throw{OnGrid}}}, Tuple{Base.OneTo{Int64}}}, BSpline{Linear{Throw{OnGrid}}}, Tuple{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}}}, BSpline{Linear{Throw{OnGrid}}}, Throw{Nothing}})(::AffExpr)
Use square brackets [] for indexing an Array.
谢谢!
using JuMP
import Ipopt
β = 0.88
Nb = 1000
δ = 1.5
wage = 1
rate = 1
grid_b = range(0, 5, length = 1000)
w = 5 * (grid_b).^2
w_func = LinearInterpolation(grid_b, w)
choice1 = Model(Ipopt.Optimizer)
@variable(choice1, x >= 0)
@NLobjective(choice1, Max, x^δ/(1-δ) + β * (w_func.((grid_b[3]*(1+rate)+wage-x) * 3)))
optimize!(choice1)
解决方案
如果我尝试运行您的代码,我会得到
ERROR: UndefVarError: LinearInterpolation not defined
那是哪个包的?另外,您使用的是什么版本的 JuMP?
推荐阅读
- android - 具有 sourceBounds 的其他应用程序的 startActivity(就像启动器一样)
- c++ - nghttp2-asio :在标头中设置内容类型的正确方法
- java - .next() 在 Java 的 ResultSet 中不起作用
- sqlite - 如何在 Julia 中以只读方式打开 SQLite 数据库?
- java - 如何使用 Oracle 10g 在 Spring JPA 存储库中获取分页结果
- javascript - 有没有办法直接在html中检查打开的文件大小而不上传?
- javascript - 检查段落是否以字符开头,如果是则在其上应用 HTML 样式
- r - 提取产品名称、数量和单价,并将它们放入包含每个订单中的项目的数据框中
- ios - 在外部函数swift中使用表行中的indexPath
- sql - 使用正则表达式从下划线分隔的字符串中提取所有元素