All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.btrplace.scheduler.runner.disjoint.splitter.AmongSplitter Maven / Gradle / Ivy

Go to download

Instance solvers that split a single problem into smaller parts to solve them in parallel.

There is a newer version: 1.9.3
Show newest version
/*
 * Copyright  2020 The BtrPlace Authors. All rights reserved.
 * Use of this source code is governed by a LGPL-style
 * license that can be found in the LICENSE.txt file.
 */

package org.btrplace.scheduler.runner.disjoint.splitter;

import gnu.trove.map.hash.TIntIntHashMap;
import org.btrplace.model.Instance;
import org.btrplace.model.Node;
import org.btrplace.model.VM;
import org.btrplace.model.constraint.Among;
import org.btrplace.scheduler.runner.disjoint.model.ElementSubSet;
import org.btrplace.scheduler.runner.disjoint.model.SplittableElementSet;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * Splitter for {@link org.btrplace.model.constraint.Among} constraints.
 * 

* When the constraint focuses VMs among different partitions, * the constraint is split accordingly. * If the nodes groups are also split among different partitions, * this leads to a un-solvable problem as it is not possible to * synchronize the sub-among constraints to make them choose the same nodes group. * * @author Fabien Hermenier */ public class AmongSplitter implements ConstraintSplitter { @Override public Class getKey() { return Among.class; } @Override public boolean split(final Among cstr, Instance origin, final List partitions, TIntIntHashMap vmsPosition, final TIntIntHashMap nodePosition) { final boolean c = cstr.isContinuous(); return SplittableElementSet.newVMIndex(cstr.getInvolvedVMs(), vmsPosition). forEachPartition((index, idx, from, to) -> { if (to - from >= 2) { ElementSubSet vms = new ElementSubSet<>(index, idx, from, to); //Get the servers on the partition //Filter out the other nodes in the original constraint final Collection> subParams = new ArrayList<>(); for (Collection ns : cstr.getGroupsOfNodes()) { SplittableElementSet nodeIndex = SplittableElementSet.newNodeIndex(ns, nodePosition); Set s = nodeIndex.getSubSet(idx); if (s != null && !s.isEmpty()) { subParams.add(s); } } partitions.get(idx).getSatConstraints().add(new Among(vms, subParams, c)); } return true; }); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy