PyFOT is an open source, easy and robust framework that offers a customizable environment for programming and testing optimization algorithms and solving optimization problems as well. It joins the most necessary features for who needs to implement, test and improve optimization algorithms.
This project requires Python versions 3.8 or above.
Install pipenv by executing the following commands on terminal:
-
Windows:
pip install --user pipenv
-
Linux:
pip3 install --user pipenv
After installing pipenv, go to the project folder in your terminal and run below command to create Pipfile and Pipfile.lock files for the Python project.
pipenv install
PyFOT implements unit tests for the basic infrastructure. If you modify the inner modules, you can run the tests to see if the expected behaviors are not broken. To run the tests, execute the following command:
pipenv run test
It is possible to add more tests to custom implementations and it is encouraged.
PyFOT offers two ways to use its resources.
- The CLI, or Command Line Interface, provide an interactive interface that you can send commands to PyFOT to execute an Algorithm, evaluate a Problem for a solution or monitor results. To run this interface, you can run the following command, providing a configuration file:
pipenv run start -c my_config_file.json
ps: if you don't provide the configuration file, the default configuration file sample_config_file.json will be loaded.
- The API, or Application Programming Interface, provides the same as CLI, but it runs a Django REST API, making possible to call PyFOT's features through a browser or via Postman, for example. This feature is better than CLI, because it is more flexible to update data in the configuration file, being easier to change the Algorithm or the Problem to be executed, or its parameters, for example. To start the API on port 8000, you can run the following command:
pipenv run start-api
There are two ways to do it: via CLI or API. However, both uses a config file that must have an Algorithm and Problem specifications. The basic structure of a configuration file consists of an Algorithm and Problem. Refer to any of the files in (configs)[configs] directory to see some examples of configuration files.
After loading the configuration file as presented in section PyFOT CLI and API Features, you can execute the following:
- Through CLI: after loading the configuration file, a CLI interface will be created. The run command starts the execution of the configured Algorithm. This command starts a new thread that receives an ID starting at 1. To monitor the results, you can use the command summary/?id=<thread_id>. For example:
run
summary/?id=1
- Through API: after starting the REST API, you can use the following POST endpoint to load a configuration file <user_id>/set_config. The user_id is always 1 for release v2.1.3. Thus, to execute the Algorithm you can use the GET endpoint <user_id>/run and use the GET endpoint <user_id>/summary?thread_id=<thread_id>. Please, refer to the PyFOT Postman Collection to see some configuration file examples and other endpoints. If you don't have Postman installed, click here to go to the download page.
