In this article:

Integration with Python

Integration with Java

Integration with R

Integration with LPSolve

Integration with TRAMO and SEATS

Connecting External Modules to Foresight Analytics Platform

Integration with Python

Integration with the Python programming language enables the user to extend Foresight Analytics Platform capabilities in the following tools: Modeling and ForecastingTime Series AnalysisReports. The Python functions are applied in the uniform formula editor.

NOTE. Integration with Python from 3.5 to 3.11 is supported. To see if newer versions are supported, an additional investigation is required. The bitness of Python and Foresight Analytics Platform must match.

NOTE. Astra Linux SE 1.7 already has preinstalled version of Python 3.7 that is why it must be used. If, for some reason, this version is missing, add a symbolic link to a library by executing the following command: sudo ln -s /usr/lib/python3.7/config-3.7m-x86_64-linux-gnu/libpython3.7m.so /opt/foresight/fp10.x-biserver/bin/

Steps for Python integration differ depending on the operating system in use.

For Python integration on Linux OS prebuild Python source files.

Python Build from Source Files on Linux OS

See below an example of Python source files build of 3.6.9 version on Astra Linux CE OS.

Execute the following operations:

  1. Download the archive with source files of Python 3.6.9:

wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz

  1. Unpack file form archive:

tar xvf Python-3.6.9.tgz
cd Python-3.6.9

  1. Add the configure file delivered with Python source files, parameters --enable-shared to generate dynamic library used by the platform and --prefix specifying Python installation folder:

./configure --enable-shared --prefix=/opt/python

  1. Compile Python source code, using altinstall:

sudo make altinstall

NOTE. The make altinstall command is used to prevent Python binary file from replacement, which is by default located at: S/usr/bin/python, where S is the path to the folder with installed Python.

Compilation result must be the following:

Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-18.1 setuptools-40.6.2

Integration with Python on Linux OS

See below the example of Python 3.6.9 integration on Astra Linux CE OS. Make sure that Python source files build is ready.

For Python integration on Astra Linux CE OS:

  1. Check that source files are correctly built and a new Python version is installed.

If the default version was not overwritten in the system, check the current Python version using the command:

python3.6 --version

  1. Execute one of the operations if the command was not found:

    • Add a path to the Python installation folder in the Path system variable:

echo export PATH=$PATH:/opt/python/bin >> ~/.bashrc
source ~/.bashrc

    • Determine a path to Python libpython3.*m.so library which was created using the --enable-shared parameter in Step 3:

echo export LD_LIBRARY_PATH="/opt/python/lib:$LD_LIBRARY_PATH" >> ~/.bashrc
source ~/.bashrc

On the first Python use, the platform will look for the library from the list:

libpython3.9.so, libpython3.8.so, libpython3.7m.so, libpython3.6m.so, libpython3.5m.so

The platform will use the first found library before the restart. Restart the BI server:

sudo systemctl restart apache2-fp10.x

For Python integration on Windows OS:

  1. Download Python distribution file.

  2. Install Python on the same computer where the Foresight Analytics Platform desktop application is installed. If Python is supposed to be used in the web application, install Python on the computer where BI server is located.

    • Select the Add Python <Version> to PATH checkbox in the Python installer to add a path to the folder with installed Python in the Path system variable.

If Python is installed via package, for example, Anaconda, also select the Add...to PATH checkbox during the installation. Therefore, Foresight Analytics Platform is integrated with Python. All executed scripts must be located in the folder with installed Foresight Analytics Platform.

To specify an additional folder with scripts:

  • Create a PythonPath string parameter in the registry and set up the required path to the additional scripts folder. The parameter is created in the registry key: [HKEY_CURRENT_USER\SOFTWARE\Foresight\Foresight Analytics Platform\10.0\DevEnv\Python].

  • Use the IPythonUtils.AddFolderToPythonPath method.

If several versions of Python were installed, and a specific version must be used, in Windows OS in the registry key [HKEY_CURRENT_USER\SOFTWARE\Foresight\Foresight Analytics Platform\10.0\DevEnv\Python] create the PythonLib string parameter and as its value specify name of the required version of Python library, for example, python39.dll.

If several Python versions are installed in Linux OS, execute the following operations:

  1. Add a symbolic link to the required library, for example:

