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

ai.libs.hasco.variants.forwarddecomposition.DefaultPathPriorizingPredicate Maven / Gradle / Ivy

Go to download

HASCO is a framework for reducing configuration tasks (e.g. software system configuration or algorithm configuration) into an HTN planning problem. This can then in turn be reduced to a graph search problem that can be solved by any kind of standard graph search algorithm, e.g., breadth-first-search.

There is a newer version: 0.2.1
Show newest version
package ai.libs.hasco.variants.forwarddecomposition;

import java.util.function.Predicate;

import ai.libs.hasco.core.HASCO;
import ai.libs.hasco.core.Util;
import ai.libs.hasco.model.ComponentInstance;
import ai.libs.hasco.model.ComponentUtil;
import ai.libs.jaicore.planning.hierarchical.algorithms.forwarddecomposition.graphgenerators.tfd.TFDNode;

/**
 * This is a node evaluator that assigns 0 to all nodes encoding (partial) compositions where each component refinement is with its default parameters.
 *
 * This is a somewhat cyclic component, because it needs to know the HASCO object it will advise, but it is already needed to initialize HASCO. So to use it, the hasco variable must be set after initialization.
 *
 * @author fmohr
 *
 */
public class DefaultPathPriorizingPredicate implements Predicate {

	private HASCO hasco;

	@Override
	public boolean test(final N node) {
		if (this.hasco == null) {
			throw new IllegalStateException("HASCO has not yet been set!");
		}
		if (!(node instanceof TFDNode)) {
			throw new IllegalArgumentException("Currently we only support TFDNodes for node priorization");
		}
		if (this.hasco.getInput() == null) {
			throw new IllegalStateException("HASCO exists, but its problem input has not been defined yet.");
		}
		ComponentInstance inst = Util.getSolutionCompositionFromState(this.hasco.getInput().getComponents(), ((TFDNode) node).getState(), false);
		if (inst == null) {
			return true;
		}
		return ComponentUtil.isDefaultConfiguration(inst);
	}

	public HASCO getHasco() {
		return this.hasco;
	}

	public void setHasco(final HASCO hasco) {
		this.hasco = hasco;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy