From 704dad3a1abd608ddc5fffc896861edfc5d200d2 Mon Sep 17 00:00:00 2001 From: Michel Schanen Date: Mon, 30 Jan 2023 19:09:59 -0600 Subject: [PATCH] N-2 test and force ADMM convergence * Add N-2 test and force no block model iteration limits exceeded for convergence * EmptyBlockModel always returns solution status MOI.Optimal --- Artifacts.toml | 6 +++--- src/Evaluators/ProxALEvalutor.jl | 13 +++++++++++-- src/backends.jl | 14 ++++++++++---- src/communication.jl | 4 ++-- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Artifacts.toml b/Artifacts.toml index c12cd5c..0cb15d6 100644 --- a/Artifacts.toml +++ b/Artifacts.toml @@ -1,6 +1,6 @@ [ExaData] -git-tree-sha1 = "df547b1e5d707fdb88721eee9bf84f9211e1fb50" +git-tree-sha1 = "882112a441efaa242000181b177c4005b190a4c1" lazy = true [[ExaData.download]] - url = "https://web.cels.anl.gov/~mschanen/ExaData-e1b6123.tar.gz" - sha256 = "f6e22f26fbf273e97625a25b1b55f07d0eb0e15283483c545dda6eda84c48fdd" + url = "https://web.cels.anl.gov/~mschanen/ExaData-4747d0f.tar.gz" + sha256 = "6d929aa12f3841c0fb14100effff42bc5edffd7602afb4844e80996f033c3fc8" diff --git a/src/Evaluators/ProxALEvalutor.jl b/src/Evaluators/ProxALEvalutor.jl index 859f8a9..56ceb5c 100644 --- a/src/Evaluators/ProxALEvalutor.jl +++ b/src/Evaluators/ProxALEvalutor.jl @@ -400,13 +400,22 @@ function optimize!( iteration() # Check convergence - if max( + iteration_limit = 0 + for blk in opfBlockData.blkModel + solution = get_solution(blk) + if solution.status ∉ MOI_OPTIMAL_STATUSES + iteration_limit = 1 + end + end + giteration_limit = comm_sum(iteration_limit, comm) + + if (max( runinfo.maxviol_t[end], runinfo.maxviol_c[end], runinfo.maxviol_t_actual[end], runinfo.maxviol_c_actual[end], runinfo.maxviol_d[end] - ) <= algparams.tol + ) <= algparams.tol) && (giteration_limit == 0) # minviol = max( # runinfo.maxviol_t[end], # runinfo.maxviol_c[end], diff --git a/src/backends.jl b/src/backends.jl index ed7b3db..7ecb5bc 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -112,7 +112,13 @@ function init!(block::EmptyBlockModel, algparams::AlgParams) end function set_objective!(block::EmptyBlockModel, algparams::AlgParams, primal::AbstractPrimalSolution, dual::AbstractDualSolution) end -function get_solution(block::EmptyBlockModel) end +function get_solution(block::EmptyBlockModel) + # Empty block is always optimal + solution = ( + status=MOI.OPTIMAL, + ) + return solution +end ### Implementation of JuMPBlockBackend struct JuMPBlockBackend <: AbstractBlockModel @@ -768,9 +774,9 @@ function get_solution(block::AdmmBlockBackend) k = block.k t = block.t - if status ∉ MOI_OPTIMAL_STATUSES - @warn("Block $blk[$k, $t] subproblem not solved to optimality. status: $status") - end + # if status ∉ MOI_OPTIMAL_STATUSES + # @warn("Block $blk[$k, $t] subproblem not solved to optimality. status: $status") + # end s = ExaAdmmBackend.slack_values(model) |> Array solution = ( diff --git a/src/communication.jl b/src/communication.jl index 33aed94..2afb88d 100644 --- a/src/communication.jl +++ b/src/communication.jl @@ -168,11 +168,11 @@ end Collective to reduce and return the sum over scalar `data`. """ -function comm_sum(data::Float64, comm::MPI.Comm) +function comm_sum(data::Number, comm::MPI.Comm) return MPI.Allreduce(data, MPI.SUM, comm) end -function comm_sum(data::Float64, comm::Nothing) +function comm_sum(data::Number, comm::Nothing) return data end