Skip to content

Commit

Permalink
Various fixes (#262)
Browse files Browse the repository at this point in the history
* fix getname in logs

* fix promote rule of bounds

* fill_dual_result tol
  • Loading branch information
guimarqu authored Feb 25, 2020
1 parent 07e86ba commit 82c3da8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/Algorithm/record.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ end
function apply_data!(form::Formulation, var::Variable, var_state::VarState)
# Bounds
if getcurlb(form, var) != var_state.lb || getcurub(form, var) != var_state.ub
@logmsg LogLevel(-2) string("Reseting bounds of variable ", getname(var))
@logmsg LogLevel(-2) string("Reseting bounds of variable ", getname(form, var))
setcurlb!(form, var, var_state.lb)
setcurub!(form, var, var_state.ub)
@logmsg LogLevel(-3) string("New lower bound is ", getcurlb(form, var))
@logmsg LogLevel(-3) string("New upper bound is ", getcurub(form, var))
end
# Cost
if getcurcost(form, var) != var_state.cost
@logmsg LogLevel(-2) string("Reseting cost of variable ", getname(var))
@logmsg LogLevel(-2) string("Reseting cost of variable ", getname(form, var))
setcurcost!(form, var, var_state.cost)
@logmsg LogLevel(-3) string("New cost is ", getcurcost(form, var))
end
Expand All @@ -108,7 +108,7 @@ end
function apply_data!(form::Formulation, constr::Constraint, constr_state::ConstrState)
# Rhs
if getcurrhs(form, constr) != constr_state.rhs
@logmsg LogLevel(-2) string("Reseting rhs of constraint ", getname(constr))
@logmsg LogLevel(-2) string("Reseting rhs of constraint ", getname(form, constr))
setrhs!(form, constr, constr_state.rhs)
@logmsg LogLevel(-3) string("New rhs is ", getcurrhs(form, constr))
end
Expand All @@ -117,7 +117,7 @@ end

function reset_var_constr!(form::Formulation, active_var_constrs, var_constrs_in_formulation)
for (id, vc) in var_constrs_in_formulation
@logmsg LogLevel(-4) "Checking " getname(vc)
@logmsg LogLevel(-4) "Checking " getname(form, vc)
# vc should NOT be active but is active in formulation
if !haskey(active_var_constrs, id) && getcurisactive(form, vc)
@logmsg LogLevel(-4) "Deactivating"
Expand Down
2 changes: 1 addition & 1 deletion src/Containers/solsandbounds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ end
Base.promote_rule(B::Type{<:Bound}, ::Type{<:AbstractFloat}) = B
Base.promote_rule(B::Type{<:Bound}, ::Type{<:Integer}) = B
Base.promote_rule(B::Type{<:Bound}, ::Type{<:AbstractIrrational}) = B
Base.promote_rule(::Type{Bound{Primal,Se}}, ::Type{Bound{Dual,Se}}) where {Se<:Coluna.AbstractSense} = Float64
Base.promote_rule(::Type{<:Bound{<:Primal,Se}}, ::Type{<:Bound{<:Dual,Se}}) where {Se<:Coluna.AbstractSense} = Float64

Base.convert(::Type{<:AbstractFloat}, b::Bound) = b.value
Base.convert(::Type{<:Integer}, b::Bound) = b.value
Expand Down
3 changes: 2 additions & 1 deletion src/MathProg/MOIinterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ function fill_dual_result!(optimizer::MoiOptimizer,
for (id, constr) in constrs
moi_index = getindex(getmoirecord(constr))
val = MOI.get(inner, MOI.ConstraintDual(res_idx), moi_index)
if val > 0.000001 || val < - 0.000001 # todo use a tolerance
val = round(val, digits = Coluna._params_.tol_digits)
if abs(val) > Coluna._params_.tol
@logmsg LogLevel(-4) string("Constr ", constr.name, " = ", val)
push!(solconstrs, id)
push!(solvals, val)
Expand Down

0 comments on commit 82c3da8

Please sign in to comment.