Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Array input arguments in nonlinear expressions

未關閉
#2,402 5 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
25/100
Issue 類型
功能
描述清晰度
需要釐清
活躍度
停滯
技術堆疊
julia
領域
backend

研究方向

從 GenericNonlinearExpr、MOI.(Scalar,Vector)NonlinearFunction、MOI.Nonlinear,以及 issue 中描述的提議 Node 和 Expression 結構開始。追蹤目前純量非線性表達式及其導數的表示方式,然後確定陣列和矩陣輸入應如何表示和微分。完成的標準是設計和實作支援 norm(x, p) 和 log_det(X) 等範例,並包含涵蓋其導數的測試。

由索引模型根據 Issue 內容生成。

描述

Project: next-gen nonlinear support Submodule: Nonlinear

Context: Yesterday I had a chat to @rluce about nonlinear expressions, particularly as they relate to Gurobi's upcoming nonlinear interface. We broadly agree on scalar nonlinear functions, and he had some preliminary ideas for vector-inputs.

cc @ccoffrin and @chriscoey for thoughts.

Our ultimate goal is to support examples like the following:

using JuMP, Ipopt
model = Model(Ipopt.Optimizer)
@variable(model, x[1:2, 1:2])
@objective(model, Max, log(det(X)))
# or perhaps the easier to manage;
@objective(model, Max, log_det(X))
using JuMP, Ipopt
model = Model(Ipopt.Optimizer)
@variable(model, x[1:3] >= 1)
p = 2
@objective(model, Min, norm(x, p))

Another key consumer of this would be https://github.com/jump-dev/MiniZinc.jl.

Changes required in JuMP

  • We'd need to support Array in GenericNonlinearExpr and their mapping to moi_function. This seems pretty easy.

Changes required in MOI

  1. We'd need to support Array in MOI.(Scalar,Vector)NonlinearFunction. This seems pretty easy.
  2. We'd need to support Array in MOI.Nonlinear and be able to compute derivatives, etc.

The tricky part is all in 2.

We'd likely need some sort of Node(NODE_VECTOR, parent, n).

But matrices are a bit more complicated. We'd need to encode (rows, cols). One option would be to store the size as a packed value::Int64. That'd mean that we couldn't have matrices with side dimension greater than typemax(Int32)... but that seems okay.

encode(m::Int64, n::Int64) = encode(Int32(m), Int32(n))
encode(m::Int32, n::Int32) = reinterpret(Int64, (m, n))
decode(x::Int64) = Int64.(reinterpret(Tuple{Int32,Int32}, x))

norm(x) would look something like:

expr = Expression(
    [
        Node(NODE_CALL_MULTIVARIATE, -1, OP_NORM             ),
        Node(NODE_ARRAY,              1, 3 #= encode(3, 0) =#),
        Node(NODE_VARIABLE,           2, 1 #= x1 =#          ),
        Node(NODE_VARIABLE,           2, 2 #= x2 =#          ),
        Node(NODE_VARIABLE,           2, 3 #= x3 =#          ),
    ],
    [],
);

log_det(X) would then look something like:

expr = Expression(
    [
        Node(NODE_CALL_MULTIVARIATE, -1, OP_LOGDET                     ),
        Node(NODE_ARRAY,              1, 8589934594  #= encode(2, 2) =#),
        Node(NODE_VARIABLE,           2, 1 #= x11 =#                   ),
        Node(NODE_VARIABLE,           2, 2 #= x21 =#                   ),
        Node(NODE_VARIABLE,           2, 2 #= x12 =#                   ),
        Node(NODE_VARIABLE,           2, 3 #= x22 =#                   ),
    ],
    [],
);

Once you have the data structure, it seems to me that the AD should follow fairly well.

Output arguments

Still absolutely no idea.

主要語言
Julia
星號
506
分支
103
平均合併
1 天 1 小時
30 天內合併 PR
9

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

jump-dev/MathOptInterface.jl 的其他 Issue

查看 jump-dev/MathOptInterface.jl 的全部 Issue

相似的 Issue

更多 Julia Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。