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 9fd9877
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/macros.jl
Expand Up @@ -177,6 +177,7 @@ function parse_one_operator_constraint(_error::Function, vectorized::Bool, sense
return parse_code, _build_call(_error, vectorized, :(_functionize($variable)), set)
end

<<<<<<< HEAD
function parse_constraint_expr(_error::Function, expr::Expr)
return parse_constraint_head(_error, Val(expr.head), expr.args...)
end
Expand All @@ -187,6 +188,16 @@ end
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)...
=======
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...)...
>>>>>>> e8c3cca8... New implementation of constraint programming.
end

function parse_ternary_constraint(_error::Function, vectorized::Bool, lb, ::Union{Val{:(<=)}, Val{:(≤)}}, aff, rsign::Union{Val{:(<=)}, Val{:(≤)}}, ub)
Expand All @@ -209,11 +220,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 9fd9877

Please sign in to comment.