Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.

odow/LPWriter.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LPWriter.jl

Build Status

codecov.io

This package is not registered. Use Pkg.clone("https://github.com/odow/LPWriter.jl") to install.

The LPWriter.jl package is a pure Julia light-weight implementation of an LP file writer.

It has a two, user-facing, un-exported functions. One to write a LP file given the input

LPWriter.write(io::IO,
    A::AbstractMatrix,       # the constraint matrix
    collb::Vector,           # vector of variable lower bounds
    colub::Vector,           # vector of variable upper bounds
    c::Vector,               # vector containing variable objective coefficients
    rowlb::Vector,           # constraint lower bounds
    rowub::Vector,           # constraint upper bounds
    sense::Symbol,           # model sense
    colcat::Vector{Symbol},  # constraint types
    sos::Vector{Tuple{Int, Vector{Int}, Vector{Float64}}}, # SOS information
    Q::AbstractMatrix,       #  Quadratic objective 0.5 * x' Q x
    modelname::AbstractString = "LPWriter_jl",  # LP model name
    colnames::Vector{String}  = ["V$i" for i in 1:length(c)],    # variable names
    rownames::Vector{String}  = ["C$i" for i in 1:length(rowub)] # constraint names
)

And one to read the file:

(A::AbstractMatrix,       # the constraint matrix
    collb::Vector,           # vector of variable lower bounds
    colub::Vector,           # vector of variable upper bounds
    c::Vector,               # vector containing variable objective coefficients
    rowlb::Vector,           # constraint lower bounds
    rowub::Vector,           # constraint upper bounds
    sense::Symbol,           # model sense
    colcat::Vector{Symbol},  # constraint types
    sos::Vector{Tuple{Int, Vector{Int}, Vector{Float64}}}, # SOS information
    Q::AbstractMatrix,       #  Quadratic objective 0.5 * x' Q x
    modelname::AbstractString = "LPWriter_jl",  # LP model name
    colnames::Vector{String}  = ["V$i" for i in 1:length(c)],    # variable names
    rownames::Vector{String}  = ["C$i" for i in 1:length(rowub)] # constraint names
    ) = LPWriter.read(filename::String)
)

Limitations:

  • sense must be :Min or :Max
  • Quadratic objectives are unsupported
  • Only Integer (colcat = :Int), Binary (colcat = :Bin) and Continuous (colcat = :Cont) variables are supported.

SOS are given by the Tuple Tuple{Int, Vector{Int}, Vector{Float64}} where the first index is either 1 (for SOS of type I) or 2 (for SOS of type II). The second index a list of the indices of the columns in the constraint matrix corresponding to the variables in the SOS set. The third index defines an ordering on the indices.

About

A Julia package for writing LP files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages