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

WIP : MOI wrapper (based on LQOI) #27

Merged
merged 23 commits into from
Aug 14, 2018
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
julia 0.6
Cbc
MathProgBase 0.5 0.8
LinQuadOptInterface 0.1 0.3
1 change: 1 addition & 0 deletions src/Clp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Clp

include("ClpCInterface.jl")
include("ClpSolverInterface.jl")
include("MOIWrapper.jl")

using Clp.ClpMathProgSolverInterface
export ClpSolver
Expand Down
26 changes: 26 additions & 0 deletions src/ClpCInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export
resize,
delete_rows,
add_rows,
add_row,
delete_columns,
add_column,
add_columns,
chg_row_lower,
chg_row_upper,
Expand Down Expand Up @@ -418,12 +420,36 @@ function add_rows(model::ClpModel, number::Integer, row_lower::Vector{Float64},
@clp_ccall addRows Void (Ptr{Void}, Int32, Ptr{Float64}, Ptr{Float64}, Ptr{Int32}, Ptr{Int32}, Ptr{Float64}) model.p number row_lower row_upper row_starts columns elements
end

#This function exists in cpp but not c interface
function add_row(model::ClpModel, number_in_row::Integer, columns::Vector{Int32}, elements::Vector{Float64},
row_lower::Float64, row_upper::Float64)
row_starts_vector = Vector{Int32}(2)
row_starts_vector[1] = 0
row_starts_vector[2] = number_in_row
row_upper_vector = [row_upper]
row_lower_vector = [row_lower]
add_rows(model, 1, row_lower_vector, row_upper_vector, row_starts_vector, columns, elements)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it just as simple to go
add_rows(model, 1, [row_lower], [row_upper], [0, number_in_row], columns, elements)

end

# Delete columns.
function delete_columns(model::ClpModel, which::Vector{Int32})
_jl__check_model(model)
@clp_ccall deleteColumns Void (Ptr{Void},Int32,Ptr{Int32}) model.p length(which) which
end

#This function exists in cpp but not c interface
function add_column(model::ClpModel, number_in_column::Integer, rows::Vector{Int32},
elements::Vector{Float64}, column_lower::Float64,
column_upper::Float64, objective::Float64)
_column_starts = Vector{Int32}(2)
_column_starts[1] = 0
_column_starts[2] = number_in_column
_column_upper = [column_upper]
_column_lower = [column_lower]
_objective = [objective]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto here, or at least no underscore variable names

add_columns(model, 1, _column_lower, _column_upper, _objective, _column_starts, rows, elements)
end

# Add columns.
function add_columns(model::ClpModel, number::Integer, column_lower::Vector{Float64},
column_upper::Vector{Float64},
Expand Down
Loading