使用Ipopt

时间:2017-08-17 12:55:35

标签: optimization julia nonlinear-optimization

尝试运行以下内容,即解决受约束的NL方程组:

using JuMP
using Ipopt
m=Model(solver=IpoptSolver())
@variable(m,k,start=0.1)
@variable(m,c,start=1.2)
@variable(m,l,start=0.3)
@NLparameter(m,α==0.21)
@NLparameter(m,β==0.99)
@NLparameter(m,γ==0.4)
@NLparameter(m,μ==0.2)
@NLparameter(m,δ==0.14)
@NLparameter(m,θ==0.25)
@NLconstraint(m,c-c*β*(1-δ+((α/μ)*(k^(α-1))*l^(1-α)))==0)
@NLconstraint(m,θ*c*l^(1/γ)-((1-α)/μ)*k^α*l^-α ==0)
@NLconstraint(m,c+δ*k-k^α*l^(1-α)==0)
@NLconstraint(m,l==0.33)
@NLconstraint(m,(1-δ+((α/μ)*(k^(α-1))*l^(1-α)))-(1.05)^(1/4)==0)
@NLobjective(m,Max,1.0)
solve(m)
println("k=", getvalue(k),"c=", getvalue(c),"l=", getvalue(l))
status=solve(m)

但是,我收到以下错误消息:

警告:Ipopt已完成状态Not_Enough_Degrees_Of_Freedom 警告:未解决最佳状态,状态:错误 警告:Ipopt已完成状态Not_Enough_Degrees_Of_Freedom 警告:未解决最佳状态,状态:错误

这是经济模型的均衡条件,有2个约束条件(Const.4和5) 请问,代码有什么问题吗?或者是否有另一种方法(一种不同的求解器,包,......)来解决这个受约束的问题。

1 个答案:

答案 0 :(得分:0)

您正在尝试解决具有比变量(未知数)更多约束(方程)的NL方程组。此外,等式(5)是在理论(经济学)基础上对等式(1)的一部分施加的约束。因此,对于(c,l,k)满足5个约束(没有足够的自由度)没有可行的解决方案。将模型的两个参数(θ和β)作为变量考虑,导致找到最优解的可行问题。