001 package jcolibri.method.maintenance; 002 003 import java.util.Collection; 004 import java.util.LinkedList; 005 006 import jcolibri.cbrcore.CBRCase; 007 import jcolibri.method.retrieve.KNNretrieval.KNNConfig; 008 009 010 /** 011 * Provides the ability to run two maintenance algorithms consecutively 012 * on a set of cases 013 * 014 * @author Lisa Cummins 015 */ 016 public class RunTwoStepMaintenance { 017 018 /** 019 * Runs alg1 followed by alg2 on the given cases and returns the 020 * cases deleted by the combined algorithms 021 * @param alg1 The first maintenance algorithm to perform 022 * @param alg2 The second maintenance algorithm to perform 023 * @param cases The group of cases on which to perform maintenance 024 * @param simConfig The KNNConfig for these cases 025 * @return the list of cases deleted by the algorithm 026 */ 027 public static LinkedList<CBRCase> runMaintenance(MaintenanceAlgorithm alg1, MaintenanceAlgorithm alg2, 028 Collection<CBRCase> cases, KNNConfig simConfig) 029 { 030 031 LinkedList<CBRCase> deletedCases = alg1.runMaintenance(cases, simConfig); 032 033 cases.removeAll(deletedCases); 034 035 deletedCases.addAll(alg2.runMaintenance(cases, simConfig)); 036 037 return deletedCases; 038 } 039 }