Skip to content

Commit

Permalink
Merge pull request #70 from matbesancon/v07
Browse files Browse the repository at this point in the history
v0.7 & v1.0 compatibility
  • Loading branch information
rschwarz authored Oct 21, 2018
2 parents ff15a83 + 3346b4c commit 6f6b90f
Show file tree
Hide file tree
Showing 13 changed files with 215 additions and 187 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ deps/deps.jl
deps/downloads/
deps/src/
deps/usr/
deps/build.log
/test/test.lp
/test/test.mps
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ language: julia
os:
- linux
julia:
- 0.6
- 0.7
- 1.0
dist: trusty
sudo: required
services:
Expand Down
3 changes: 1 addition & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
julia 0.6
julia 0.7
BinDeps
MathProgBase 0.5 0.8
Compat 0.8.6
2 changes: 2 additions & 0 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using BinDeps

using Libdl

include("csip_version.jl")

CSIP_URL = "https://github.com/SCIP-Interfaces/CSIP/archive/v$(CSIP_VERSION).zip"
Expand Down
14 changes: 9 additions & 5 deletions src/SCIP.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
__precompile__()

module SCIP

import Compat

if isfile(joinpath(dirname(@__FILE__),"..","deps","deps.jl"))
include("../deps/deps.jl")
else
Expand All @@ -12,7 +8,15 @@ end

include("../deps/csip_version.jl")

importall MathProgBase.SolverInterface
using SparseArrays: issparse, findnz

import MathProgBase
import MathProgBase.SolverInterface: AbstractLinearQuadraticModel,
AbstractNonlinearModel,
AbstractMathProgSolver,
MathProgCallbackData,
AbstractNLPEvaluator,
LinearQuadraticModel

include("types.jl")
include("csip_wrapper.jl")
Expand Down
96 changes: 48 additions & 48 deletions src/csip_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,47 @@ function _patchVersion()
end

function _freeModel(inner::SCIPModel)
ccall((:CSIPfreeModel, libcsip), Cint, (Ptr{Void}, ), inner.ptr_model)
ccall((:CSIPfreeModel, libcsip), Cint, (Ptr{Cvoid}, ), inner.ptr_model)
end

function _addVar(model::SCIPMathProgModel, lowerbound::Cdouble,
upperbound::Cdouble, vartype::Cint, idx::Ptr{Cint})
ccall((:CSIPaddVar, libcsip), Cint,
(Ptr{Void}, Cdouble, Cdouble, Cint, Ptr{Cint}),
(Ptr{Cvoid}, Cdouble, Cdouble, Cint, Ptr{Cint}),
model.inner.ptr_model, lowerbound, upperbound, vartype, idx)
end

function _chgVarLB(model::SCIPMathProgModel, numindices::Cint,
indices::Vector{Cint}, lowerbounds::Vector{Cdouble})
ccall((:CSIPchgVarLB, libcsip), Cint,
(Ptr{Void}, Cint, Ptr{Cint}, Ptr{Cdouble}),
(Ptr{Cvoid}, Cint, Ptr{Cint}, Ptr{Cdouble}),
model.inner.ptr_model, numindices, indices, lowerbounds)
end

function _chgVarUB(model::SCIPMathProgModel, numindices::Cint,
indices::Vector{Cint}, upperbounds::Vector{Cdouble})
ccall((:CSIPchgVarUB, libcsip), Cint,
(Ptr{Void}, Cint, Ptr{Cint}, Ptr{Cdouble}),
(Ptr{Cvoid}, Cint, Ptr{Cint}, Ptr{Cdouble}),
model.inner.ptr_model, numindices, indices, upperbounds)
end

function _getVarType(model::SCIPMathProgModel, varindex::Cint)
ccall((:CSIPgetVarType, libcsip), Cint,
(Ptr{Void}, Cint),
(Ptr{Cvoid}, Cint),
model.inner.ptr_model, varindex)
end

