-
Notifications
You must be signed in to change notification settings - Fork 63
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
Delete constraint(s), add and remove multiple warmstarts #121
Closed
Closed
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
665175a
Added add_warm_start!, del_warm_start!
363d2af
Update cpx_model.jl
badadba
Added del_constrs!
324fa2a
Updated del_constrs!
855113a
Add and delete multiple warm starts with effort levels
1bb9042
Changed add_warm_start! -> set_warm_start! and removed type annotation
832185c
start -> starts wherever applicable
f66d12a
warm_start(s) -> mip_start(s)
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,6 +174,57 @@ function set_warm_start!(model::Model, indx::IVec, val::FVec, effortlevel::Integ | |
end | ||
end | ||
|
||
function add_warm_start!(model::Model, x::Vector{Vector{Float64}}, efforts::Vector{Cint}) | ||
beg::Vector{Cint}, inds::Vector{Cint}, vals::Vector{Cdouble} = Cint[], Cint[], Cdouble[] | ||
count::Int64 = 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type annotation here shouldn't be necessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry about that. Its just an old habit. |
||
for i in 1:length(x) | ||
push!(beg, count) | ||
for j in 1:length(x[i]) | ||
push!(inds, j) | ||
push!(vals, x[i][j]) | ||
count += 1 | ||
end | ||
end | ||
add_warm_start!(model, convert(Cint, length(x)), beg, inds, vals, efforts) | ||
end | ||
|
||
add_warm_start!{T<:Signed}(model::Model, x::Vector{Float64}, effort::T) = add_warm_start!(model, convert(Cint, 1), Cint[1], Cint[1:length(x);], x, [convert(Cint, effort)]) | ||
|
||
function add_warm_start!(model::Model, num_warm_starts::Cint, beg::Vector{Cint}, inds::Vector{Cint}, vals::Vector{Cdouble}, efforts::Vector{Cint}) | ||
stat = @cpx_ccall(addmipstarts, Cint, ( | ||
Ptr{Void}, | ||
Ptr{Void}, | ||
Cint, | ||
Cint, | ||
Ptr{Cint}, | ||
Ptr{Cint}, | ||
Ptr{Cdouble}, | ||
Ptr{Cint}, | ||
Ptr{Ptr{Cchar}} | ||
), | ||
model.env.ptr, model.lp, num_warm_starts, length(inds), beg - 1, inds - 1, vals, efforts, fill(C_NULL, num_warm_starts)) | ||
if stat != 0 | ||
throw(CplexError(model.env, stat)) | ||
end | ||
end | ||
|
||
del_warm_start!{T<:Signed}(model::Model, ind::T) = del_warm_start!(model, convert(Cint, ind), convert(Cint, ind)) | ||
|
||
del_warm_start!{T<:Signed}(model::Model, start_ind::T, end_ind::T) = del_warm_start!(model, convert(Cint, start_ind), convert(Cint, end_ind)) | ||
|
||
function del_warm_start!(model::Model, start_ind::Cint, end_ind::Cint) | ||
stat = @cpx_ccall(delmipstarts, Cint, ( | ||
Ptr{Void}, | ||
Ptr{Void}, | ||
Cint, | ||
Cint | ||
), | ||
model.env.ptr, model.lp, start_ind-1, end_ind-1) | ||
if stat != 0 | ||
throw(CplexError(model.env, stat)) | ||
end | ||
end | ||
|
||
function free_problem(model::Model) | ||
tmp = Ptr{Void}[model.lp] | ||
stat = @cpx_ccall(freeprob, Cint, (Ptr{Void}, Ptr{Void}), model.env.ptr, tmp) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not crazy about the naming here. Probably better to write this as
set_warm_starts!
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure