The official documentation for the Nextmv Python SDKs has been moved to this site. This page is not being updated anymore.
A decision model is a program that makes decisions, i.e.: solves decision problems. The model takes in an input (representing the problem data and options) and returns an output, which is the solution to the decision problem. The nextmv.Model class is the base class for all models. It holds the necessary logic to handle all decisions.
Your programs DO NOT need to use the nextmv.Model functionality to work with Nextmv Cloud.
As explained in the Deploy App section, a valid application in Nextmv is that which:
- Reads from
stdinor a file. - Writes to
stdoutor a file. - Conforms to the statistics convention for registering statistics.
- Contains an
app.yamlmanifest.
The nextmv.Model class is provided for two purposes:
- As an opinionated way to structure your models.
- As a feature to be able to push Python models to Nextmv Cloud directly, as they are converted to valid Nextmv applications.
With that clarified, let's see how to use the nextmv.Model class.
When creating your own decision model, you must create a class that inherits from nextmv.Model and implement the solve method.
Example
Here is an example of a simple knapsack problem, using highspy (HiGHS open-source solver).
Consider the following input and options to configure the solver:
You can define a DecisionModel that packs the knapsack with the most valuable items without exceeding the weight capacity.
To solve the problem, you can run the model with the input and options:
Push to Nextmv Cloud
If you want to run the model as a Nextmv Cloud app, you need two components:
- A model configuration. This configuration tells Nextmv Cloud how to load the model.
- An app manifest. Every Nextmv Cloud app must have a manifest that establishes how to run the app. It holds information such as the runtime, and files that the app needs.
Continuing with the knapsack problem, you can define the model configuration for it. From the config, there is a convenience function to create the manifest.
Once the model, options, model configuration, and manifest are defined, you can push the app to Nextmv Cloud.