From 37fa83a4e21944d5506e3495ed161252c810cfb8 Mon Sep 17 00:00:00 2001 From: Nuwan Yapa Date: Thu, 30 Jan 2025 13:08:13 -0500 Subject: [PATCH] Optimize ensemble when Gram-Schmidt is not requested --- EC.jl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/EC.jl b/EC.jl index d93367f..1c320b4 100644 --- a/EC.jl +++ b/EC.jl @@ -58,10 +58,17 @@ function train!(EC::affine_EC, c_vals; ref_eval=-10.0, CAEC=false, gram_schmidt_ (EC.H0_EC, EC.H1_EC, EC.N_EC) = get_reduced_matrices(EC, training_vecs, gram_schmidt_threshold; verbose=true) for _ in 1:EC.ensemble_size - (H0_EC, H1_EC, N_EC) = get_reduced_matrices(EC, training_vecs, gram_schmidt_threshold, resample(length(training_vecs)); verbose=false) - push!(EC.H0_EC_ensemble, H0_EC) - push!(EC.H1_EC_ensemble, H1_EC) - push!(EC.N_EC_ensemble, N_EC) + subsample = resample(length(training_vecs)) + if gram_schmidt_threshold > 0 + (H0_EC, H1_EC, N_EC) = get_reduced_matrices(EC, training_vecs, gram_schmidt_threshold, subsample; verbose=false) + push!(EC.H0_EC_ensemble, H0_EC) + push!(EC.H1_EC_ensemble, H1_EC) + push!(EC.N_EC_ensemble, N_EC) + else + push!(EC.H0_EC_ensemble, EC.H0_EC[subsample, subsample]) + push!(EC.H1_EC_ensemble, EC.H1_EC[subsample, subsample]) + push!(EC.N_EC_ensemble, EC.N_EC[subsample, subsample]) + end end EC.trained = true