Get started with Nextmv

Build a decision model in 5 minutes

Before continuing with this tutorial you will need to create a free Nextmv Cloud account and then follow the instructions after sign up to install Nextmv CLI.

1Configure Nextmv CLI

After downloading and installing Nextmv CLI, configure the CLI installation with your account:

nextmv configure --apiKey <YOUR_NEXTMV_CLOUD_API_KEY>
Copy

You’re now ready to start using the CLI and install Nextmv SDK.

Go to step 2

2Install Nextmv SDK

With Nextmv CLI, install Nextmv SDK with:

nextmv install
Copy
If you’re on macOS you may need to run a command to allow access to Nextmv SDK. This command will be output at the end of the installation process.

This will install Go and get the necessary plugins and other supporting files needed to build and run your model locally. Note that Nextmv SDK manages its own Go installation and will not affect your current Go installation if you have one.

You’re now ready to create your first project.

Go to step 3

3Initialize a new project using a template

With Nextmv CLI, initialize a new project with the Sudoku template:

nextmv init -t sudoku
Copy

This will create a new directory “sudoku” in your current working directory. Change into to this new sudoku directory:

cd sudoku
Copy

There are several files in this newly created directory. The main.go file contains all of the code for the Sudoku model and the input.json contains the sample input for the model (a matrix containing a starting grid for a sudoku problem).

In the next step you’ll run the sudoku model using the input.json file for the model input.

Go to step 4

4Run the model locally

With Nextmv CLI, run your newly created sudoku model:

nextmv run local main.go -- \
  -hop.runner.input.path input.json \
  -hop.solver.limits.duration 3s \
  -hop.solver.diagram.expansion.limit 1 \
  -hop.runner.output.path output.json
Copy

This command runs the model ( main.go ) specifying input.json as the model input, and output.json as where to store the model output. Running this command will create a new file in the current directory called output.json .

In the final step will inspect the model output in this new file.

Go to step 5

5View the results

Open the output.json file in your code editor to view the results of your model. Among the solver options and statistics you should see a store field with an array of arrays. This is your model’s solution to the sudoku problem (see formatted version below).

[
  [7, 4, 8,   9, 1, 6,   5, 3, 2],
  [1, 5, 9,   3, 2, 7,   6, 8, 4],
  [3, 2, 6,   8, 5, 4,   7, 1, 9],

  [5, 9, 3,   2, 6, 8,   4, 7, 1],
  [2, 1, 4,   5, 7, 3,   9, 6, 8],
  [6, 8, 7,   1, 4, 9,   3, 2, 5],

  [4, 3, 1,   7, 8, 5,   2, 9, 6],
  [8, 7, 5,   6, 9, 2,   1, 4, 3],
  [9, 6, 2,   4, 3, 1,   8, 5, 7]
]
Copy

Try changing the input.json file and re-running the model to see what kind of result you get. (You can leave off the -hop.runner.output.path flag if you want to the model output to appear directly in the terminal.)

These steps can also be repeated with any of the other templates (like routing). To see a list of available templates, run:

nextmv init -h
Copy