ln -s /opt/python/lib/libpython3.9.so /opt/foresight/fp10.x-biserver/bin/

  1. In Windows OS in the registry key [HKEY_CURRENT_USER\SOFTWARE\Foresight\Foresight Analytics Platform\10.0\DevEnv\Python] create the PythonLib string parameter and as its value specify name of the required version of Python library, for example, libpython3.9.so. Save settings to the file with the *.reg extension to the folder /opt/foresight/fp10.x-biserver/bin.

NOTE. The [HKEY_CURRENT_USER] registry key can be replaced with [HKEY_LOCAL_MACHINE] if the path to the Python library is specified for all users and not only for the current user.

If the pip package management system was used to install Python, install the Python using the sudo pip3 command if search for Python libraries failed. If sudo is not used, Python is installed to the /home/user/.local/bin user folder, in which BI server cannot find Python libraries.

For details about creating Python modules, where codes of macros in the Python language are stored, see the Creating Python Modules section.

Integration with Java

Integration with the Java language enables the user to extend capabilities of Foresight Analytics Platform capabilities in the following tools: Modeling and ForecastingTime Series AnalysisReports. In the specified tools the Java functions are applied in the uniform expression editor.

Installing Java in Linux OS

If the Java language is already installed in Linux environment, steps 1-8 can be skipped. To install the Java language:

  1. Execute the commands in the terminal:

sudo mkdir /usr/lib/jvm
cd /usr/lib/jvm

  1. Download the .gz package at: https://www.oracle.com/java/technologies/downloads/#java8.

  1. Execute the command:

sudo tar -xvzf ~/Downloads/jdk-8u<Ver>-linux-x64.tar.gz

NOTE. The path to the .gz file may be different. Specify the path where the package was saved.

  1. Open the file with variables for edit:

sudo gedit /etc/environment

  1. Add the following strings to the end of the file:

J2SDKDIR="/usr/lib/jvm/jdk1.8.0_<Ver>"

J2REDIR="/usr/lib/jvm/jdk1.8.0_<Ver>/jre"

JAVA_HOME="/usr/lib/jvm/jdk1.8.0_<Ver>"

DERBY_HOME="/usr/lib/jvm/jdk1.8.0_<Ver>/db"

  1. If the file does not have the PATH variable, add the following value:

PATH="/usr/lib/jvm/jdk1.8.0_<Ver>/bin:/usr/lib/jvm/jdk1.8.0_<Ver>/db/bin:/usr/lib/jvm/jdk1.8.0_<Ver>/jre/bin:$PATH"

If the file has the variable, add the value to the list:

/usr/local/games:/usr/lib/jvm/jdk1.8.0_<Ver>/bin:/usr/lib/jvm/jdk1.8.0_<Ver>/db/bin:/usr/lib/jvm/jdk1.8.0_<Ver>/jre/bin

  1. Execute the following in the terminal:

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_<Ver>/bin/java" 0

sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_<Ver>/bin/javac" 0

sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_<Ver>/bin/java

sudo update-alternatives --set javac /usr/lib/jvm/jdk1.8.0_<Ver>/bin/javac

  1. Restart the terminal. To check the installed version, execute the command:

java -version

Integration with Java in Linux OS

  1. Add a symbolic link:

sudo ln -s /usr/lib/jvm/jdk1.8.0_<Ver>/jre/lib/amd64/server/libjvm.so /opt/foresight/fp10.x-biserver/bin/libjvm.so

  1. In Windows OS in the registry key [HKEY_CURRENT_USER\SOFTWARE\Foresight\Foresight Analytics Platform\10.0\DevEnv\Java] create the Java subsection, in which create the Options string parameter. This parameter will be used to specify additional options used on creating and working with a Java machine. Specify values in the Options parameter via comma. Save settings to the file with the *.reg extension to the folder /opt/foresight/fp10.x-biserver/bin/registry.

  2. Open the obtained *.reg file in the Linux environment and set values for the Options parameter:

"Options"="-Djava.home=/usr/lib/jvm/jdk1.8.0_<Ver>/jre"

  1. If the "Check Value of CLASSPATH" error is occurred at the runtime, add the value "-Dfile.encoding=UTF-8" via a comma to the Options parameter.

  2. It is also possible to specify in the Options parameter the paths to the files with custom classes (archives with custom classes). Separate paths with a semicolon, for example, "-Djava.class.path=/opt/foresight/fp10.x-biserver/:/usr/local".

