Table of Contents

API Clients

The SOLVER-AI API provides a set of client classes to facilitate the integration of Python, JavaScript, and C++ with the API. It also provides examples to help you understand how the API works. This document provides a detailed guide on how to use the API.

Note: Browsable API and code are interchangable and can be used together for differnet portions of setup and execution of a Problem.


github

The clients with its examples can be downloaded from https://github.com/SOLVER-AI-LTD/client.


setup.txt (IMPORTANT)

As first thing, edit the setup/setup.txt file and replace REPLACEWITHSOLVERAITOKENHERE with your token (which you can obtained from Account).


Folder Structure

The client folder contains the following sub-folders:

setup Folder

This folder contains the setup.txt file.

cpp, python and js Folders

The cpp, python and js folders contain the client classes:

the examples files which contain the code for the examples presented in this documentation:

the helper code for deleting for cleaning the data on your account:

example_files Folder

This folder contains the data used by the examples.

delete_everything code (USE WITH CAUTION)

The delete_everything code allows deleting all of the Problem and modules.

This code can be used as a starting point for deletin batches of Problems and modules making use of regular expressions based on Problem and module names. It leverages the following member functions of the SolverAiClientSetup class (see below):

C++

The cpp folder contains a Makefile for compileing all of the code with GCC. Compile from within the folder with command

make -f Makefile

Classes

SolverAiClientSetup

This class is used to set up the modules (Equation, Code, HardData and SoftData) and then set up a Problem for those modules. It also allows deletion of the modules and Problem as well as a complete cleanup after the solver has run. The class contains the following methods:

IMPORTANT: Remember that modules which have been associated with an existing Problem will not be allowed to be deleted, returning an error for those which have not been deleted.

SolverAiClientCompute

This class is used to run the solver for the problem set up by the SolverAiClientSetup class. It contains the following methods:

SolverAiComputeInput

This class is used to define the input for the solver, input to function runSolver of an object of class SolverAiClientCompute . It contains the following methods:

SolverAiComputeResults

This class is used to handle the results from the solver. It contains the following methods:

SolverAiResultsWriter

This class is used for writing the results (SolverAiComputeResults) to a csv file. It contains the following methods:


Examples

The examples in the python, js, and cpp folders demonstrate how to use the Client classes. They all perform the same actions, but in different languages. The examples have beed defined so to make them as clear as possible. The examples and data are intentionally extremely simple to help you understand how the SOLVER-AI API works.

Note that although the examples create, execute and delete the problem, this is not required or expected. The modules and Problem could be created via the Browsabel API and the Problem ID simply used in code. Or different codes could perform different operations depending on the work to be performed.

Here are brief descriptions of the examples:


Running the Solver

The solver is run as:

results = solverAiClientCompute.runSolver(input)

where input is of type SolverAiComputeInput and results is of type SolverAiComputeResults.

As the solver is capable of obtaining one or more solutions (depending on the problem) the data type returned by functions getX and getY of the SolverAiComputeResults will be different depending on the implementation:

An object results of type SolverAiComputeResults is such that assuming, getX or getY returned objects X and Y, respectively: