Skip to content

Retrieving the basis solution #444

Closed
@matheusdiogenesandrade

Description

@matheusdiogenesandrade

Hello.

I am trying to obtain the status of variables in the basis solution. The issue covered this topic with a previous version of this package. But, it seems that the proposed solution doesn't work for the current package version, so, I took the time to try to write my own function for this, but I am struggling in the step for retrieving the corresponding variables mapping.

For instance, let's consider the following use case.

model = direct_model(CPLEX.Optimizer())
@variable(model, y[["a", "b"]])
# constraints

optimize!(model)

c_basis, r_basis = get_basis(model)

# c_basis["a"] =  CPX_AT_LOWER	        0	variable y["a"] at lower bound
#                 CPX_BASIC	        1	variable y["a"] is basic
#                 CPX_AT_UPPER	        2	variable y["a"] at upper bound
#                 CPX_FREE_SUPER	3	variable y["a"] free and nonbasic

A "partial snippet" is given below.

function get_basis(model::Model)
    cval = Vector{Cint}(num_variables(model))
    rval = Vector{Cint}(num_constraints(model))

    ret = CPXgetbase(model.moi_backend.env, model.moi_backend.lp, cval, rval)
    ret != 0 && throw(PROPEREXCEPTION(model.moi_backend.env, ret))
    # ...
end

I would like to know how I could complete the above function.

Thanks and regards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions