org.optaplanner.constraint.streams.bavet.quad.BavetIfExistsQuadConstraintStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of optaplanner-constraint-streams-bavet Show documentation
Show all versions of optaplanner-constraint-streams-bavet Show documentation
OptaPlanner solves planning problems.
This lightweight, embeddable planning engine implements powerful and scalable algorithms
to optimize business resource scheduling and planning.
This module contains implementation of Constraint streams (Bavet).
package org.optaplanner.constraint.streams.bavet.quad;
import java.util.Set;
import org.optaplanner.constraint.streams.bavet.BavetConstraintFactory;
import org.optaplanner.constraint.streams.bavet.common.AbstractIfExistsNode;
import org.optaplanner.constraint.streams.bavet.common.BavetAbstractConstraintStream;
import org.optaplanner.constraint.streams.bavet.common.NodeBuildHelper;
import org.optaplanner.constraint.streams.bavet.common.index.IndexerFactory;
import org.optaplanner.constraint.streams.bavet.common.index.JoinerUtils;
import org.optaplanner.constraint.streams.bavet.uni.BavetIfExistsBridgeUniConstraintStream;
import org.optaplanner.constraint.streams.common.penta.DefaultPentaJoiner;
import org.optaplanner.core.api.function.PentaPredicate;
import org.optaplanner.core.api.score.Score;
import org.optaplanner.core.api.score.stream.ConstraintStream;
final class BavetIfExistsQuadConstraintStream
extends BavetAbstractQuadConstraintStream {
private final BavetAbstractQuadConstraintStream parentABCD;
private final BavetIfExistsBridgeUniConstraintStream parentBridgeE;
private final boolean shouldExist;
private final DefaultPentaJoiner joiner;
private final PentaPredicate filtering;
public BavetIfExistsQuadConstraintStream(BavetConstraintFactory constraintFactory,
BavetAbstractQuadConstraintStream parentABCD,
BavetIfExistsBridgeUniConstraintStream parentBridgeE,
boolean shouldExist,
DefaultPentaJoiner joiner, PentaPredicate filtering) {
super(constraintFactory, parentABCD.getRetrievalSemantics());
this.parentABCD = parentABCD;
this.parentBridgeE = parentBridgeE;
this.shouldExist = shouldExist;
this.joiner = joiner;
this.filtering = filtering;
}
@Override
public boolean guaranteesDistinct() {
return parentABCD.guaranteesDistinct();
}
// ************************************************************************
// Node creation
// ************************************************************************
@Override
public void collectActiveConstraintStreams(Set> constraintStreamSet) {
parentABCD.collectActiveConstraintStreams(constraintStreamSet);
parentBridgeE.collectActiveConstraintStreams(constraintStreamSet);
constraintStreamSet.add(this);
}
@Override
public ConstraintStream getTupleSource() {
return parentABCD.getTupleSource();
}
@Override
public > void buildNode(NodeBuildHelper buildHelper) {
int inputStoreIndexA = buildHelper.reserveTupleStoreIndex(parentABCD.getTupleSource());
int inputStoreIndexB = buildHelper.reserveTupleStoreIndex(parentBridgeE.getTupleSource());
IndexerFactory indexerFactory = new IndexerFactory(joiner);
AbstractIfExistsNode, E> node = new IfExistsQuadWithUniNode<>(shouldExist,
JoinerUtils.combineLeftMappings(joiner), JoinerUtils.combineRightMappings(joiner),
inputStoreIndexA, inputStoreIndexB,
buildHelper.getAggregatedTupleLifecycle(childStreamList),
indexerFactory.buildIndexer(true), indexerFactory.buildIndexer(false),
filtering);
buildHelper.addNode(node, this, parentBridgeE);
}
// ************************************************************************
// Equality for node sharing
// ************************************************************************
// TODO
@Override
public String toString() {
return "IfExists() with " + childStreamList.size() + " children";
}
// ************************************************************************
// Getters/setters
// ************************************************************************
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy