55
66# tools for JuMP functions
77
8- function add_cuts (cuts:: Vector{AE } , opt:: Optimizer , viol_only:: Bool )
8+ function add_cuts (cuts:: Vector{JuMP.AffExpr } , opt:: Optimizer , viol_only:: Bool )
99 if viol_only
1010 # filter out unviolated cuts
1111 cuts = filter (cut -> get_value (cut, opt. lazy_cb) < - opt. tol_feas, cuts)
@@ -16,22 +16,28 @@ function add_cuts(cuts::Vector{AE}, opt::Optimizer, viol_only::Bool)
1616 return ! isempty (cuts)
1717end
1818
19- function _add_cuts (cuts:: Vector{AE } , model:: JuMP.Model , :: Nothing )
19+ function _add_cuts (cuts:: Vector{JuMP.AffExpr } , model:: JuMP.Model , :: Nothing )
2020 JuMP. @constraint (model, cuts .>= 0 )
2121 return
2222end
2323
24- function _add_cuts (cuts:: Vector{AE } , model:: JuMP.Model , cb)
24+ function _add_cuts (cuts:: Vector{JuMP.AffExpr } , model:: JuMP.Model , cb)
2525 cons = JuMP. @build_constraint (cuts .>= 0 )
2626 MOI. submit .(model, MOI. LazyConstraint (cb), cons)
2727 return
2828end
2929
30- get_value (expr:: Union{VR,AE} , :: Nothing ) = JuMP. value (expr)
30+ function get_value (expr:: Union{JuMP.VariableRef,JuMP.AffExpr} , :: Nothing )
31+ return JuMP. value (expr)
32+ end
3133
32- get_value (expr:: Union{VR,AE} , cb) = JuMP. callback_value (cb, expr)
34+ function get_value (expr:: Union{JuMP.VariableRef,JuMP.AffExpr} , cb)
35+ return JuMP. callback_value (cb, expr)
36+ end
3337
34- get_value (exprs:: Vector{<:Union{VR,AE}} , cb) = [get_value (e, cb) for e in exprs]
38+ function get_value (exprs:: Vector{<:Union{JuMP.VariableRef,JuMP.AffExpr}} , cb)
39+ return [get_value (e, cb) for e in exprs]
40+ end
3541
3642function check_set_time_limit (opt:: Optimizer , model:: JuMP.Model )
3743 time_left = opt. time_limit - time () + opt. solve_time
0 commit comments