Pre-conference version. (6 pages full - yay!)

This commit is contained in:
Tom
2026-06-26 20:33:40 +02:00
parent 8e0d2842af
commit 0566162922
7 changed files with 235 additions and 164 deletions

31
code/README.md Normal file
View File

@@ -0,0 +1,31 @@
# How to run
## Linux & MacOS
Have python3 installed and install the necessary packages with (must be in the same working directory)
```bash
pip install -r requirements.txt
```
and now run the main script:
```bash
python ./main.py
```
## Windows
`main.py` uses a packages that doesn't work on Windows. Therefore I created `Dockerfile` to run it in a docker container. These are the commands used to run it.
``` bash
docker build --tag bool-sim .
docker run -it bool-sim
```
Note that if you want to write to a file, you have to manually copy it out of the container (path: `/app/output.txt`).
# How to use
Running `main.py` leads to a menu in which you are able to navigate using arrow keys, accept using `ENTER`, go back/quit using `q`, `ESCAPE` or by selecting the last option in the menu.
Stable distribution is available for probabilistic and asynchronous-random only. Furthermore it doesn't check if there are multiple eigenvalues which can cause wrong computations/weird output.
On input requests, you can put whatever (BE CAREFUL: this uses python's `eval()` function. Any python code inserted here can and will be executed!). On invalid inputs an error will be printed above the menu and the input field remains open. To abort changing a value in the input fields, leave it empty and press `ENTER`. It should say `Cancelled` above the menu.
Onto the menu in general. You first have the choice to setup a Boolean network from scratch, or use a preconfigured network.
Eitherway, next is the Boolean Network menu - here you can set the number of nodes, set the state, change update schemes, change update functions and simulate the network. The current state is always shown in the title (`Boolean Network: <time-step> | <state>`).
Updating can be done in single steps or multiple at once. Multiple steps can write the output to a file in the current working directory. This file will always be named `output.txt` and overwrites this file if it exists.
The simulated steps are also shown in the console (up to 999 steps if writing to file is enabled).
Have fun!

View File

@@ -4,9 +4,10 @@ from typing import Callable, Optional
import numpy as np
from simple_term_menu import TerminalMenu
from simulator import BooleanNetwork
from typing_extensions import Concatenate
from simulator import BooleanNetwork
def ShowMenu(options: list[str], title: str = "", highlight_entry: int = 0) -> int:
menu = TerminalMenu(
@@ -231,6 +232,7 @@ def BooleanNetworkMenu(
return
try:
boolNetwork.SetState(state)
return
except AssertionError as e:
print("Invalid input:", e)
@@ -392,7 +394,7 @@ def BooleanNetworkMenu(
def main() -> None:
global currentFunction
currentFunction = MainMenu
np.set_printoptions(precision=4, linewidth=300, sign=" ")
np.set_printoptions(precision=5, linewidth=300, sign=" ")
while True:
currentFunction()