From 2f1c91f4f9943127a3809c94ee22273399b68718 Mon Sep 17 00:00:00 2001 From: harshangrjn Date: Thu, 12 Sep 2024 14:31:19 -0600 Subject: [PATCH] format compat --- examples/run_examples.jl | 3 +-- src/constraints.jl | 6 ++++-- src/utility.jl | 20 +++++++++++++------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/examples/run_examples.jl b/examples/run_examples.jl index 354856c..1cf897d 100644 --- a/examples/run_examples.jl +++ b/examples/run_examples.jl @@ -61,8 +61,7 @@ data_dict, augment_budget = data_I(num_nodes, instance) # data_dict, augment_budget = data_SLAM("CSAIL") # "CSAIL", "intel", "ais2klinik" # data_dict, augment_budget = data_II() -params = Dict{String,Any}("data_dict" => data_dict, - "augment_budget" => augment_budget) +params = Dict{String,Any}("data_dict" => data_dict, "augment_budget" => augment_budget) #----------------------------------------------------------------# # Optimization model and visualize solution (optional) # diff --git a/src/constraints.jl b/src/constraints.jl index e92644d..9bf72c0 100644 --- a/src/constraints.jl +++ b/src/constraints.jl @@ -272,11 +272,13 @@ function constraint_cheeger_cuts( lom::LaplacianOptModel, optimizer::MOI.OptimizerWithAttributes, ) - ac_lower_bound = floor(lom.options.best_lower_bound, digits = 3) if isapprox(ac_lower_bound, 0, atol = 1E-4) - Memento.info(_LOGGER,"Cheeger cuts may be ineffective: best λ₂ lower bound is approximately 0.") + Memento.info( + _LOGGER, + "Cheeger cuts may be ineffective: best λ₂ lower bound is approximately 0.", + ) return end diff --git a/src/utility.jl b/src/utility.jl index 05809e0..3ef8023 100644 --- a/src/utility.jl +++ b/src/utility.jl @@ -187,14 +187,15 @@ function cheeger_constant( JuMP.@variable(m_cheeger, 0 <= cheeger <= cheeger_ub) JuMP.@variable(m_cheeger, cheeger_z[1:num_nodes] >= 0) - if formulation_type == "set_cardinality" + if formulation_type == "set_cardinality" JuMP.@constraint(m_cheeger, sum(z) >= 1) JuMP.@constraint(m_cheeger, sum(z) <= floor(num_nodes / 2)) JuMP.@constraint( m_cheeger, sum(cheeger_z) >= sum( - G[i, j] * (z[i] + z[j] - 2*Z[i, j]) for i in 1:(num_nodes-1), j in (i+1):num_nodes if + G[i, j] * (z[i] + z[j] - 2 * Z[i, j]) for + i in 1:(num_nodes-1), j in (i+1):num_nodes if !(isapprox(G[i, j], 0, atol = 1E-5)) ) ) @@ -203,20 +204,24 @@ function cheeger_constant( laplacian = LOpt.laplacian_matrix(float(G .> 0)) k_vol_ub = sum(G .> 0) / 2 #|E| JuMP.@constraint(m_cheeger, sum(z[i] * laplacian[i, i] for i in 1:num_nodes) >= 1) - JuMP.@constraint(m_cheeger, sum(z[i] * laplacian[i, i] for i in 1:num_nodes) <= k_vol_ub) + JuMP.@constraint( + m_cheeger, + sum(z[i] * laplacian[i, i] for i in 1:num_nodes) <= k_vol_ub + ) JuMP.@constraint( m_cheeger, sum(cheeger_z[i] * laplacian[i, i] for i in 1:num_nodes) >= sum( - G[i, j] * (z[i] + z[j] - 2*Z[i, j]) for i in 1:(num_nodes-1), j in (i+1):num_nodes if + G[i, j] * (z[i] + z[j] - 2 * Z[i, j]) for + i in 1:(num_nodes-1), j in (i+1):num_nodes if !(isapprox(G[i, j], 0, atol = 1E-5)) ) ) end - for i = 1:(num_nodes-1), j = (i+1):num_nodes + for i in 1:(num_nodes-1), j in (i+1):num_nodes if !(isapprox(G[i, j], 0, atol = 1E-5)) - LOpt.relaxation_bilinear(m_cheeger, Z[i,j], z[i], z[j]) + LOpt.relaxation_bilinear(m_cheeger, Z[i, j], z[i], z[j]) end end @@ -236,7 +241,8 @@ function cheeger_constant( result_cheeger["termination_status"] = JuMP.termination_status(m_cheeger) result_cheeger["optimality_gap_percent"] = 100 * JuMP.relative_gap(m_cheeger) - (length(result_cheeger["S"]) == 0) && (Memento.error(_LOGGER, "Cheeger set cardinality cannot be zero.")) + (length(result_cheeger["S"]) == 0) && + (Memento.error(_LOGGER, "Cheeger set cardinality cannot be zero.")) return result_cheeger end