NOTE. In the specified above commands <Ver> - Java language version.

For integration with the Java language install the following software:

  • Java SE Runtime Environment (JRE).

  • Java SE Development Kit (JDK).

NOTE. The installed Java must have version 8 or later. Bitness of Java and Foresight Analytics Platform must match.

After the installation is complete, execute the operations:

  1. Add the path to the folder with the jvm.dll library in the folder with installed JRE (for example, C:\Program Files\Java\jre1.8.0_<Ver>\bin\server\) to the Path system variable.

  2. In the registry key [HKEY_CURRENT_USER\SOFTWARE\Foresight\Foresight Analytics Platform\10.0\DevEnv] create the Java subsection, in which create the Options string parameter. This parameter will be used to specify additional options used on creating and working with a Java machine. Specify values in the Options parameter separating them with commas.

  3. In the Options parameter set the path to the installed JDK (path to the jre subdirectory in the folder with installed JDK), for example, "-Djava.home=c:/Program Files/Java/jdk1.8.0_<Ver>/jre/".

  4. It is also possible to specify in the Options parameter the paths to the files with custom classes (archives with custom classes). Separate paths with a semicolon, for example, "-Djava.class.path=D:/Work/Java/;D:/Test/".

For details about creating Java modules, where codes of modules in the Java language are stored, see the Creating Java Modules section.

NOTE. In the specified above commands <Ver> - Java language version.

Integration with R

Connection to R allows for extending capabilities of Foresight Analytics Platform capabilities in the following tools: Modeling and ForecastingTime Series Analysis and in the uniform formula editor.

To connect R:

  1. Install R on the local computer and the application server, if theTask Scheduler tool is used to start modeling problem calculation.

Steps for R installation differ depending on the operating system in use.

To install R on Astra Linux:

  1. Set up proxy server for the Bash command shell.

  2. Set up proxy server for the Apt-Get program that is used to install, update and delete program packages in Debian-based Linux OS distributions.

  3. Connect to the external Debian repository to download the R package files. To do this, open the /etc/apt/sources.list file for edit and add the following command to it:

deb http://ftp.ru.debian.org/debian/ stretch main

  1. Check package signatures from the repository. To do this, download GPG key for Debian repository and install it using the command:

sudo apt-key add <key file>

  1. Update package lists in the connected repository using the command:

sudo apt-get update

  1. Install R using the command:

sudo apt-get install r-base

NOTE. For details about R installation see R documentation.

  1. Install the Rserve package for the interaction of Foresight Analytics Platform with R using the commands:

sudo apt-get install r-cran-rserve

NOTE. For details about Rserve package installation see Rserve documentation.

  1. Start R.

  2. Connect the Rserve package using the command:

library(Rserve)

  1. Start the Rserve package using the command:

Rserve()

  1. Install the required R packages using the command:

install.packages("<package name>")

The list of required packages is given in the Which Foresight Analytics Platform Methods can be Calculated Using R? section.

  1. Register the Rserve package as a service:

    1. Create the rserve.service file in the /etc/systemd/system directory:

[Unit]
Description=Rserve

[Service]
Environment="ARG=--save --RS-encoding latin1"
Environment="R_HOME=/usr/lib/R"
ExecStart=/usr/lib/R/site-library/Rserve/libs//Rserve $ARG
Type=forking

[Install]
WantedBy=default.target

Where:

      • Environment with the ARG value. The argument for starting RServe with the use of latin1 encoding to provide correct query handling on calculation of formulas containing R methods.

      • Environment with the R_HOME value. Path to the folder with installed R.

      • ExecStart. Path to the RServe package.

      • WantedBy. The default.target output file contained in the /etc/systemd/system directory.

    1. Start Rserve:

systemctl daemon-reload
systemctl start rserve

NOTE. Registration of the Rserve package as a service is optional but it is recommended for automatic startup of R on startup of Foresight Analytics Platform.

After executing the operations, R will be installed on Astra Linux.

To install R on Windows:

  1. Load R installer.

  2. Install R.

NOTE. For details about R installation see R documentation.

  1. Add the path to the S\bin folder in the Path system variable, where S is the R installation folder.

  2. Start R and install the RServe package to interact with Foresight Analytics Platform with the R package using the command:

install.packages("RServe");

After executing the operation, during Rserve package installation the dialog box opens to select the server, from which package files are to be loaded. If the package is installed successfully, the corresponding message is displayed.

