Introduction to PIFOP Functions
Turn your Optimization Models into Web Services
PIFOP Functions is a new way of deploying mathematical optimization models to the cloud. It allows you to make your optimization programs (models, scripts, etc) executable from virtually any application, including Excel for the web, Google Sheets, your company's internal system and your client's website.
This wide-ranging integration capability is achieved by turning your optimization models into web services accessible via a REST API, which is what a PIFOP Function is.
Key Features
- Integration-ready: when a Function is created, it is immediatelly ready to be called via APIs and client libraries.
- Offer the solution without giving away the secret: callers of Functions developed by you have no access to the underlying optimization model.
- Any kind of project can be deployed as a Function: AMPL, GAMS, Python, C/C++, and more.
- Access control is in your hands: Functions require API keys to be used, which are generated and managed by you.
Use Cases
- Black-box consulting solutions: create optimization solutions for your clients without exposing the model behind it.
- One solution for many clients: create a single optimization solution and offer it to multiple of your clients.
- Extend existing applications with math optimization: integrate Functions into your company's internal systems and other applications.
- Create optimization-based plugins for popular applications: many applications that are widely used by your clients can be extended via plugins, such as Excel for the web and Google Sheets. PIFOP Functions makes it easier for you to develop and offer optimization-based plugins.
Simple Example: TSP Solver
This project implements an optimization model in AMPL to solve the Traveling Salesman Problem (TSP). We have deployed it as a PIFOP Function, and we are using it as the calculation backend for a demo web application.
Function Implemetation
This is the AMPL script that is executed when the Function is called:
Function Input and Output
Note that the above script reads the node coordinates from a file called coords.dat, which does not exist in the project itself. This file is supposed to be submitted by the caller of the Function, as specified by the "input" property in the Function configuration file.
Note also that the script writes the output to a file called result.json. This file can be downloaded by the caller of the Function after the execution is finished, as specified by the "output" property in the Function configuration file.
Function Configuration File
The func.json file is a Function configuration file. Among other things, here we define the Function id, the command that should be executed when the Function is called, the input files that it expects from the user and the output files it generates for the user:
Calling the Function from a Web Application
We use the PIFOP Functions JavaScript client API to call the TSP Function from the demo web application.
Here is a snippet of the code that calls the Function and displays the result:
The entire source code for the web application can be found here.