# Symbolx and karray: Optimization variables into python objects for efficient math operations and scenario analysis

Symbolx aims to simplify mathematical operations between resulting variables from optimization problems. Scenarios analysis and quick data visualization are the tool’s focus. Symbolx helps to keep track of variables and their dimensions when considering several scenarios. It also enables the user to make mathematical operations between variables with the support of Karray. Symbolx can work with several file formats, such as GAMS-GDX, arrow tables, and CSV. Custom parsers can be easily incorporated to read other file formats.

Karray is a simple tool that intends to abstract the users from the complexity of working with labelled multi-dimensional arrays. Numpy is the tool’s core, with an extensive collection of high-level mathematical functions to operate on multi-dimensional arrays efficiently thanks to its well-optimized C code. With Karray, we put effort into generating lightweight objects expecting to reduce overheads and avoid large loops that cause bottlenecks and impact performance. Numpy is the only relevant dependency, while Polars, Pandas and Pyarrow are required to import, export and store the arrays.

Karray can be partially compared with other tools, such as Xarray, a preferred tool for dealing with labelled multi-dimensional arrays. With Karray, we developed a distinctive feature that differs from Xarray. In Xarray, when two arrays with dimensions in common have different coordinates, it opts for the intersection of the items in front of a mathematical operation. This might lead to losing relevant information from the original arrays. Pandas can also operate with labelled multi-dimensional variables through, for example, multiIndex. Here, we noticed that Pandas also find the intersection of coordinates with known values to perform the operations. While the symmetric difference of the dimensions’ coordinate are filled with NAN values, making it more challenging to figure out which coordinates were replaced by NAN. In Karray, to avoid this issue, we opt for the union of the coordinates. The resulting array would have missing values, as one coordinate of the two variables does not exist. This is solved by letting the user decide which value to use for the missing item (zero is the default option).

We expect to show some relevant features during the workshop and apply them in cases where the tools might shine!

You can bring your laptop, and make sure you have a dedicated python 3.9 environment with the following packages: jupyter, plotly, and symbolx (pip install symbolx==0.3.1)

This work has been carried out as part of the development of dieterpy and will be included as a dependency in the upcoming dieterpy 2.0 release.

This work has been supported by research grants of the German Federal Ministry of Education and Research via the project “Ariadne”, FKZ 03SFK5NO.