An open API service indexing awesome lists of open source software.

https://github.com/sakryukov/generic-state-machine

Transition system and state machine generic classes can be instantiated with any enumeration types representing the sets of states and the input and output alphabets
https://github.com/sakryukov/generic-state-machine

acceptors csharp dotnet enumeration finite-state-machine generics graph-algorithms graphs np-hard state-machine transducers transition-matrix transition-systems transitions

Last synced: 27 days ago
JSON representation

Transition system and state machine generic classes can be instantiated with any enumeration types representing the sets of states and the input and output alphabets

Awesome Lists containing this project

README

        

# Generic state machine

The classes [TransitionSystem](https://SAKryukov.GitHub.io/generic-state-machine#heading-class-transitionsystem),
[Acceptor](https://SAKryukov.GitHub.io/generic-state-machine#heading-class-acceptor),
and [Transducer](https://SAKryukov.GitHub.io/generic-state-machine#heading-class-transducer)
can be instantiated with any enumeration types representing the sets of states and the input and output alphabets. For example:

~~~
enum RoomDoorState { Locked, Closed, Opened,
OpenedInside, ClosedInside, LockedInside };
TransitionSystem transitionSystem = new();
~~~

Then the transition graph can be populated:

~~~
transitionSystem.AddValidStateTransition(RoomDoorState.ClosedInside, RoomDoorState.LockedInside,
(start, finish) => {
// command hardware actuator to lock the door
});
//...
transitionSystem.AddInvalidStateTransition(RoomDoorState.Locked, RoomDoorState.LockedInside,
(start, finish) =>
$"You cannot get in through the locked door"));
~~~

Note that both valid and some invalid transitions can be defined. The purpose of the invalid transition is to provide some information on why the transition is not permitted.
Both valid and invalid transitions can come with optional handlers accepting two arguments, the enumeration values representing starting and finishing states. In the case of a valid transition, the handler provides a side effect of transition.
For example, in the hardware automation applications, it can operate the hardware. In the case of an invalid transition, the handler returns a comment string explaining why the transition is not permitted.

Please see the comprehensive [API documentation](https://SAKryukov.GitHub.io/generic-state-machine).

For the rationale, general ideas, and mathematical aspects, please see the
[original publication](https://sakryukov.github.io/publications/2024-12-29.Enumeration-Based-Generic-State-Machine.html).