Skip to content

Commit

Permalink
WIP : MOI wrapper (based on LQOI) (#27)
Browse files Browse the repository at this point in the history
* MOI interface through LQOI (Partially implemented)

* more impl.

* Finished first impl and fixed tests.

* updated to use CSR struct

* minor updates. more tests

* a few fixes

* using copy!

* removed some commented out code

* minor modifs

* some fixes

* exculded test linear11

* removed the LQOI version upperbound

* limited LQOI to 2.0 inclusive

* Tidy up. Remove unneeded docstrings, fix a few functions, enable
more tests.

* Handle infeasiblity certificates and other matters:

* Minor re-org

* Remove unneeded code

* Exclude linear11 test

* minor updates

* renaming ClpOptimizer --> Clp.Optimizer

* update requires

* enabled a test, added 0.7 to travis
  • Loading branch information
IssamT authored and odow committed Aug 14, 2018
1 parent a7c6223 commit afc14ee
Show file tree
Hide file tree
Showing 7 changed files with 459 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ os:
- osx
julia:
- 0.6
- nightly
- 0.7
notifications:
email: false
script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- julia -e 'Pkg.clone(pwd()); Pkg.build("Clp"); Pkg.test("Clp"; coverage=true)'
#after_success:
#- julia -e 'cd(Pkg.dir("Clp")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
after_success:
- julia -e 'cd(Pkg.dir("Clp")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
2 changes: 2 additions & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
julia 0.6
Compat 0.59
Cbc
MathProgBase 0.5 0.8
LinQuadOptInterface 0.3 0.4
2 changes: 2 additions & 0 deletions src/Clp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ __precompile__()

module Clp

using Compat

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

using Clp.ClpMathProgSolverInterface
export ClpSolver
Expand Down
19 changes: 17 additions & 2 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 @@ -414,16 +416,30 @@ function add_rows(model::ClpModel, number::Integer, row_lower::Vector{Float64},
row_starts::Vector{Int32}, columns::Vector{Int32},
elements::Vector{Float64})
_jl__check_model(model)

@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, nnz::Cint, columns::Vector{Int32},
elements::Vector{Float64}, row_lower::Float64, row_upper::Float64)
add_rows(model, 1, [row_lower], [row_upper], [Cint(0), nnz], 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, nnz::Int32, rows::Vector{Int32},
elements::Vector{Float64}, column_lower::Float64,
column_upper::Float64, objective::Float64)
add_columns(model, 1, [column_lower], [column_upper], [objective],
[Int32(0), nnz], rows, elements)
end

# Add columns.
function add_columns(model::ClpModel, number::Integer, column_lower::Vector{Float64},
column_upper::Vector{Float64},
Expand All @@ -440,7 +456,6 @@ function add_columns(model::ClpModel, column_lower::Vector{Float64},
column_upper::Vector{Float64},
objective::Vector{Float64},
new_columns::SparseMatrixCSC{Float64,Int32})

add_columns(model, new_columns.n, column_lower, column_upper, objective, new_columns.colptr-convert(Int32,1), new_columns.rowval-convert(Int32,1), new_columns.nzval)
end

Expand Down
Loading

0 comments on commit afc14ee

Please sign in to comment.