-
-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add parse_constraint_expr and parse_constraint_head #2228
Conversation
This would allow to have constraints like:
which was a possible syntax for the reified constraint. One can implement:
in that case which wasn't possible before with the |
6300d61
to
a6f7948
Compare
Codecov Report
@@ Coverage Diff @@
## master #2228 +/- ##
==========================================
- Coverage 91.17% 91.16% -0.02%
==========================================
Files 42 42
Lines 4159 4165 +6
==========================================
+ Hits 3792 3797 +5
- Misses 367 368 +1
Continue to review full report at Codecov.
|
Add support for reification. Things moved to https://github.com/dourouc05/JuCP.jl Update macros.jl Pass the same type of argument to the different calls to parsefun. Restore two definitions of parse_constraint to avoid ambiguity. LoadError: LoadError: MethodError: parse_constraint(::JuMP.var"#_error#70"{Symbol}, ::Symbol, ::Symbol, ::Expr, ::Symbol, ::Symbol) is ambiguous. Candidates: parse_constraint(_error::Function, sense::Symbol, args...) in JuMP at C:\Users\Thibaut\.julia\dev\JuMP\src\macros.jl:180 parse_constraint(_error::Function, lb, lsign::Symbol, aff, rsign::Symbol, ub) in JuMP at C:\Users\Thibaut\.julia\dev\JuMP\src\macros.jl:205 Implement more closely @blegat's suggestion. Also adapt build_constraint. Also adapt indicator constraints. Also adapt SD constraint. For :call constraint, dispatch on the first argument. Clean up. Make tests pass. Useless extension point. Allow rewriting the rhs of a comparison constraint. Bug fixing (due to MA?). Don't break user code. If the constraint looks like `== f(x)`, whatever f or x, the previous code would always think the function f must be known by JuMP. Reduce diff size. @blegat's comments. Simplify PR wrt jump-dev#2228. Simplify PR wrt jump-dev#2228. Clean PR wrt jump-dev#2229.
Add support for reification. Things moved to https://github.com/dourouc05/JuCP.jl Update macros.jl Pass the same type of argument to the different calls to parsefun. Restore two definitions of parse_constraint to avoid ambiguity. LoadError: LoadError: MethodError: parse_constraint(::JuMP.var"#_error#70"{Symbol}, ::Symbol, ::Symbol, ::Expr, ::Symbol, ::Symbol) is ambiguous. Candidates: parse_constraint(_error::Function, sense::Symbol, args...) in JuMP at C:\Users\Thibaut\.julia\dev\JuMP\src\macros.jl:180 parse_constraint(_error::Function, lb, lsign::Symbol, aff, rsign::Symbol, ub) in JuMP at C:\Users\Thibaut\.julia\dev\JuMP\src\macros.jl:205 Implement more closely @blegat's suggestion. Also adapt build_constraint. Also adapt indicator constraints. Also adapt SD constraint. For :call constraint, dispatch on the first argument. Clean up. Make tests pass. Useless extension point. Allow rewriting the rhs of a comparison constraint. Bug fixing (due to MA?). Don't break user code. If the constraint looks like `== f(x)`, whatever f or x, the previous code would always think the function f must be known by JuMP. Reduce diff size. @blegat's comments. Simplify PR wrt jump-dev#2228. Simplify PR wrt jump-dev#2228. Clean PR wrt jump-dev#2229.
Add support for reification. Things moved to https://github.com/dourouc05/JuCP.jl Update macros.jl Pass the same type of argument to the different calls to parsefun. Restore two definitions of parse_constraint to avoid ambiguity. LoadError: LoadError: MethodError: parse_constraint(::JuMP.var"#_error#70"{Symbol}, ::Symbol, ::Symbol, ::Expr, ::Symbol, ::Symbol) is ambiguous. Candidates: parse_constraint(_error::Function, sense::Symbol, args...) in JuMP at C:\Users\Thibaut\.julia\dev\JuMP\src\macros.jl:180 parse_constraint(_error::Function, lb, lsign::Symbol, aff, rsign::Symbol, ub) in JuMP at C:\Users\Thibaut\.julia\dev\JuMP\src\macros.jl:205 Implement more closely @blegat's suggestion. Also adapt build_constraint. Also adapt indicator constraints. Also adapt SD constraint. For :call constraint, dispatch on the first argument. Clean up. Make tests pass. Useless extension point. Allow rewriting the rhs of a comparison constraint. Bug fixing (due to MA?). Don't break user code. If the constraint looks like `== f(x)`, whatever f or x, the previous code would always think the function f must be known by JuMP. Reduce diff size. @blegat's comments. Simplify PR wrt jump-dev#2228. Simplify PR wrt jump-dev#2228. Clean PR wrt jump-dev#2229.
Add support for reification. Things moved to https://github.com/dourouc05/JuCP.jl Update macros.jl Pass the same type of argument to the different calls to parsefun. Restore two definitions of parse_constraint to avoid ambiguity. LoadError: LoadError: MethodError: parse_constraint(::JuMP.var"#_error#70"{Symbol}, ::Symbol, ::Symbol, ::Expr, ::Symbol, ::Symbol) is ambiguous. Candidates: parse_constraint(_error::Function, sense::Symbol, args...) in JuMP at C:\Users\Thibaut\.julia\dev\JuMP\src\macros.jl:180 parse_constraint(_error::Function, lb, lsign::Symbol, aff, rsign::Symbol, ub) in JuMP at C:\Users\Thibaut\.julia\dev\JuMP\src\macros.jl:205 Implement more closely @blegat's suggestion. Also adapt build_constraint. Also adapt indicator constraints. Also adapt SD constraint. For :call constraint, dispatch on the first argument. Clean up. Make tests pass. Useless extension point. Allow rewriting the rhs of a comparison constraint. Bug fixing (due to MA?). Don't break user code. If the constraint looks like `== f(x)`, whatever f or x, the previous code would always think the function f must be known by JuMP. Reduce diff size. @blegat's comments. Simplify PR wrt jump-dev#2228. Simplify PR wrt jump-dev#2228. Clean PR wrt jump-dev#2229.
Add support for reification. Things moved to https://github.com/dourouc05/JuCP.jl Update macros.jl Pass the same type of argument to the different calls to parsefun. Restore two definitions of parse_constraint to avoid ambiguity. LoadError: LoadError: MethodError: parse_constraint(::JuMP.var"#_error#70"{Symbol}, ::Symbol, ::Symbol, ::Expr, ::Symbol, ::Symbol) is ambiguous. Candidates: parse_constraint(_error::Function, sense::Symbol, args...) in JuMP at C:\Users\Thibaut\.julia\dev\JuMP\src\macros.jl:180 parse_constraint(_error::Function, lb, lsign::Symbol, aff, rsign::Symbol, ub) in JuMP at C:\Users\Thibaut\.julia\dev\JuMP\src\macros.jl:205 Implement more closely @blegat's suggestion. Also adapt build_constraint. Also adapt indicator constraints. Also adapt SD constraint. For :call constraint, dispatch on the first argument. Clean up. Make tests pass. Useless extension point. Allow rewriting the rhs of a comparison constraint. Bug fixing (due to MA?). Don't break user code. If the constraint looks like `== f(x)`, whatever f or x, the previous code would always think the function f must be known by JuMP. Reduce diff size. @blegat's comments. Simplify PR wrt jump-dev#2228. Simplify PR wrt jump-dev#2228. Clean PR wrt jump-dev#2229.
This PR continues #2051. We avoid breaking the
parse_constraint
API. We might consider renamingparse_constraint
inparse_call_constraint
andparse_constraint_head
inparse_constraint
but this might be breaking. We can consider this renaming just before we plan to release JuMP v0.22 or v1.0.Allow parsing of non-
:call
expressions in@constraint
.@dourouc05 Could you provide an example use case for this ?
This is point 1) of #2051 (comment)