Skip to content

added bounds to MixedIntegerLP and TriangularRelaxedLP #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/optimization/utils/constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,20 @@ function encode_layer!(SLP::SlackLP, model::Model, layer::Layer{Id}, ẑᵢ, z
end

# need to fix δᵢⱼ for BoundedMixedIntegerLP and possibly other types
function encode_layer!(::BoundedMixedIntegerLP, model::Model, layer::Layer{Id}, ẑᵢ, zᵢ, δᵢ, args...)
function encode_layer!(::BoundedMixedIntegerLP, model::Model, layer::Layer{Id}, ẑᵢ, zᵢ, δᵢ, l̂ᵢ, ûᵢ)
@constraint(model, zᵢ .== ẑᵢ)
@constraint(model, δᵢ .== 1)

set_lower_bound.(zᵢ, l̂ᵢ)
set_upper_bound.(zᵢ, ûᵢ)
return nothing
end

function encode_layer!(::TriangularRelaxedLP, model::Model, layer::Layer{Id}, ẑᵢ, zᵢ, l̂ᵢ, ûᵢ)
@constraint(model, zᵢ .== ẑᵢ)

set_lower_bound.(zᵢ, l̂ᵢ)
set_upper_bound.(zᵢ, ûᵢ)
return nothing
end

Expand Down Expand Up @@ -153,6 +164,8 @@ function encode_relu(::BoundedMixedIntegerLP, model, ẑᵢⱼ, zᵢⱼ, δᵢ
zᵢⱼ <= ẑᵢⱼ - l̂ᵢⱼ * (1 - δᵢⱼ)
end)
end
set_lower_bound(zᵢⱼ, max(l̂ᵢⱼ, 0.0))
set_upper_bound(zᵢⱼ, max(ûᵢⱼ, 0.0))
end

function encode_relu(::MixedIntegerLP, args...)
Expand All @@ -171,6 +184,8 @@ function encode_relu(::TriangularRelaxedLP, model, ẑᵢⱼ, zᵢⱼ, l̂ᵢⱼ
zᵢⱼ <= (ẑᵢⱼ - l̂ᵢⱼ) * ûᵢⱼ / (ûᵢⱼ - l̂ᵢⱼ)
end)
end
set_lower_bound(zᵢⱼ, max(l̂ᵢⱼ, 0.0))
set_upper_bound(zᵢⱼ, max(ûᵢⱼ, 0.0))
end

function encode_relu(::LinearRelaxedLP, model, ẑᵢⱼ, zᵢⱼ, δᵢⱼ)
Expand Down