function _chgVarType(model::SCIPMathProgModel, varindex::Cint, vartype::Cint)
ccall((:CSIPchgVarType, libcsip), Cint,
(Ptr{Void}, Cint, Cint),
(Ptr{Cvoid}, Cint, Cint),
model.inner.ptr_model, varindex, vartype)
end

function _addLinCons(model::SCIPMathProgModel, numindices::Cint,
indices::Vector{Cint}, coefs::Vector{Cdouble},
lhs::Cdouble, rhs::Cdouble, idx::Ptr{Cint})
ccall((:CSIPaddLinCons, libcsip), Cint,
(Ptr{Void}, Cint, Ptr{Cint}, Ptr{Cdouble}, Cdouble, Cdouble, Ptr{Cint}),
(Ptr{Cvoid}, Cint, Ptr{Cint}, Ptr{Cdouble}, Cdouble, Cdouble, Ptr{Cint}),
model.inner.ptr_model, numindices, indices, coefs, lhs, rhs, idx)
end

Expand All @@ -63,7 +63,7 @@ function _addQuadCons(model::SCIPMathProgModel, numlinindices::Cint,
quadcolindices::Vector{Cint}, quadcoefs::Vector{Cdouble},
lhs::Cdouble, rhs::Cdouble, idx::Ptr{Cint})
ccall((:CSIPaddQuadCons, libcsip), Cint,
(Ptr{Void}, Cint, Ptr{Cint}, Ptr{Cdouble}, Cint, Ptr{Cint}, Ptr{Cint},
(Ptr{Cvoid}, Cint, Ptr{Cint}, Ptr{Cdouble}, Cint, Ptr{Cint}, Ptr{Cint},
Ptr{Cdouble}, Cdouble, Cdouble, Ptr{Cint}),
model.inner.ptr_model, numlinindices, linindices, lincoefs, numquadterms,
quadrowindices, quadcolindices, quadcoefs, lhs, rhs, idx)
Expand All @@ -74,30 +74,30 @@ function _addNonLinCons(model::SCIPMathProgModel, nops::Cint,
beg::Vector{Cint}, values::Vector{Cdouble},
lhs::Cdouble, rhs::Cdouble, idx::Ptr{Cint})
ccall((:CSIPaddNonLinCons, libcsip), Cint,
(Ptr{Void}, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cdouble}, Cdouble, Cdouble, Ptr{Cint}),
(Ptr{Cvoid}, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cdouble}, Cdouble, Cdouble, Ptr{Cint}),
model.inner.ptr_model, nops, ops, children, beg, values, lhs, rhs, idx)
end

function _addSOS1(model::SCIPMathProgModel, numindices::Cint,
indices::Vector{Cint}, weights::Vector{Cdouble},
idx::Ptr{Cint})
ccall((:CSIPaddSOS1, libcsip), Cint,
(Ptr{Void}, Cint, Ptr{Cint}, Ptr{Cdouble}, Ptr{Cint}),
(Ptr{Cvoid}, Cint, Ptr{Cint}, Ptr{Cdouble}, Ptr{Cint}),
model.inner.ptr_model, numindices, indices, weights, idx)
end

function _addSOS2(model::SCIPMathProgModel, numindices::Cint,
indices::Vector{Cint}, weights::Vector{Cdouble},
idx::Ptr{Cint})
ccall((:CSIPaddSOS2, libcsip), Cint,
(Ptr{Void}, Cint, Ptr{Cint}, Ptr{Cdouble}, Ptr{Cint}),
(Ptr{Cvoid}, Cint, Ptr{Cint}, Ptr{Cdouble}, Ptr{Cint}),
model.inner.ptr_model, numindices, indices, weights, idx)
end

function _setObj(model::SCIPMathProgModel, numindices::Cint,
indices::Vector{Cint}, coefs::Vector{Cdouble})
ccall((:CSIPsetObj, libcsip), Cint,
(Ptr{Void}, Cint, Ptr{Cint}, Ptr{Cdouble}),
(Ptr{Cvoid}, Cint, Ptr{Cint}, Ptr{Cdouble}),
model.inner.ptr_model, numindices, indices, coefs)
end

