Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Apr 3, 2024
1 parent d5d7688 commit 159c4f0
Showing 1 changed file with 13 additions and 27 deletions.
40 changes: 13 additions & 27 deletions src/MOI/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4748,43 +4748,29 @@ function _reverse_polish(
type::Vector{Cint},
value::Vector{Cdouble},
)
if f.head == :- && length(f.args) == 1
# Special handling for unary negation
if f.head == :- && length(f.args) == 1 # Special handling for unary -
push!(type, Lib.XPRS_TOK_OP)
push!(value, Lib.XPRS_OP_UMINUS)
for arg in reverse(f.args)
_reverse_polish(model, arg, type, value)
end
return

Check warning on line 4757 in src/MOI/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI/MOI_wrapper.jl#L4751-L4757

Added lines #L4751 - L4757 were not covered by tests
elseif f.head in (:+, :*) && length(f.args) != 2
# Special handling for non-binary sum and product
push!(type, Lib.XPRS_TOK_IFUN)
push!(value, f.head == :+ ? Lib.XPRS_IFUN_SUM : Lib.XPRS_IFUN_PROD)
# XPRS_TOK_LB is not needed. Implied by XPRS_TOK_IFUN
for arg in reverse(f.args)
_reverse_polish(model, arg, type, value)
end
push!(type, Lib.XPRS_TOK_RB)
push!(value, 0.0)
return
end
ret = get(_FUNCTION_MAP, f.head, nothing)
if ret === nothing
throw(MOI.UnsupportedNonlinearOperator(f.head))
elseif ret[1] == Lib.XPRS_TOK_OP
push!(type, ret[1])
push!(value, ret[2])
for arg in reverse(f.args)
_reverse_polish(model, arg, type, value)
end
else
@assert ret[1] == Lib.XPRS_TOK_IFUN
push!(type, ret[1])
push!(value, ret[2])
# XPRS_TOK_LB is not needed. Implied by XPRS_TOK_IFUN
for arg in reverse(f.args)
_reverse_polish(model, arg, type, value)
end
elseif f.head == :+ && length(f.args) != 2 # Special handling for n-ary +
ret = (Lib.XPRS_TOK_IFUN, Lib.XPRS_IFUN_SUM)
elseif f.head == :* && length(f.args) != 2 # Special handling for n-ary *
ret = (Lib.XPRS_TOK_IFUN, Lib.XPRS_IFUN_PROD)

Check warning on line 4765 in src/MOI/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI/MOI_wrapper.jl#L4759-L4765

Added lines #L4759 - L4765 were not covered by tests
end
push!(type, ret[1])
push!(value, ret[2])
for arg in reverse(f.args)
_reverse_polish(model, arg, type, value)
end
if ret[1] == Lib.XPRS_TOK_IFUN

Check warning on line 4772 in src/MOI/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI/MOI_wrapper.jl#L4767-L4772

Added lines #L4767 - L4772 were not covered by tests
# XPRS_TOK_LB is not needed because it is implied by XPRS_TOK_IFUN
push!(type, Lib.XPRS_TOK_RB)
push!(value, 0.0)

Check warning on line 4775 in src/MOI/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI/MOI_wrapper.jl#L4774-L4775

Added lines #L4774 - L4775 were not covered by tests
end
Expand Down

0 comments on commit 159c4f0

Please sign in to comment.