Skip to content

Commit

Permalink
cleaning up delta_ij changes
Browse files Browse the repository at this point in the history
  • Loading branch information
chelseas committed Nov 12, 2021
1 parent 81fa4e3 commit 92d7128
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/optimization/utils/constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ function encode_relu(::SlackLP, model, ẑᵢⱼ, zᵢⱼ, δᵢⱼ, sᵢⱼ)
if δᵢⱼ
@constraint(model, zᵢⱼ == ẑᵢⱼ + sᵢⱼ)
@constraint(model, ẑᵢⱼ + sᵢⱼ >= 0.0)
# how to encode necessary constraint on δᵢⱼ here?
else
@constraint(model, zᵢⱼ == sᵢⱼ)
@constraint(model, ẑᵢⱼ <= sᵢⱼ)
Expand Down Expand Up @@ -163,10 +162,8 @@ end
function encode_relu(::TriangularRelaxedLP, model, ẑᵢⱼ, zᵢⱼ, l̂ᵢⱼ, ûᵢⱼ)
if l̂ᵢⱼ > 0.0
@constraint(model, zᵢⱼ == ẑᵢⱼ)
@constraint(model, δᵢⱼ == 1)
elseif ûᵢⱼ < 0.0
@constraint(model, zᵢⱼ == 0.0)
@constraint(model, δᵢⱼ == 0)
else
@constraints(model, begin
zᵢⱼ >= 0.0
Expand All @@ -177,18 +174,16 @@ function encode_relu(::TriangularRelaxedLP, model, ẑᵢⱼ, zᵢⱼ, l̂ᵢⱼ
end

function encode_relu(::LinearRelaxedLP, model, ẑᵢⱼ, zᵢⱼ, δᵢⱼ)
@constraint(model, zᵢⱼ == (δᵢⱼ ? ẑᵢⱼ : 0.0)) # what does this mean? how can you use ? in a constraint?
@constraint(model, zᵢⱼ == (δᵢⱼ ? ẑᵢⱼ : 0.0)) # in LinearRelaxedLP δᵢⱼ is a constant not a variable
end

function encode_relu(::StandardLP, model, ẑᵢⱼ, zᵢⱼ, δᵢⱼ)
if δᵢⱼ
if δᵢⱼ # in StandardLP δᵢⱼ is a constant, not a variable
@constraint(model, ẑᵢⱼ >= 0.0)
@constraint(model, zᵢⱼ == ẑᵢⱼ)
@constraint(model, δᵢⱼ == 1)
else
@constraint(model, ẑᵢⱼ <= 0.0)
@constraint(model, zᵢⱼ == 0.0)
@constraint(model, δᵢⱼ == 0)
end
end

Expand Down

0 comments on commit 92d7128

Please sign in to comment.