Bring your custom Python decision model to Nextmv: Build, test, deploy

Accelerate development of your Python decision models – from completely custom models to those built using popular modeling tools – with features for testing, deploying, managing, and collaborating.

Operations researchers, data scientists, and software developers alike are using Python to develop decision models. Nextmv integrates directly with popular modeling tools and solvers like OR-Tools, AMPL, Pyomo, VROOM, HiGHS, and Gurobi which offer Python interfaces for solving optimization problems such as vehicle routing, shift scheduling, price optimization, inventory allocation, and more.

Now, with Nextmv’s language-based templates, you can develop and ship your custom Python decision models that use nearly any modeling tool or solver. Here are a few examples (in addition to the integrations listed above): Seeker , CVXPY, Python-MIP, PyOptInterface, Linopy, CPMpy, PuLP, and Clarabel

When you bring your custom Python model to Nextmv you can validate model changes, simulate scenarios, share run details and experiment results with stakeholders, and create a system of record for your decision model. (You can even incorporate Prophet, Statsmodels, and scikit-learn to better bridge the ML and OR gap – check out this talk.)

How to deploy your custom Python decision model to Nextmv

Start with our Python template and insert your model code into the main.py file.

The above is a very basic “Hello world” model that demonstrates how simple it is to paste your custom model into the template so you view results in the Nextmv platform.

There are a just a few basic concepts required for bringing your Python decision model to our DecisionOps platform. The model must: 

  • Read from either stdin or a file
  • Write results either to stdout or a file
  • Write logs to stderr
  • Format statistics in json to view in console

Tutorial using Python OR-Tools TSP

Let’s take a look at an OR-Tools example. In this step-by-step video, we’ll walk you through deploying a Python OR-Tools traveling salesperson problem (TSP) model using the Nextmv Python template.  

Here’s how simple it is to deploy a custom Python model once you’ve started a free trial and downloaded the Nextmv CLI

1. Create an app in the Nextmv UI

2. Initialize the Nextmv Python template via the Nextmv CLI

nextmv template init -t python

3. Copy the model code from the OR-Tools tsp.py sample

4. Paste the OR-Tools code into the main.py file of the Nextmv Python template. (You can delete the existing helper code that comes in the main.py file.)

5. Make minor changes to main.py

Move the imports up for a cleaner file.

Change all print statements to print to standard error so they’re visible in the Nextmv platform.

Print the output to standard error so it’s visible in the Nextmv platform.

Add OR-Tools packages to requirements.txt file.

6. Push the app to Nextmv via the Nextmv CLI

nextmv app push -a sample-tsp

7. Run the app via the Nextmv UI

Start a run using a blank input since the input is built into the OR-Tools TSP model.

8. Review run results including logs and statistics

Now you’re ready to run your Python app using API endpoints, perform experiments, and collaborate with teammates.

For more details on the Nextmv Python template, visit our documentation and our templates GitHub repo

DecisionOps for Python models

When you bring a custom Python model to Nextmv, you unlock a standardized DecisionOps workflow that adds efficiency to your modeling process. We view DecisionOps as a set of practices, tools, and infrastructure for operationalizing decision models quickly, consistently, and reliably. 

Deploy and scale. With a few lines of Python code and a single command, your Python-based decision app is running on managed, remote infrastructure. Scale to higher volume and more decision models without the hassle of provisioning resources.

Create and share experiments. Validate model changes with experiments like acceptance tests, scenario tests, and switchback tests. Share results with key stakeholders to improve confidence and understanding. 

Manage models and Git workflow. Create a system of record for your Python decision model. Create versions to manage model updates, share logs for faster troubleshooting and development, and incorporate practices like CI/CD

Getting started

Sign up for a free account and start a free trial to create a custom app in Python.

Have questions? We’d love to chat. Reach out to us directly or head to our community forum.

Video by:
No items found.