Skip to content

Commit

Permalink
New implementation of constraint programming.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dourouc05 committed May 5, 2020
1 parent a72e7ac commit 597a02c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/macros.jl
Expand Up @@ -188,6 +188,15 @@ function parse_constraint(_error::Function, sense::Symbol, lhs, rhs)
(sense, vectorized) = _check_vectorized(sense)
vectorized, parse_one_operator_constraint(_error, vectorized, Val(sense), lhs, rhs)...
end
function parse_constraint(_error::Function, ::Val{:call}, args...)
return parse_constraint(_error, Val(args[1]), args[2:end]...)
end

function parse_constraint(_error::Function, sense::Val, F...)
sense_symbol = typeof(sense).parameters[1]
(sense, vectorized) = _check_vectorized(sense_symbol)
vectorized, parse_one_operator_constraint(_error, vectorized, Val(sense), F...)...
end

function parse_ternary_constraint(_error::Function, vectorized::Bool, lb, ::Union{Val{:(<=)}, Val{:(≤)}}, aff, rsign::Union{Val{:(<=)}, Val{:(≤)}}, ub)
newaff, parseaff = _MA.rewrite(aff)
Expand All @@ -209,11 +218,15 @@ function parse_ternary_constraint(_error::Function, args...)
_error("Only two-sided rows of the form lb <= expr <= ub or ub >= expr >= lb are supported.")
end

<<<<<<< HEAD
function parse_constraint_head(_error::Function, ::Val{:comparison}, lb, lsign::Symbol, aff, rsign::Symbol, ub)
return parse_constraint(_error, lb, lsign, aff, rsign, ub)
end

function parse_constraint(_error::Function, lb, lsign::Symbol, aff, rsign::Symbol, ub)
=======
function parse_constraint(_error::Function, ::Val{:comparison}, lb, lsign::Symbol, aff, rsign::Symbol, ub)
>>>>>>> e8c3cca8... New implementation of constraint programming.
(lsign, lvectorized) = _check_vectorized(lsign)
(rsign, rvectorized) = _check_vectorized(rsign)
((vectorized = lvectorized) == rvectorized) || _error("Signs are inconsistently vectorized")
Expand Down

0 comments on commit 597a02c

Please sign in to comment.