Accelerate the development of your Pyomo model and manage it in production with Nextmv. Pyomo is a Python-based, open source library that supports many solvers and is used to model a wide range of optimization problems, such as energy generation, inventory management, and scheduling. Nextmv is a DecisionOps platform that serves as the speed and trust layer for your optimization models.
In this blog post, we’ll walk through how to connect a Pyomo model to Nextmv’s DecisionOps to develop quickly, deploy safely, and scale to many use cases. What’s a DecisionOps platform? DecisionOps, like MLOps for optimization, brings transparency and standardization to the decision modeling process – from development to managing models in production.
- Observability. Create and share a system of record for your model. See when it was last updated and by whom. Dive into details of each run, including input, output, metadata, and logs.
- Experimentation. Answer what-if questions like, “What happens if I switch the solver?” or “How does changing this constraint affect costs?"
- Orchestration. Connect models (e.g., routing, scheduling) and data sources (e.g., Databricks, Snowflake) to create end-to-end decision workflows.
- Collaboration. Create a shared space for all of your optimization projects and get buy-in from stakeholders.
Without DecisionOps, data science and optimization teams often need months instead of weeks to deploy new models and updates, significant amounts of ongoing engineering support, and face challenges in getting stakeholder buy-in.
A Pyomo example
In this guide, we’ll look at the classic “diet problem” from Pyomo with the objective of minimizing the total cost of food while satisfying daily nutritional requirements. In addition to solving this problem, we also want to know if using different solvers or changing a constraint (e.g., limiting dairy) impacts the total cost? Here’s how we’ll connect the model to Nextmv and find answers to our “what if” questions:
- First, we’ll run the Pyomo model locally with no changes (just to see how it works)
- Next, we’ll push the Pyomo model as a decision app to the Nextmv platform for scalable, production-grade infrastructure
- After our app is live, we’ll run the model remotely via the Nextmv UI
- Then we’ll add options and statistics (metrics) to the decision app
- Lastly, we’ll perform a scenario test using configurable options (e.g., solver and a constraint to limit dairy)
Let’s dive in! (And if you’d like a visual companion, check out this video walkthrough.)
Get started with Nextmv
But before we begin, let’s get your Nextmv account set up!
- Sign up for a Nextmv account: cloud.nextmv.io/signup
- Verify your account (via an email to the address you provided)
- Start a free trial of the Innovator plan by clicking “Upgrade” in the top right of the Nextmv UI and then selecting “Innovator” on the “Plans” page
Note: Ensure you have Python and pip installed
Set up the model and run it locally
In this section, we’ll download the Pyomo project files and run the model locally on your machine.
Get the project files. Download the files from the “Pyomo example” folder in Google Drive. (It’ll probably zip them up when you download the whole folder.)

Put the following files in a directory named “pyomo-example” on your computer:
- diet.dat
- diet.py
- main.py
- requirements.txt
Install the requirements via terminal
Note: Make sure you’re in the pyomo-example directory you just created.
Note: You may need to use “pip3” command depending on your setup
Run the Python file via terminal to execute the model
Note: You may need to use “python3” command depending on your setup
Push the Pyomo model to Nextmv
In this section, we’ll walk through the steps required to connect the Pyomo model to Nextmv.
Configure your Nextmv API key. Navigate to “Settings” then “API Keys”. Copy your API key.

Export your API key via the terminal
- Option 1: From a Mac machine
- Option 2: From a Windows machine
Note: If you are using a Windows machine, use a PowerShell terminal with administrative privileges to allow for setting the environment variable.
Create an “app.yaml” file within the same directory (pyomo-example) and paste the following (and save the file):
Install Nextmv via terminal
Note: You may need to use “pip3” command depending on your setup
Create a “push.py” file in the same directory (pyomo-example) and save the file
Create an app from the model and push the app to Nextmv via terminal
Note: You may need to use “python3” command depending on your setup
Run the app remotely via the Nextmv UI
- Go to the Nextmv UI
- Select “Apps + Workflows” from the top menu
- Select your new app “Pyomo example”
- Click “New run” on the top right
- Click “Browse files for input” and select the diet.dat file you downloaded earlier
- Select instance “latest”
- Click “Start run” in the top right
Navigate to “Output” to see the results

Unlock configurable options and experimentation
In this section, we’ll walk through the steps required to create configurable options and custom statistics (or metrics) in Nextmv for experiments.
Add “nextmv” to requirements.txt
Update the app.yaml file with this code, which adds configuration for options. Completely replace the existing code in app.yaml with the following:
Update the diet.py file to add the dairy constraint. Completely replace the existing code in diet.py with the following:
Update the main.py file to wire up options. Completely replace the existing code in main.py with the following:
Push the changes up to the model in Nextmv via terminal
Note: You may need to use “python3” command depending on your setup
Make two runs of the app via the Nextmv UI
After you’ve pushed the changes up, navigate back to your app in the Nextmv UI and create a new run. Use the diet.dat file as the input and “latest” for the instance.

After your first run completes, click the “+” button in the top right and select “Clone run”. For the next run, try updating any of the options (e.g., solver).

Perform a scenario test
In this section, we’ll create an input set from existing runs and create a scenario test using the configurable options we wired up in the steps above.
Make an input set
- Under “Experiments” in the left-hand navigation, select “Input Sets”
- In the top right-hand corner, click “+” to create a new input set
- For “Create Type” select “Instance + date range”
- For “Instance” select “latest”
- For “Date Range” select “Past 24 hours"

Create a scenario test varying limit-dairy
- Under “Experiments” in the left-hand navigation, select “Scenario”
- In the top right-hand corner, click “+” to create a new scenario test
- Select the input set you just created
- Select “latest” instance
- Under Configuration, choose solvers “highs” and “scip”
- Under Configuration, add another option for “limit_dairy” and toggle it to “On”
- Click “Create scenario test”

Congrats! You’ve created a scenario test. You should see results that look like this:

We can see in this small example that limiting dairy did increase the total cost, but there was no impact on total cost from switching solvers.
What’s next?
Have questions? Reach out to us. We’d love to help. If you’re ready to keep exploring, try running more scenario tests, connecting your own Pyomo model, and inviting your teammates to join in!