Expand All @@ -106,7 +106,7 @@ function _setQuadObj(model::SCIPMathProgModel, numlinindices::Cint,
numquadterms::Cint, quadrowindices::Vector{Cint},
quadcolindices::Vector{Cint}, quadcoefs::Vector{Cdouble})
ccall((:CSIPsetQuadObj, libcsip), Cint,
(Ptr{Void}, Cint, Ptr{Cint}, Ptr{Cdouble}, Cint, Ptr{Cint}, Ptr{Cint},
(Ptr{Cvoid}, Cint, Ptr{Cint}, Ptr{Cdouble}, Cint, Ptr{Cint}, Ptr{Cint},
Ptr{Cdouble}),
model.inner.ptr_model, numlinindices, linindices, lincoefs, numquadterms,
quadrowindices, quadcolindices, quadcoefs)
Expand All @@ -116,148 +116,148 @@ function _setNonlinearObj(model::SCIPMathProgModel, nops::Cint,
ops::Vector{Cint}, children::Vector{Cint},
beg::Vector{Cint}, values::Vector{Cdouble})
ccall((:CSIPsetNonlinearObj, libcsip), Cint,
(Ptr{Void}, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cdouble}),
(Ptr{Cvoid}, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cdouble}),
model.inner.ptr_model, nops, ops, children, beg, values)
end

function _setSenseMinimize(model::SCIPMathProgModel)
ccall((:CSIPsetSenseMinimize, libcsip), Cint, (Ptr{Void}, ), model.inner.ptr_model)
ccall((:CSIPsetSenseMinimize, libcsip), Cint, (Ptr{Cvoid}, ), model.inner.ptr_model)
end

function _setSenseMaximize(model::SCIPMathProgModel)
ccall((:CSIPsetSenseMaximize, libcsip), Cint, (Ptr{Void}, ), model.inner.ptr_model)
ccall((:CSIPsetSenseMaximize, libcsip), Cint, (Ptr{Cvoid}, ), model.inner.ptr_model)
end

function _solve(model::SCIPMathProgModel)
ccall((:CSIPsolve, libcsip), Cint, (Ptr{Void}, ), model.inner.ptr_model)
ccall((:CSIPsolve, libcsip), Cint, (Ptr{Cvoid}, ), model.inner.ptr_model)
end

function _interrupt(model::SCIPMathProgModel)
ccall((:CSIPinterrupt, libcsip), Cint, (Ptr{Void}, ), model.inner.ptr_model)
ccall((:CSIPinterrupt, libcsip), Cint, (Ptr{Cvoid}, ), model.inner.ptr_model)
end

