Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
madeleineudell committed Apr 5, 2016
2 parents 9eb5eab + a668039 commit fc4efc6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
5 changes: 5 additions & 0 deletions docs/solvers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ If we wish to increase the maximum number of iterations for ECOS or SCS, we can
solve!(p, ECOSSolver(maxit=10000))
using SCS
solve!(p, SCSSolver(max_iters=10000))

To turn off the problem status warning issued by Convex when a solver is not able to solve a problem to optimality, use the keyword argument `verbose=false` of the solve method, along with any desired solver parameters:
::

solve!(p, SCSSolver(verbose=false), verbose=false)
34 changes: 26 additions & 8 deletions src/solution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ function solve!(problem::Problem,
end

function solve!(problem::Problem;
warmstart=false, check_vexity=true)
warmstart=false,
check_vexity=true,
verbose=true)

if check_vexity
vex = vexity(problem)
Expand All @@ -34,7 +36,7 @@ function solve!(problem::Problem;
# populate the status, the primal (and possibly dual) solution
# and the primal (and possibly dual) variables with values
populate_solution!(m, problem, var_to_ranges, conic_constraints)
if !(problem.status==:Optimal)
if !(problem.status==:Optimal) && verbose
warn("Problem status $(problem.status); solution may be inaccurate.")
end

Expand Down Expand Up @@ -95,14 +97,30 @@ function populate_solution!(m::MathProgBase.AbstractConicModel,
problem::Problem,
var_to_ranges,
conic_constraints)
try
dual = MathProgBase.getdual(m)
problem.solution = Solution(MathProgBase.getsolution(m), dual,
MathProgBase.status(m), MathProgBase.getobjval(m))
dual = try
MathProgBase.getdual(m)
catch
problem.solution = Solution(MathProgBase.getsolution(m),
MathProgBase.status(m), MathProgBase.getobjval(m))
fill(NaN, MathProgBase.numconstr(m))
end

solution = try
MathProgBase.getsolution(m)
catch
fill(NaN, MathProgBase.numvar(m))
end

objective = try
MathProgBase.getobjval(m)
catch
NaN
end

if any(isnan(dual))
problem.solution = Solution(solution, MathProgBase.status(m), objective)
else
problem.solution = Solution(solution, dual, MathProgBase.status(m), objective)
end

populate_variables!(problem, var_to_ranges)

if problem.solution.has_dual
Expand Down

0 comments on commit fc4efc6

Please sign in to comment.