diff --git a/src/CoinOptServices.jl b/src/CoinOptServices.jl index 5496206..4304bec 100644 --- a/src/CoinOptServices.jl +++ b/src/CoinOptServices.jl @@ -293,9 +293,16 @@ function MathProgBase.loadproblem!(outer::OsilNonlinearModel, end while nextrowlinear constrexpr = MathProgBase.constr_expr(d, row) - @assertequal(constrexpr.head, :comparison) + + if VERSION < v"0.5.0-dev+3231" + @assertequal(constrexpr.head, :comparison) + constrlinpart = constrexpr.args[end - 2] + else + @assertequal(constrexpr.head, :call) + constrlinpart = constrexpr.args[2] + end + #(lhs, rhs) = constr2bounds(constrexpr.args...) - constrlinpart = constrexpr.args[end - 2] @assertequal(constrlinpart.head, :call) constrlinargs = constrlinpart.args @assertequal(constrlinargs[1], :+) @@ -341,9 +348,15 @@ function MathProgBase.loadproblem!(outer::OsilNonlinearModel, nl = new_child(nonlinearExpressions, "nl") set_attribute(nl, "idx", row - 1) # OSiL is 0-based constrexpr = MathProgBase.constr_expr(d, row) - @assertequal(constrexpr.head, :comparison) #(lhs, rhs) = constr2bounds(constrexpr.args...) - expr2osnl!(nl, constrexpr.args[end - 2]) + if VERSION >= v"0.5.0-dev+3231" && constrexpr.head == :call + @assert(constrexpr.args[1] in [:<=, :(==), :>=]) + constrpart = constrexpr.args[2] + else + @assertequal(constrexpr.head, :comparison) + constrpart = constrexpr.args[end - 2] + end + expr2osnl!(nl, constrpart) end end diff --git a/src/translations.jl b/src/translations.jl index eb74c21..91737da 100644 --- a/src/translations.jl +++ b/src/translations.jl @@ -20,7 +20,17 @@ jl2osnl_binary = Dict( :rem => "rem", :^ => "power", :.^ => "power", - :log => "log") + :log => "log", + :< => "lt", + :<= => "leq", + :≤ => "leq", + :> => "gt", + :>= => "geq", + :≥ => "geq", + :(==) => "eq", + :!= => "neq", + :≠ => "neq") +# and, or, xor, not? jl2osnl_unary = Dict( :- => "negate", @@ -48,17 +58,19 @@ for op in [:abs, :sqrt, :floor, :factorial, :exp, :sign, :erf, jl2osnl_unary[op] = string(op) end -jl2osnl_comparison = Dict( - :< => "lt", - :<= => "leq", - :≤ => "leq", - :> => "gt", - :>= => "geq", - :≥ => "geq", - :(==) => "eq", - :!= => "neq", - :≠ => "neq") -# and, or, xor, not? +if VERSION < v"0.5.0-dev+3231" + jl2osnl_comparison = Dict( + :< => "lt", + :<= => "leq", + :≤ => "leq", + :> => "gt", + :>= => "geq", + :≥ => "geq", + :(==) => "eq", + :!= => "neq", + :≠ => "neq") + # and, or, xor, not? +end jl2osil_vartypes = Dict(:Cont => "C", :Int => "I", :Bin => "B", :SemiCont => "D", :SemiInt => "J", :Fixed => "C") @@ -155,7 +167,7 @@ function expr2osnl!(parent, ex::Expr) elseif head == :ref child = var2osnl!(parent, args) elseif head == :comparison - if numargs == 3 + if VERSION < v"0.5.0-dev+3231" && numargs == 3 if haskey(jl2osnl_comparison, args[2]) child = new_child(parent, jl2osnl_comparison[args[2]]) expr2osnl!(child, args[1])