@NLexpression
マクロはその3番目の引数としてジャンプ変数から所望の発現を構築しなければならない一方で、あなたは、Float64
値の配列であることをf
を定義しています。 JuMP documentation for Nonlinear Expressionsに記載されているように、すべての非線形式は@NLexpression
マクロの内部で定義されていなければなりません。マクロではAffExpr
とQuadExpr
オブジェクトは現在使用できません。
solve
操作を経由して解決策を見つけるのコマンドの結果を以下のセット:
julia> using JuMP
julia> using Ipopt
julia> m = Model(solver=IpoptSolver(print_level=0))
Feasibility problem with:
* 0 linear constraints
* 0 variables
Solver is Ipopt
julia> @variable(m, x[i=1:2])
2-element Array{JuMP.Variable,1}:
x[1]
x[2]
julia> function bounds_BK1()
return ([-5.0;-5.0],[10.0;10.0])
end
bounds_BK1 (generic function with 1 method)
julia> @NLexpression(m, F1, x[1]^2 + x[2]^2)
JuMP.NonlinearExpression(Feasibility problem with:
* 0 linear constraints
* 2 variables
Solver is Ipopt,1)
julia> @NLexpression(m, F2, (x[1]-5.0)^2 + (x[2]-5.0)^2)
JuMP.NonlinearExpression(Feasibility problem with:
* 0 linear constraints
* 2 variables
Solver is Ipopt,2)
julia> @constraint(m, x .>= bounds_BK1()[1])
2-element Array{JuMP.ConstraintRef{JuMP.Model,JuMP.GenericRangeConstraint{JuMP.GenericAffExpr{Float64,JuMP.Variable}}},1}:
x[1] ≥ -5
x[2] ≥ -5
julia> @constraint(m, x .<= bounds_BK1()[2])
2-element Array{JuMP.ConstraintRef{JuMP.Model,JuMP.GenericRangeConstraint{JuMP.GenericAffExpr{Float64,JuMP.Variable}}},1}:
x[1] ≤ 10
x[2] ≤ 10
julia> s = solve(m)
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************
:Optimal
julia> getvalue(x)
2-element Array{Float64,1}:
0.261454
0.261454
私はあなたが希望後でfuncts_BK1
以内式の配列を構築することが現在可能であることを信じていません。 @NLexpression
に渡す必要があります。現在、Ju33変数のスカラ式を直接引数として@NLexpression
に渡す必要があります。