From 892bc1f5ffa8fd5e1845cda4a299632f7f0ae80e Mon Sep 17 00:00:00 2001 From: odow Date: Fri, 29 Sep 2023 12:09:37 +1300 Subject: [PATCH] Update --- docs/src/developers/extensions.md | 8 ++++---- src/constraints.jl | 13 ++----------- test/test_macros.jl | 4 ++-- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/docs/src/developers/extensions.md b/docs/src/developers/extensions.md index cf65e9a8a92..d638b59d29b 100644 --- a/docs/src/developers/extensions.md +++ b/docs/src/developers/extensions.md @@ -200,11 +200,11 @@ julia> model = Model(); @variable(model, x); julia> function JuMP.parse_constraint_head( _error::Function, - ::Val{:≡}, + ::Val{:≝}, lhs, rhs, ) - println("Rewriting ≡ as ==") + println("Rewriting ≝ as ==") new_lhs, parse_code = MutableArithmetics.rewrite(lhs) build_code = :( build_constraint($(_error), $(new_lhs), MOI.EqualTo($(rhs))) @@ -212,8 +212,8 @@ julia> function JuMP.parse_constraint_head( return false, parse_code, build_code end -julia> @constraint(model, x + x ≡ 1.0) -Rewriting ≡ as == +julia> @constraint(model, x + x ≝ 1.0) +Rewriting ≝ as == 2 x = 1 ``` diff --git a/src/constraints.jl b/src/constraints.jl index aaca4009e38..6d4cb9e6c2e 100644 --- a/src/constraints.jl +++ b/src/constraints.jl @@ -1543,13 +1543,7 @@ function relax_with_penalty!( return relax_with_penalty!(model, Dict(); default = default) end - -function parse_constraint_head( - error_fn::Function, - ::Val{:(:=)}, - lhs, - rhs, -) +function parse_constraint_head(error_fn::Function, ::Val{:(:=)}, lhs, rhs) new_lhs, parse_code_lhs = _rewrite_expression(lhs) new_rhs, parse_code_rhs = _rewrite_expression(rhs) parse_code = quote @@ -1562,10 +1556,7 @@ function parse_constraint_head( elseif $new_lhs isa Bool ScalarConstraint($new_rhs, MOI.EqualTo($new_lhs)) else - ScalarConstraint( - op_equal_to($new_lhs, $new_rhs), - MOI.EqualTo(true), - ) + ScalarConstraint(op_equal_to($new_lhs, $new_rhs), MOI.EqualTo(true)) end end return false, parse_code, build_code diff --git a/test/test_macros.jl b/test/test_macros.jl index ee665eaf346..f2df0c24ed2 100644 --- a/test/test_macros.jl +++ b/test/test_macros.jl @@ -89,7 +89,7 @@ end struct CustomType end -function JuMP.parse_constraint_head(_error::Function, ::Val{:≡}, lhs, rhs) +function JuMP.parse_constraint_head(_error::Function, ::Val{:≝}, lhs, rhs) return false, :(), :(build_constraint($_error, $(esc(lhs)), $(esc(rhs)))) end @@ -326,7 +326,7 @@ function test_extension_custom_expression_test( ) model = ModelType() @variable(model, x) - @constraint(model, con_ref, x ≡ CustomType()) + @constraint(model, con_ref, x ≝ CustomType()) con = constraint_object(con_ref) @test jump_function(con) == x @test moi_set(con) isa CustomSet