Skip to content

Commit

Permalink
Merge pull request #120 from JuliaOpt/ml/effort
Browse files Browse the repository at this point in the history
expose the effortlevel parameter through CplexSolver()
  • Loading branch information
mlubin authored Mar 20, 2017
2 parents 93327ba + 846bbfe commit c603658
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ Note for windows
----------------

Currently, CPLEX.jl is compatible only with 64-bit CPLEX and 64-bit Julia on Windows. CPLEX.jl attemps to automatically find the CPLEX library based on the ``CPLEX_STUDIO_BINARIES`` environmental variable set by the CPLEX installer.


Parameters
----------

Solver parameters can be passed through the ``CplexSolver()`` object, e.g., ``CplexSolver(CPX_PARAM_EPINT=1e-8)``. Parameters match those of the CPLEX documentation. Additionally, the ``mipstart_effortlevel`` parameter can be used to tell CPLEX how much effort to put into turning warmstarts into feasible solutions, with possible values ``CPLEX.CPX_MIPSTART_AUTO``, ``CPLEX.CPX_MIPSTART_CHECKFEAS``, ``CPLEX.CPX_MIPSTART_SOLVEFIXED``, ``CPLEX.CPX_MIPSTART_SOLVEMIP``, ``CPLEX.CPX_MIPSTART_REPAIR``, and ``CPLEX.CPX_MIPSTART_NOCHECK``.
7 changes: 4 additions & 3 deletions src/CplexSolverInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ type CplexMathProgModel <: AbstractLinearQuadraticModel
incumbentcb
infocb
solvetime::Float64
mipstart_effortlevel::Cint
end

function CplexMathProgModel(;options...)
function CplexMathProgModel(;mipstart_effortlevel::Cint = CPX_MIPSTART_AUTO, options...)
env = Env()
# set_param!(env, "CPX_PARAM_MIPCBREDLP", 0) # access variables in original problem, not presolved
# set_param!(env, "CPX_PARAM_PRELINEAR", 0) # MAY NOT BE NECESSARY, only performs linear presolving so can recover original variables
Expand All @@ -20,7 +21,7 @@ function CplexMathProgModel(;options...)
set_param!(env, string(name), value)
end

m = CplexMathProgModel(Model(env), nothing, nothing, nothing, nothing, nothing, nothing, NaN)
m = CplexMathProgModel(Model(env), nothing, nothing, nothing, nothing, nothing, nothing, NaN, mipstart_effortlevel)
return m
end

Expand Down Expand Up @@ -289,7 +290,7 @@ getbasis(m::CplexMathProgModel) = get_basis(m.inner)
function setwarmstart!(m::CplexMathProgModel, v)
# This means that warm starts are ignored if you haven't called setvartype! first
if m.inner.has_int
set_warm_start!(m.inner, v)
set_warm_start!(m.inner, v, m.mipstart_effortlevel)
end
end

Expand Down
6 changes: 3 additions & 3 deletions src/cpx_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ function set_obj!(model::Model, c::Vector)
end
end

set_warm_start!(model::Model, x::Vector{Float64}) = set_warm_start!(model, Cint[1:length(x);], x)
set_warm_start!(model::Model, x::Vector{Float64}, effortlevel::Integer = CPX_MIPSTART_AUTO) = set_warm_start!(model, Cint[1:length(x);], x, effortlevel)

function set_warm_start!(model::Model, indx::IVec, val::FVec)
function set_warm_start!(model::Model, indx::IVec, val::FVec, effortlevel::Integer)
stat = @cpx_ccall(addmipstarts, Cint, (
Ptr{Void},
Ptr{Void},
Expand All @@ -168,7 +168,7 @@ function set_warm_start!(model::Model, indx::IVec, val::FVec)
Ptr{Cint},
Ptr{Ptr{Cchar}}
),
model.env.ptr, model.lp, 1, length(indx), Cint[0], indx.-1, val, Cint[CPX_MIPSTART_AUTO], C_NULL)
model.env.ptr, model.lp, 1, length(indx), Cint[0], indx -Cint(1), val, Cint[effortlevel], C_NULL)
if stat != 0
throw(CplexError(model.env, stat))
end
Expand Down

0 comments on commit c603658

Please sign in to comment.