I have opened a ticket for the Sequential Logic work I'm doing.
https://github.com/apache/incubator-kie-drools/issues/6182

I had a slight pause, but I have now resumed this work.

The sequential engine is a dedicated subsystem that integrates with Rete's
alpha network but uses a state machine rather than Rete's beta network to
drive the sequence matching. The current temporal operators (before, after,
etc.) all require beta joins, which are not as efficient as a state machine
and are not as flexible for complex sequences with loops.

When a sequence is matched, it enters the beta network for additional
relational joins or rule firing. Future versions will optimise the network
to avoid entering the beta network and fire immediately.

Under the hood is a dedicated state machine that moves through states when
signals are received from the SignalProcessors; the state machine is
optimised for integrations for the sources it interacts with. Those signals
are provided by logic gates once they become satisfied. The logic gates
matched data received from the event stream, which itself is from the alpha
network. The "feel" of the system is similar to how regular expression
matching works.

Because it only wants to attempt to match data for the current active
sequence or subsequence, it uses a flat list of current patterns to match
against. Bitmasks are used to get efficient routing from the input of data,
to the pattern matching to the appropriate logic gates and their parent
sequence.

The branch can be found here:
https://github.com/mdproctor/drools/tree/sequentiallogic

It's early days, however a lot of the unit tests are in place to show how
it works, but it's currently still very low level.  For those interested, a
lot of the unit tests can be found here:
https://github.com/mdproctor/drools/tree/sequentiallogic/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/sequencing


A sequence has 1...n steps. Currently, it supports LogicCircuits, Actions,
Aggregators and Subsequences.

https://github.com/mdproctor/drools/tree/sequentiallogic/drools-base/src/main/java/org/drools/base/reteoo/sequencing/steps


This test shows how to construct the logic gates, which are used within a
LogicCircuit:

https://github.com/mdproctor/drools/blob/sequentiallogic/drools-base/src/main/java/org/drools/base/reteoo/sequencing/signalprocessors/Gates.java

https://github.com/mdproctor/drools/blob/sequentiallogic/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/sequencing/PhreakSequencerLogicGateTest.java


A LogicGate is a type of SignalProcessor:

https://github.com/mdproctor/drools/blob/sequentiallogic/drools-base/src/main/java/org/drools/base/reteoo/sequencing/signalprocessors/LogicGate.java


Loops can occur on individual SignalProcesses or on Subsequences. Where
it's on a LogicGate, it tests the number of times the individual LogicGate
is matched.

https://github.com/mdproctor/drools/blob/sequentiallogic/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/sequencing/PhreakSequencerSignalProcessorCounterTest.java


Here is the conditional loop for SubSequence:

https://github.com/mdproctor/drools/blob/sequentiallogic/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/sequencing/PhreakSequencerSequenceLoopTest.java


Timers are supported as well on signal processors and subsequences. The
timer can be used to add delays or do timeouts.

https://github.com/mdproctor/drools/blob/sequentiallogic/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/sequencing/PhreakSequencerSignalProcessorTimerTest.java

https://github.com/mdproctor/drools/blob/sequentiallogic/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/sequencing/PhreakSequencerSequenceTimerTest.java


Lastly, you can do aggregations over subsequences:

https://github.com/mdproctor/drools/blob/sequentiallogic/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/sequencing/PhreakSequencerAggregatorTest.java


The next steps are to improve the unit tests and start to try and expose
this in the DRL language itself so end users can start to use it.


Regards


Mark









Mark

Reply via email to