Skip to content

Commit

Permalink
fix #149
Browse files Browse the repository at this point in the history
  • Loading branch information
changliuliu committed Aug 6, 2020
1 parent a324281 commit ce23cb6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
13 changes: 7 additions & 6 deletions src/optimization/iLP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function solve(solver::ILP, problem::Problem)
encode_network!(model, nnet, neurons, δ, StandardLP())
optimize!(model)
termination_status(model) != OPTIMAL && return AdversarialResult(:unknown)
return interpret_result(solver, value(o), problem.input)
x = value.(first(neurons))
return interpret_result(solver, x, problem.input)
end

encode_network!(model, nnet, neurons, δ, LinearRelaxedLP())
Expand All @@ -55,17 +56,17 @@ function solve(solver::ILP, problem::Problem)
x = value.(first(neurons))
matched, index = match_activation(nnet, x, δ)
if matched
return interpret_result(solver, value(o), problem.input)
return interpret_result(solver, x, problem.input)
end
add_constraint!(model, nnet, neurons, δ, index)
end
end

function interpret_result(solver::ILP, o, input)
if o >= maximum(input.radius)
return AdversarialResult(:holds, o)
function interpret_result(solver::ILP, x, input)
if prod(abs.(x - input.center) .>= input.radius)
return AdversarialResult(:holds, minimum(abs.(x - input.center)))
else
return AdversarialResult(:violated, o)
return AdversarialResult(:violated, minimum(abs.(x - input.center)))
end
end

Expand Down
6 changes: 1 addition & 5 deletions src/optimization/mipVerify.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,5 @@ function solve(solver::MIPVerify, problem::Problem)
if termination_status(model) == INFEASIBLE
return AdversarialResult(:holds)
end
if value(o) >= maximum(problem.input.radius)
return AdversarialResult(:holds)
else
return AdversarialResult(:violated, value(o))
end
return AdversarialResult(:violated, value(o))
end

0 comments on commit ce23cb6

Please sign in to comment.