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

ai.libs.jaicore.search.algorithms.standard.bnb.BranchAndBound Maven / Gradle / Ivy

package ai.libs.jaicore.search.algorithms.standard.bnb;

import java.util.Random;

import org.api4.java.ai.graphsearch.problem.IPathSearchWithPathEvaluationsInput;
import org.api4.java.ai.graphsearch.problem.pathsearch.pathevaluation.IPathEvaluator;

import ai.libs.jaicore.search.algorithms.standard.bestfirst.StandardBestFirst;
import ai.libs.jaicore.search.probleminputs.GraphSearchWithSubpathEvaluationsInput;
import ai.libs.jaicore.search.problemtransformers.GraphSearchProblemInputToGraphSearchWithSubpathEvaluationInputTransformerViaRDFS;

/**
 * Branch and Bound algorithm. The evaluations given for each node must be optimistic (lower bounds).
 *
 * @author Felix Mohr
 *
 * @param 
 * @param 
 */
public class BranchAndBound extends StandardBestFirst {

	public static  GraphSearchWithSubpathEvaluationsInput encodeBoundsIntoProblem(final IPathSearchWithPathEvaluationsInput problem, final int numSamplesPerNode) {
		GraphSearchProblemInputToGraphSearchWithSubpathEvaluationInputTransformerViaRDFS trans = new GraphSearchProblemInputToGraphSearchWithSubpathEvaluationInputTransformerViaRDFS<>(n -> null, n -> false,
				new Random(), numSamplesPerNode, 100000, 100000);
		return trans.encodeProblem(problem);
	}

	public BranchAndBound(final IPathSearchWithPathEvaluationsInput problem, final IPathEvaluator lowerBoundComputer, final int numSamplesPerNode) {
		super(encodeBoundsIntoProblem(problem, numSamplesPerNode), lowerBoundComputer);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy