MathVM

Roberto De Ioris - Code Plugins - Feb 21, 2024
Not Yet Rated

Math Expressions (parallel) evaluation and plotting

  • Supported Platforms
  • Supported Engine Versions
    5.3
  • Download Type
    Engine Plugin
    This product contains a code plugin, complete with pre-built binaries and all its source code that integrates with Unreal Engine, which can be installed to an engine version of your choice then enabled on a per-project basis.

MathVM exposes a simple framework (both C++ and Blueprint) for running user-defined math expressions:

y = sin(x) * 2

This expression will compute the sin of x and multiply it by 2. The result will be put in y.


The two symbols (x and y), can be local variables or globals (more on this below) and, in the case of x, it can be a constant.


There is a very important difference between local and global: MathVM supports running expressions in parallel (read: on multiple threads) but while accessing local variables is fully thread-safe and lock-free (each thread works on a different copy of them), global variables are shared between parallel evaluations.


For global variables a locking is required to avoid race conditions (see below). Constants are shared and lock-free (but obviously you cannot change them).


The native data type is double and multiple statements can be specified by using the ; separator:

y = tan(x * 2); y = y + (3 * sin(z)); final = y + x;

If there are parts of your expressions that works over global variables (or resources, see below), and you want to avoid race conditions you can "surround" critical sections with curly brackets (braces):

y = sin(z); {x = x + 1;}

Here the x increment (assuming x is a global variable) will be under lock.


Note: the compiler will automatically detect deadlocks


A plotter is included for drawing simple lines/points based graphs.


The plugin is open source under the MIT license. This marketplace version is meant for supporting the development of the project.

Technical Details

Features:

  •  Runtime evaluation of Math Expressions
  •  Parallel evaluation
  •  Plotting of results


Code Modules:

  •  MathVM (Runtime)


Number of Blueprints: 1

Number of C++ Classes: 10

Network Replicated: No

Supported Development Platforms: Windows, Linux, Mac

Supported Target Build Platforms: Windows, Linux, Mac, Android, iOS

Documentation: https://github.com/rdeioris/MathVM/blob/master/README.md