function _getVarValues(model::SCIPMathProgModel, output::Vector{Cdouble})
ccall((:CSIPgetVarValues, libcsip), Cint, (Ptr{Void}, Ptr{Cdouble}),
ccall((:CSIPgetVarValues, libcsip), Cint, (Ptr{Cvoid}, Ptr{Cdouble}),
model.inner.ptr_model, output)
end

function _getObjValue(model::SCIPMathProgModel)
ccall((:CSIPgetObjValue, libcsip), Cdouble, (Ptr{Void}, ), model.inner.ptr_model)
ccall((:CSIPgetObjValue, libcsip), Cdouble, (Ptr{Cvoid}, ), model.inner.ptr_model)
end

function _getObjBound(model::SCIPMathProgModel)
ccall((:CSIPgetObjBound, libcsip), Cdouble, (Ptr{Void}, ), model.inner.ptr_model)
ccall((:CSIPgetObjBound, libcsip), Cdouble, (Ptr{Cvoid}, ), model.inner.ptr_model)
end

function _getStatus(model::SCIPMathProgModel)
ccall((:CSIPgetStatus, libcsip), Cint, (Ptr{Void}, ), model.inner.ptr_model)
ccall((:CSIPgetStatus, libcsip), Cint, (Ptr{Cvoid}, ), model.inner.ptr_model)
end

function _getParamType(model::SCIPMathProgModel, name::Ptr{UInt8})
ccall((:CSIPgetParamType, libcsip), Cint,
(Ptr{Void}, Ptr{UInt8}),
(Ptr{Cvoid}, Ptr{UInt8}),
model.inner.ptr_model, name)
end

function _setBoolParam(model::SCIPMathProgModel, name::Ptr{UInt8},
value::Cint)
ccall((:CSIPsetBoolParam, libcsip), Cint,
(Ptr{Void}, Ptr{UInt8}, Cint),
(Ptr{Cvoid}, Ptr{UInt8}, Cint),
model.inner.ptr_model, name, value)
end

function _setIntParam(model::SCIPMathProgModel, name::Ptr{UInt8},
value::Cint)
ccall((:CSIPsetIntParam, libcsip), Cint,
(Ptr{Void}, Ptr{UInt8}, Cint),
(Ptr{Cvoid}, Ptr{UInt8}, Cint),
model.inner.ptr_model, name, value)
end

function _setLongintParam(model::SCIPMathProgModel, name::Ptr{UInt8},
value::Clonglong)
ccall((:CSIPsetLongintParam, libcsip), Cint,
(Ptr{Void}, Ptr{UInt8}, Clonglong),
(Ptr{Cvoid}, Ptr{UInt8}, Clonglong),
model.inner.ptr_model, name, value)
end

function _setRealParam(model::SCIPMathProgModel, name::Ptr{UInt8},
value::Cdouble)
ccall((:CSIPsetRealParam, libcsip), Cint,
(Ptr{Void}, Ptr{UInt8}, Cdouble),
(Ptr{Cvoid}, Ptr{UInt8}, Cdouble),
model.inner.ptr_model, name, value)
end

function _setCharParam(model::SCIPMathProgModel, name::Ptr{UInt8},
value::Cchar)
ccall((:CSIPsetCharParam, libcsip), Cint,
(Ptr{Void}, Ptr{UInt8}, Cchar),
(Ptr{Cvoid}, Ptr{UInt8}, Cchar),
model.inner.ptr_model, name, value)
end

function _setStringParam(model::SCIPMathProgModel, name::Ptr{UInt8},
value::Ptr{UInt8})
ccall((:CSIPsetStringParam, libcsip), Cint,
(Ptr{Void}, Ptr{UInt8}, Ptr{UInt8}),
(Ptr{Cvoid}, Ptr{UInt8}, Ptr{UInt8}),
model.inner.ptr_model, name, value)
end

function _getNumVars(model::SCIPMathProgModel)
ccall((:CSIPgetNumVars, libcsip), Cint, (Ptr{Void}, ), model.inner.ptr_model)
ccall((:CSIPgetNumVars, libcsip), Cint, (Ptr{Cvoid}, ), model.inner.ptr_model)
end

function _getNumConss(model::SCIPMathProgModel)
ccall((:CSIPgetNumConss, libcsip), Cint, (Ptr{Void}, ), model.inner.ptr_model)
ccall((:CSIPgetNumConss, libcsip), Cint, (Ptr{Cvoid}, ), model.inner.ptr_model)
end

function _setInitialSolution(model::SCIPMathProgModel, values::Vector{Cdouble})
ccall((:CSIPsetInitialSolution, libcsip), Cint, (Ptr{Void}, Ptr{Cdouble}),
ccall((:CSIPsetInitialSolution, libcsip), Cint, (Ptr{Cvoid}, Ptr{Cdouble}),
model.inner.ptr_model, values)
end

function _lazyGetContext(lazydata::Ptr{Void})
ccall((:CSIPlazyGetContext, libcsip), Cint, (Ptr{Void}, ), lazydata)
function _lazyGetContext(lazydata::Ptr{Cvoid})
ccall((:CSIPlazyGetContext, libcsip), Cint, (Ptr{Cvoid}, ), lazydata)
end

function _lazyGetVarValues(lazydata::Ptr{Void}, output::Vector{Cdouble})
ccall((:CSIPlazyGetVarValues, libcsip), Cint, (Ptr{Void}, Ptr{Cdouble}),
function _lazyGetVarValues(lazydata::Ptr{Cvoid}, output::Vector{Cdouble})
ccall((:CSIPlazyGetVarValues, libcsip), Cint, (Ptr{Cvoid}, Ptr{Cdouble}),
lazydata, output)
end

function _lazyAddLinCons(lazydata::Ptr{Void}, numindices::Cint,
function _lazyAddLinCons(lazydata::Ptr{Cvoid}, numindices::Cint,
indices::Vector{Cint}, coefs::Vector{Cdouble},
lhs::Cdouble, rhs::Cdouble, islocal::Cint)
ccall((:CSIPlazyAddLinCons, libcsip), Cint,
(Ptr{Void}, Cint, Ptr{Cint}, Ptr{Cdouble}, Cdouble, Cdouble, Cint),
(Ptr{Cvoid}, Cint, Ptr{Cint}, Ptr{Cdouble}, Cdouble, Cdouble, Cint),
lazydata, numindices, indices, coefs, lhs, rhs, islocal)
end

function _addLazyCallback(model::SCIPMathProgModel, lazycb::Ptr{Void}, userdata)
function _addLazyCallback(model::SCIPMathProgModel, lazycb::Ptr{Cvoid}, userdata)
ccall((:CSIPaddLazyCallback, libcsip), Cint,
(Ptr{Void}, Ptr{Void}, Any),
(Ptr{Cvoid}, Ptr{Cvoid}, Any),
model.inner.ptr_model, lazycb, userdata)
end

function _heurGetVarValues(heurdata::Ptr{Void}, output::Vector{Cdouble})
ccall((:CSIPheurGetVarValues, libcsip), Cint, (Ptr{Void}, Ptr{Cdouble}),
function _heurGetVarValues(heurdata::Ptr{Cvoid}, output::Vector{Cdouble})
ccall((:CSIPheurGetVarValues, libcsip), Cint, (Ptr{Cvoid}, Ptr{Cdouble}),
heurdata, output)
end

function _heurAddSolution(heurdata::Ptr{Void}, values::Vector{Cdouble})
ccall((:CSIPheurAddSolution, libcsip), Cint, (Ptr{Void}, Ptr{Cdouble}),
function _heurAddSolution(heurdata::Ptr{Cvoid}, values::Vector{Cdouble})
ccall((:CSIPheurAddSolution, libcsip), Cint, (Ptr{Cvoid}, Ptr{Cdouble}),
heurdata, values)
end

function _addHeuristicCallback(model::SCIPMathProgModel, heur::Ptr{Void}, userdata)
ccall((:CSIPaddHeuristicCallback, libcsip), Cint, (Ptr{Void}, Ptr{Void}, Any),
function _addHeuristicCallback(model::SCIPMathProgModel, heur::Ptr{Cvoid}, userdata)
ccall((:CSIPaddHeuristicCallback, libcsip), Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Any),
model.inner.ptr_model, heur, userdata)
end

function _getInternalSCIP(model::SCIPMathProgModel)
ccall((:CSIPgetInternalSCIP, libcsip), Ptr{Void}, (Ptr{Void}, ),
ccall((:CSIPgetInternalSCIP, libcsip), Ptr{Cvoid}, (Ptr{Cvoid}, ),
model.inner.ptr_model)
end

function _setMessagePrefix(model::SCIPMathProgModel, prefix::Ptr{UInt8})
ccall((:CSIPsetMessagePrefix, libcsip), Cint, (Ptr{Void}, Cstring),
ccall((:CSIPsetMessagePrefix, libcsip), Cint, (Ptr{Cvoid}, Cstring),
model.inner.ptr_model, prefix)
end
Loading

0 comments on commit 6f6b90f

Please sign in to comment.