@@ -173,6 +173,9 @@ Parse `expr` into `f` and return a `_Node`.
173
173
This function gets called recursively.
174
174
"""
175
175
function _Node (f:: _Function , expr:: Expr )
176
+ if Meta. isexpr (expr, :|| ) || Meta. isexpr (expr, :&& )
177
+ return _Node (f, expr. head, (_Node (f, arg) for arg in expr. args). .. )
178
+ end
176
179
@assert Meta. isexpr (expr, :call )
177
180
# Performance optimization: most calls will be unary or binary
178
181
# operators. Therefore, we can specialize an if-statement to handle the
@@ -219,6 +222,10 @@ function _expr_to_symbolics(model::MOI.Nonlinear.Model, expr::_Node, p, x)
219
222
args = [_expr_to_symbolics (model, c, p, x) for c in expr. children]
220
223
if hasproperty (Base, expr. operation)
221
224
return getproperty (Base, expr. operation)(args... )
225
+ elseif expr. operation == :&&
226
+ return (& )(args... )
227
+ elseif expr. operation == :||
228
+ return (| )(args... )
222
229
end
223
230
# If the function isn't defined in Base, defer to the operator registry.
224
231
# We don't do this for all functions, because MOI uses NaNMath, which
@@ -518,6 +525,10 @@ function _to_expr(
518
525
MOI. VariableIndex (variable_order[node. index])
519
526
elseif node. type == MOI. Nonlinear. NODE_PARAMETER
520
527
data. parameters[node. index]
528
+ elseif node. type == MOI. Nonlinear. NODE_LOGIC
529
+ Expr (data. operators. logic_operators[node. index])
530
+ elseif node. type == MOI. Nonlinear. NODE_COMPARISON
531
+ Expr (:call , data. operators. comparison_operators[node. index])
521
532
else
522
533
@assert node. type == MOI. Nonlinear. NODE_VALUE
523
534
expr. values[node. index]
0 commit comments