Skip to content
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

Performance bottlenecks in MOI_wrapper #188

Closed
guilhermebodin opened this issue Mar 1, 2023 · 0 comments · Fixed by #207
Closed

Performance bottlenecks in MOI_wrapper #188

guilhermebodin opened this issue Mar 1, 2023 · 0 comments · Fixed by #207

Comments

@guilhermebodin
Copy link
Collaborator

I noticed two parts of my worflows that could be improved in Xpress.jl

The first one is that the implemetation of reducedcost in JuMP is the following

function reduced_cost(x::VariableRef)::Float64
    model = owner_model(x)
    if !has_duals(model)
        error(
            "Unable to query reduced cost of variable because model does" *
            " not have duals available.",
        )
    end
    sign = objective_sense(model) == MIN_SENSE ? 1.0 : -1.0
    if is_fixed(x)
        return sign * dual(FixRef(x))
    end
    rc = 0.0
    if has_upper_bound(x)
        rc += dual(UpperBoundRef(x))
    end
    if has_lower_bound(x)
        rc += dual(LowerBoundRef(x))
    end
    return sign * rc
end

but when we do getlpsol Xpress could return all of the reduced cost and we could cache them directly and only query them through MOI

The second one is that whenever we have to change the bound of a variable in Xpress.jl we have this implementation

function MOI.set(
    model::Optimizer,
    ::MOI.ConstraintSet,
    c::MOI.ConstraintIndex{MOI.VariableIndex, S}, s::S
) where {S<:SCALAR_SETS}
    MOI.throw_if_not_valid(model, c)
    lower, upper = _bounds(s)
    info = _info(model, c)
    if lower == upper
        if lower !== nothing
            _set_variable_fixed_bound(model, info, lower)
        end
    else
        if lower !== nothing
            _set_variable_lower_bound(model, info, lower)
        end
        if upper !== nothing
            _set_variable_upper_bound(model, info, upper)
        end
    end
    info.previous_lower_bound = _get_variable_lower_bound(model, info)
    info.previous_upper_bound = _get_variable_upper_bound(model, info)
    return
end

but the functions _get_variable_... we have to run XPRSgetub or XPRSgetlb, could we simply store the current bound on the VariableInfo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant