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

ai.libs.jaicore.search.exampleproblems.randomtrees.RandomTreeSearchProblem Maven / Gradle / Ivy

package ai.libs.jaicore.search.exampleproblems.randomtrees;

import java.util.List;

import org.api4.java.ai.graphsearch.problem.IPathSearchWithPathEvaluationsInput;
import org.api4.java.ai.graphsearch.problem.implicit.graphgenerator.IPathGoalTester;
import org.api4.java.ai.graphsearch.problem.pathsearch.pathevaluation.IPathEvaluator;
import org.api4.java.datastructure.graph.implicit.IGraphGenerator;

public class RandomTreeSearchProblem implements IPathSearchWithPathEvaluationsInput, Integer, Double> {

	private final int b;
	private final int d;
	private final long seed;
	private final IGraphGenerator, Integer> gg;
	private final IPathGoalTester, Integer> gt;
	private final IPathEvaluator, Integer, Double> se;
	private final boolean scoresPerEdge;

	public RandomTreeSearchProblem(final int b, final int d, final long seed, final int maxPerDepth, final boolean scoresPerEdge) {
		super();
		this.b = b;
		this.d = d;
		this.seed = seed;
		this.gg = new RandomTreeGraphGenerator(b, d, seed, maxPerDepth);
		this.gt = new RandomTreeGoalTester(d);
		this.scoresPerEdge = scoresPerEdge;
		this.se = n -> scoresPerEdge ? ((double)n.getHead().stream().reduce((current, added) -> current + added).get()) / (d * maxPerDepth) : n.getHead().get(n.getHead().size() - 1);
	}

	@Override
	public IGraphGenerator, Integer> getGraphGenerator() {
		return this.gg;
	}

	@Override
	public IPathGoalTester, Integer> getGoalTester() {
		return this.gt;
	}

	@Override
	public IPathEvaluator, Integer, Double> getPathEvaluator() {
		return this.se;
	}

	public int getB() {
		return this.b;
	}

	public int getD() {
		return this.d;
	}

	public IGraphGenerator, Integer> getGg() {
		return this.gg;
	}

	public IPathGoalTester, Integer> getGt() {
		return this.gt;
	}

	public IPathEvaluator, Integer, Double> getSe() {
		return this.se;
	}

	public boolean isScoresPerEdge() {
		return this.scoresPerEdge;
	}

	public long getSeed() {
		return this.seed;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy