@Override public void start(final Experiment experiment, final HeuristicCallback callback) throws InterruptedException { final AMModel model = experiment.getModel(); final List<AttributeMappingId> candidates = MappingUtils.getCandidates(model); Collections.sort( candidates, new WeightComparator(experiment.getModel(), experiment.getAlpha(), experiment.getBeta())); final List<AttributeMappingId> reverse = new ArrayList<AttributeMappingId>(candidates); Collections.reverse(reverse); for (final AttributeMappingId id : reverse) { if (MappingUtils.isIDset(candidates, model)) { break; } candidates.remove(id); } final IdSet solution = new IdSet(candidates); callback.finished(Arrays.asList(solution)); }
@Override public void start( final Experiment experiment, final List<IdSet> feasiblePool, final HeuristicCallback callback) throws InterruptedException { final List<IdSet> improved = new ArrayList<IdSet>(feasiblePool.size()); final List<AttributeMappingId> candidates = MappingUtils.getCandidates(experiment.getModel()); Collections.sort( candidates, new WeightComparator(experiment.getModel(), experiment.getAlpha(), experiment.getBeta())); for (final IdSet solution : feasiblePool) { improved.add(improve(experiment.getModel(), solution, candidates)); } callback.finished(improved); }
/** Try improving this ID set by adding as many heavy AMs as possible. */ private static IdSet improve( final AMModel model, final IdSet idSet, final List<AttributeMappingId> candidates) { final List<AttributeMappingId> ret = new ArrayList<AttributeMappingId>(idSet.getMappings()); for (final AttributeMappingId id : candidates) { if (!ret.contains(id)) { final List<AttributeMappingId> potential = new ArrayList<AttributeMappingId>(ret); potential.add(id); if (MappingUtils.isIDset(potential, model)) { ret.add(id); } } } return new IdSet(ret); }