-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
328 changed files
with
3,640 additions
and
1,571 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
core/src/main/java/ai/timefold/solver/core/impl/bavet/AbstractSession.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package ai.timefold.solver.core.impl.bavet; | ||
|
||
import java.util.IdentityHashMap; | ||
import java.util.Map; | ||
|
||
import ai.timefold.solver.core.impl.bavet.uni.AbstractForEachUniNode; | ||
|
||
public abstract class AbstractSession { | ||
|
||
private final NodeNetwork nodeNetwork; | ||
private final Map<Class<?>, AbstractForEachUniNode<Object>[]> effectiveClassToNodeArrayMap; | ||
|
||
protected AbstractSession(NodeNetwork nodeNetwork) { | ||
this.nodeNetwork = nodeNetwork; | ||
this.effectiveClassToNodeArrayMap = new IdentityHashMap<>(nodeNetwork.forEachNodeCount()); | ||
} | ||
|
||
public final void insert(Object fact) { | ||
var factClass = fact.getClass(); | ||
for (var node : findNodes(factClass)) { | ||
node.insert(fact); | ||
} | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private AbstractForEachUniNode<Object>[] findNodes(Class<?> factClass) { | ||
// Map.computeIfAbsent() would have created lambdas on the hot path, this will not. | ||
var nodeArray = effectiveClassToNodeArrayMap.get(factClass); | ||
if (nodeArray == null) { | ||
nodeArray = nodeNetwork.getForEachNodes(factClass) | ||
.filter(AbstractForEachUniNode::supportsIndividualUpdates) | ||
.toArray(AbstractForEachUniNode[]::new); | ||
effectiveClassToNodeArrayMap.put(factClass, nodeArray); | ||
} | ||
return nodeArray; | ||
} | ||
|
||
public final void update(Object fact) { | ||
var factClass = fact.getClass(); | ||
for (var node : findNodes(factClass)) { | ||
node.update(fact); | ||
} | ||
} | ||
|
||
public final void retract(Object fact) { | ||
var factClass = fact.getClass(); | ||
for (var node : findNodes(factClass)) { | ||
node.retract(fact); | ||
} | ||
} | ||
|
||
protected void settle() { | ||
nodeNetwork.settle(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
.../stream/bavet/bi/AbstractGroupBiNode.java → ...re/impl/bavet/bi/AbstractGroupBiNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
...score/stream/bavet/bi/ConcatBiBiNode.java → ...er/core/impl/bavet/bi/ConcatBiBiNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
...core/stream/bavet/bi/ConcatBiUniNode.java → ...r/core/impl/bavet/bi/ConcatBiUniNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
...core/stream/bavet/bi/ConcatUniBiNode.java → ...r/core/impl/bavet/bi/ConcatUniBiNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
core/src/main/java/ai/timefold/solver/core/impl/bavet/bi/ConditionalBiTupleLifecycle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package ai.timefold.solver.core.impl.bavet.bi; | ||
|
||
import java.util.function.BiPredicate; | ||
|
||
import ai.timefold.solver.core.impl.bavet.common.tuple.AbstractConditionalTupleLifecycle; | ||
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple; | ||
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle; | ||
|
||
public final class ConditionalBiTupleLifecycle<A, B> extends AbstractConditionalTupleLifecycle<BiTuple<A, B>> { | ||
private final BiPredicate<A, B> predicate; | ||
|
||
public ConditionalBiTupleLifecycle(BiPredicate<A, B> predicate, TupleLifecycle<BiTuple<A, B>> tupleLifecycle) { | ||
super(tupleLifecycle); | ||
this.predicate = predicate; | ||
} | ||
|
||
@Override | ||
protected boolean test(BiTuple<A, B> tuple) { | ||
return predicate.test(tuple.factA, tuple.factB); | ||
} | ||
|
||
} |
12 changes: 6 additions & 6 deletions
12
...re/stream/bavet/bi/FlattenLastBiNode.java → ...core/impl/bavet/bi/FlattenLastBiNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...vet/bi/Group0Mapping1CollectorBiNode.java → ...vet/bi/Group0Mapping1CollectorBiNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...vet/bi/Group0Mapping2CollectorBiNode.java → ...vet/bi/Group0Mapping2CollectorBiNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...vet/bi/Group0Mapping3CollectorBiNode.java → ...vet/bi/Group0Mapping3CollectorBiNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...vet/bi/Group0Mapping4CollectorBiNode.java → ...vet/bi/Group0Mapping4CollectorBiNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...vet/bi/Group1Mapping0CollectorBiNode.java → ...vet/bi/Group1Mapping0CollectorBiNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...vet/bi/Group1Mapping1CollectorBiNode.java → ...vet/bi/Group1Mapping1CollectorBiNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.