NOTE. For details about RServe package installation see RServe documentation.

  1. Copy the Rserve.dll, Rserve.exe, Rserve_d.exe files:

    • For 32-bit systems: from S\library\Rserve\libs\i386 to S\bin\i386.

    • For 64-bit systems: from S\library\Rserve\libs\x64 to S\bin\x64.

Where S is the R installation folder.

  1. Select the Packages > Install Package(s) main menu item and install the required R packages. If the packages have already been downloaded to the computer, they can be installed by selecting the Packages > Install Packages from Local Files main menu item. For details about packages required for R methods calculation see the Which Foresight Analytics Platform Methods can be Calculated Using R? section.

After executing the operations, R will be installed on Windows OS.

  1. In Foresight Analytics Platform specify the path, where R is installed or the server, where R is deployed.

NOTE. This step is required if R is installed on the workstation different from the workstation, where Foresight Analytics Platform is installed. If the R package is installed on the same workstation where Foresight Analytics Platform is installed, the path to the R directory will be already specified.

    1. Select the Tools > Parameters item in the main menu of:

      • The object navigator in the desktop application.

      • The Time Series Analysis tool in mobile application.

      • The Modeling and Forecasting tool in the web application. The item is available if any model is opened in the working area.

The Parameters dialog box opens.

    1. Go to the External Units tab and specify the path where R is installed, for example:

      • For Windows OS: C:\Program Files\R\R-3.0.3\.

      • For Linux OS: /usr/lib/R/site-library/Rserve/libs/.

Therefore, Foresight Analytics Platform is integrated with R.

Integration with LPSolve

Connection to LPSolve allows for expanding Foresight Analytics Platform capabilities in the following tools: Modeling and Forecasting, Calculation AlgorithmsTime Series Analysis.

To use the LPSolve solver:

  1. Download and unpack the lpsolve55.dll library for Windows or the liblpsolve55 for Linux. The library can be downloaded from one of the following websites:

  2. Specify the path to the library, depending on the operating system in use.

to specify the path to the liblpsolve55.so library, create the lpsolve55.reg file in the folder with installed Foresight Analytics Platform with the following contents:

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Foresight\Foresight Analytics Platform\10.0\StatCore]
"LPSolvePath"="/<path to file location>/liblpsolve55.so"

After executing the operations the path to the liblpsolve55.so library is specified.

to specify the path to the lpsolve55.dll library:

  1. Select the Tools > Parameters item in the main menu of:

    • The object navigator in the desktop application.

    • The Time Series Analysis tool in the desktop application.

  1. Go to the External Units tab and specify the path where the library is located. For example:

  1. Click the OK button.

After executing the operations the path to the lpsolve55.dll library is specified.

  1. Calculate the library checksum according to the GOST P 34.11-2012 algorithm with the hash length 256 bits.

To calculate the checksum of the liblpsolve55.so library in Linux OS, one can use OpenSSL:

openssl dgst -engine gost -md_gost12_256 <full path to library>

If OpenSSL is used, make sure that the encryption library by the GOST P 34.11-2012 algorithm is installed.

To calculate checksum of the lpsolve55.dll library in Windows OS, one can use the cpverify.exe CriptoPro utility:

cpverify.exe -mk -alg GR3411_2012_256 <full path to library>

  1. Save checksum result to a file or the LpSolveHash file without extension:

Therefore, Foresight Analytics Platform is integrated with LPSolve.

Integration with TRAMO and SEATS

Working with the TRAMO and SEATS statistical methods is available in Foresight Analytics Platform for Windows OS. When working in Linux OS one should execute the additional setup:

To execute additional setup in Astra Linux:

  1. Download the .deb package at: http://gretl.sourceforge.net/tramo/tramo-seats.html.

  2. Execute the command:

sudo dpkg -i tramo-seats_98-2_i386.deb

  1. If the error "Package architecture (i386) does not match system…" occurs, execute the following command and try again installing the package:

sudo dpkg --add-architecture i386

  1. If the error "dpkg: error processing package tramo-seats:i386 (--install): dependency problems…" occurs, execute the command to try again setting dependencies:

sudo apt --fix-broken install

After executing the specified operations the TRAMO and SEATS statistical methods become available in Linux.

See also:

Which Foresight Analytics Platform Methods can be Calculated Using R?