Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ __marimo__/
# Nextmv stuff
.nextmv/
outputs/
output.json

# HiGHS stuff
connect-your-model-cli/highs/*/HiGHS/
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ Tutorials for getting up and running with the Nextmv Platform.
decision model to the Nextmv platform using the Python SDK.
1. [Connect your model - CLI](./connect-your-model-cli/): bring an external
decision model to the Nextmv platform using the Nextmv CLI.
1. [Explore new model - CLI](./explore-new-model-cli/): explore a new decision
model using a Nextmv community app and the Nextmv CLI.
1. [Free local experience](./free-local-experience/): run Nextmv Applications
locally using the Python SDK.
26 changes: 26 additions & 0 deletions connect-your-model-cli/highs/nextmv-ified/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,30 @@ HiGHS][highs-example] turned into a Nextmv Application.
cat inputs/problem.json | LD_LIBRARY_PATH=./HiGHS/build/lib ./main
```

* Run the scripts individually.

* `app1.sh`: Create a Nextmv Cloud Application.

```bash
bash app1.sh
```

* `app2.sh`: Push the local executable code to a Nextmv Cloud Application.

```bash
bash app2.sh
```

* `app3.sh`: Run the Nextmv Cloud application.

```bash
bash app3.sh
```

* `app4.sh`: Create an input set.

```bash
bash app4.sh
```

[highs-example]: https://github.com/ERGO-Code/HiGHS/blob/master/examples/call_highs_from_cpp.cpp
26 changes: 26 additions & 0 deletions connect-your-model-cli/ortools/nextmv-ified/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,30 @@ Deliveries authored by OR-Tools][ortools-example] turned into a Nextmv Applicati
java -jar main.jar
```

* Run the scripts individually.

* `app1.sh`: Create a Nextmv Cloud Application.

```bash
bash app1.sh
```

* `app2.sh`: Push the local executable code to a Nextmv Cloud Application.

```bash
bash app2.sh
```

* `app3.sh`: Run the Nextmv Cloud application.

```bash
bash app3.sh
```

* `app4.sh`: Create an input set.

```bash
bash app4.sh
```

[ortools-example]: https://developers.google.com/optimization/routing/pickup_delivery#complete_programs
39 changes: 34 additions & 5 deletions connect-your-model-python/highs/nextmv-ified/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,49 @@ HiGHS][highs-example] turned into a Nextmv Application.
python app2.py
```

* `app3.py`: syncs the local application runs to a Nextmv Cloud
application. Requires a valid Nextmv Cloud API key.
* Export your Nextmv Cloud API key for convenience, as it is required in the upcoming
scripts.

```bash
export NEXTMV_API_KEY="<YOUR_NEXTMV_API_KEY>"
```

* `app3.py`: creates a new Nextmv Cloud Application. Requires a valid Nextmv
Cloud API key.

```bash
python app3.py
```

* `app4.py`: pushes the local executable code to a Nextmv Cloud Application.
Requires a valid Nextmv Cloud API key.
* `app4.py`: syncs the local application runs to a Nextmv Cloud
application.

```bash
export NEXTMV_API_KEY="<YOUR_NEXTMV_API_KEY>"
python app4.py
```

* `app5.py`: pushes the local executable code to a Nextmv Cloud Application.

```bash
python app5.py
```

* `app6.py`: runs the Nextmv Cloud application, polling for results.

```bash
python app6.py
```

* `app7.py`: creates an input set from the last runs.

```bash
python app7.py
```

* `app8.py`: creates a scenario test using the input set.

```bash
python app8.py
```

[highs-example]: https://github.com/ERGO-Code/HiGHS/blob/master/examples/network_flow.py
9 changes: 2 additions & 7 deletions connect-your-model-python/highs/nextmv-ified/app3.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import os

from nextmv import cloud, local

# Instantiate the local application.
local_app = local.Application(src=".")
from nextmv import cloud

# Instantiate the cloud application.
client = cloud.Client(api_key=os.getenv("NEXTMV_API_KEY"))
Expand All @@ -13,6 +10,4 @@
id="test-highs-app",
exist_ok=True,
)

# Sync the local app's runs to the cloud app.
local_app.sync(target=cloud_app, verbose=True)
print("Cloud application created:", cloud_app.id)
18 changes: 7 additions & 11 deletions connect-your-model-python/highs/nextmv-ified/app4.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import os

import nextmv
from nextmv import cloud
from nextmv import cloud, local

# Instantiate the local application.
local_app = local.Application(src=".")

# Instantiate the cloud application.
client = cloud.Client(api_key=os.getenv("NEXTMV_API_KEY"))
cloud_app = cloud.Application.new(
client=client,
name="test-highs-app",
id="test-highs-app",
exist_ok=True,
)
cloud_app = cloud.Application.new(client=client, id="test-highs-app")

# Push the app.
manifest = nextmv.Manifest.from_yaml(dirpath=".")
cloud_app.push(manifest=manifest, app_dir=".", verbose=True)
# Sync the local app's runs to the cloud app.
local_app.sync(target=cloud_app, verbose=True)
16 changes: 4 additions & 12 deletions connect-your-model-python/highs/nextmv-ified/app5.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,8 @@

# Instantiate the cloud application.
client = cloud.Client(api_key=os.getenv("NEXTMV_API_KEY"))
cloud_app = cloud.Application.new(
client=client,
name="test-highs-app",
id="test-highs-app",
exist_ok=True,
)
cloud_app = cloud.Application.new(client=client, id="test-highs-app")

# Run the app.
run_result = cloud_app.new_run_with_result(
input_dir_path="./inputs", # Data is loaded from a dir.
run_options={"duration": "3"},
)
nextmv.write(run_result)
# Push the app.
manifest = nextmv.Manifest.from_yaml(dirpath=".")
cloud_app.push(manifest=manifest, app_dir=".", verbose=True)
21 changes: 6 additions & 15 deletions connect-your-model-python/highs/nextmv-ified/app6.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
import os
from datetime import datetime, timedelta, timezone

import nextmv
from nextmv import cloud

# Instantiate the cloud application.
client = cloud.Client(api_key=os.getenv("NEXTMV_API_KEY"))
cloud_app = cloud.Application.new(
client=client,
name="test-highs-app",
id="test-highs-app",
exist_ok=True,
)
cloud_app = cloud.Application.new(client=client, id="test-highs-app")

# Create the input set.
input_set = cloud_app.new_input_set(
id="input-set-2",
name="Input Set 2",
instance_id="latest",
start_time=datetime.now(timezone.utc) - timedelta(days=1),
end_time=datetime.now(timezone.utc),
# Run the app.
run_result = cloud_app.new_run_with_result(
input_dir_path="./inputs", # Data is loaded from a dir.
run_options={"duration": "3"},
)
nextmv.write(input_set)
nextmv.write(run_result)
37 changes: 11 additions & 26 deletions connect-your-model-python/highs/nextmv-ified/app7.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
import os
from datetime import datetime, timedelta, timezone

import nextmv
from nextmv import cloud

# Instantiate the cloud application.
client = cloud.Client(api_key=os.getenv("NEXTMV_API_KEY"))
cloud_app = cloud.Application.new(
client=client,
name="test-highs-app",
id="test-highs-app",
exist_ok=True,
)
cloud_app = cloud.Application.new(client=client, id="test-highs-app")

# Create the scenario test.
scenario_test_id = cloud_app.new_scenario_test(
id="scenario-test-2",
name="Scenario Test 2",
scenarios=[
cloud.Scenario(
scenario_input=cloud.ScenarioInput(
scenario_input_type=cloud.ScenarioInputType.INPUT_SET,
scenario_input_data="input-set-2",
),
instance_id="latest",
configuration=[
cloud.ScenarioConfiguration(
name="duration",
values=["1", "3", "5"],
),
],
),
],
# Create the input set.
input_set = cloud_app.new_input_set(
id="input-set-2",
name="Input Set 2",
instance_id="latest",
start_time=datetime.now(timezone.utc) - timedelta(days=1),
end_time=datetime.now(timezone.utc),
)
print(f"Created scenario test with ID: {scenario_test_id}")
nextmv.write(input_set)
29 changes: 29 additions & 0 deletions connect-your-model-python/highs/nextmv-ified/app8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os

from nextmv import cloud

# Instantiate the cloud application.
client = cloud.Client(api_key=os.getenv("NEXTMV_API_KEY"))
cloud_app = cloud.Application.new(client=client, id="test-highs-app")

# Create the scenario test.
scenario_test_id = cloud_app.new_scenario_test(
id="scenario-test-2",
name="Scenario Test 2",
scenarios=[
cloud.Scenario(
scenario_input=cloud.ScenarioInput(
scenario_input_type=cloud.ScenarioInputType.INPUT_SET,
scenario_input_data="input-set-2",
),
instance_id="latest",
configuration=[
cloud.ScenarioConfiguration(
name="duration",
values=["1", "3", "5"],
),
],
),
],
)
print(f"Created scenario test with ID: {scenario_test_id}")
39 changes: 34 additions & 5 deletions connect-your-model-python/pyomo/nextmv-ified/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,49 @@ Pyomo][pyomo-example] turned into a Nextmv Application.
python app2.py
```

* `app3.py`: syncs the local application runs to a Nextmv Cloud
application. Requires a valid Nextmv Cloud API key.
* Export your Nextmv Cloud API key for convenience, as it is required in the upcoming
scripts.

```bash
export NEXTMV_API_KEY="<YOUR_NEXTMV_API_KEY>"
```

* `app3.py`: creates a new Nextmv Cloud Application. Requires a valid Nextmv
Cloud API key.

```bash
python app3.py
```

* `app4.py`: pushes the local executable code to a Nextmv Cloud Application.
Requires a valid Nextmv Cloud API key.
* `app4.py`: syncs the local application runs to a Nextmv Cloud
application.

```bash
export NEXTMV_API_KEY="<YOUR_NEXTMV_API_KEY>"
python app4.py
```

* `app5.py`: pushes the local executable code to a Nextmv Cloud Application.

```bash
python app5.py
```

* `app6.py`: runs the Nextmv Cloud application, polling for results.

```bash
python app6.py
```

* `app7.py`: creates an input set from the last runs.

```bash
python app7.py
```

* `app8.py`: creates a scenario test using the input set.

```bash
python app8.py
```

[pyomo-example]: https://github.com/Pyomo/pyomo-gallery/blob/main/transport/transport.py
9 changes: 2 additions & 7 deletions connect-your-model-python/pyomo/nextmv-ified/app3.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import os

from nextmv import cloud, local

# Instantiate the local application.
local_app = local.Application(src=".")
from nextmv import cloud

# Instantiate the cloud application.
client = cloud.Client(api_key=os.getenv("NEXTMV_API_KEY"))
Expand All @@ -13,6 +10,4 @@
id="test-pyomo-app",
exist_ok=True,
)

# Sync the local app's runs to the cloud app.
local_app.sync(target=cloud_app, verbose=True)
print("Cloud application created:", cloud_app.id)
Loading