Skip to content

Commit

Permalink
updates for MPB 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mlubin committed Nov 29, 2015
1 parent 5c34fc2 commit ba3d226
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ type Problem
constraints::Array{Constraint}
status::Symbol
optval::Float64OrNothing
model::MathProgBase.AbstractMathProgModel
model::MathProgBase.AbstractConicModel
solution::Solution

function Problem(head::Symbol, objective::AbstractExpr,
model::MathProgBase.AbstractMathProgModel, constraints::Array=Constraint[])
model::MathProgBase.AbstractConicModel, constraints::Array=Constraint[])
return new(head, objective, constraints, "not yet solved", nothing, model)
end
end
# constructor if model is not specified
function Problem(head::Symbol, objective::AbstractExpr, constraints::Array=Constraint[],
solver::MathProgBase.AbstractMathProgSolver = get_default_solver())
Problem(head, objective, MathProgBase.model(solver), constraints)
Problem(head, objective, MathProgBase.ConicModel(solver), constraints)
end

# If the problem constructed is of the form Ax=b where A is m x n
Expand Down
12 changes: 6 additions & 6 deletions src/solution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function solve!(problem::Problem,
s::MathProgBase.AbstractMathProgSolver;
kwargs...)
# TODO: warn about wiping out old model if warmstart=true?
problem.model = MathProgBase.model(s)
problem.model = MathProgBase.ConicModel(s)
return solve!(problem; kwargs...)
end

Expand Down Expand Up @@ -40,7 +40,7 @@ function solve!(problem::Problem;

end

function set_warmstart!(m::MathProgBase.AbstractMathProgModel,
function set_warmstart!(m::MathProgBase.AbstractConicModel,
problem::Problem,
n::Int, # length of primal (conic) solution
var_to_ranges)
Expand Down Expand Up @@ -74,11 +74,11 @@ function set_warmstart!(m::MathProgBase.AbstractMathProgModel,
m
end

function load_problem!(m::MathProgBase.AbstractMathProgModel, c, A, b, cones, vartypes)
function load_problem!(m::MathProgBase.AbstractConicModel, c, A, b, cones, vartypes)
# no conic constraints on variables
var_cones = fill((:Free, 1:size(A, 2)),1)
# TODO: Get rid of full once c and b are not sparse
MathProgBase.loadconicproblem!(m, vec(full(c)), A, vec(full(b)), cones, var_cones)
MathProgBase.loadproblem!(m, vec(full(c)), A, vec(full(b)), cones, var_cones)

# add integer and binary constraints on variables
if !all(Bool[t==:Cont for t in vartypes])
Expand All @@ -91,12 +91,12 @@ function load_problem!(m::MathProgBase.AbstractMathProgModel, c, A, b, cones, va
m
end

function populate_solution!(m::MathProgBase.AbstractMathProgModel,
function populate_solution!(m::MathProgBase.AbstractConicModel,
problem::Problem,
var_to_ranges,
conic_constraints)
try
dual = MathProgBase.getconicdual(m)
dual = MathProgBase.getdual(m)
problem.solution = Solution(MathProgBase.getsolution(m), dual,
MathProgBase.status(m), MathProgBase.getobjval(m))
catch
Expand Down

0 comments on commit ba3d226

Please sign in to comment.