-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from nextmv-io/merschformann/add-pyoptinterfac…
…e-knapsack Adds knapsack-pyoptinterface app
- Loading branch information
Showing
21 changed files
with
696 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"items": [ | ||
{ | ||
"id": "cat", | ||
"value": 100, | ||
"weight": 20 | ||
}, | ||
{ | ||
"id": "dog", | ||
"value": 20, | ||
"weight": 45 | ||
}, | ||
{ | ||
"id": "water", | ||
"value": 40, | ||
"weight": 2 | ||
}, | ||
{ | ||
"id": "phone", | ||
"value": 6, | ||
"weight": 1 | ||
}, | ||
{ | ||
"id": "book", | ||
"value": 63, | ||
"weight": 10 | ||
}, | ||
{ | ||
"id": "rx", | ||
"value": 81, | ||
"weight": 1 | ||
}, | ||
{ | ||
"id": "tablet", | ||
"value": 28, | ||
"weight": 8 | ||
}, | ||
{ | ||
"id": "coat", | ||
"value": 44, | ||
"weight": 9 | ||
}, | ||
{ | ||
"id": "laptop", | ||
"value": 51, | ||
"weight": 13 | ||
}, | ||
{ | ||
"id": "keys", | ||
"value": 92, | ||
"weight": 1 | ||
}, | ||
{ | ||
"id": "nuts", | ||
"value": 18, | ||
"weight": 4 | ||
} | ||
], | ||
"weight_capacity": 50 | ||
} |
66 changes: 66 additions & 0 deletions
66
.nextmv/golden/knapsack-pyoptinterface/inputs/input.json.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"options": { | ||
"duration": 30, | ||
"input": "input.json", | ||
"output": "output.json", | ||
"version": "0.2.8" | ||
}, | ||
"solution": { | ||
"items": [ | ||
{ | ||
"id": "cat", | ||
"value": 100, | ||
"weight": 20 | ||
}, | ||
{ | ||
"id": "water", | ||
"value": 40, | ||
"weight": 2 | ||
}, | ||
{ | ||
"id": "phone", | ||
"value": 6, | ||
"weight": 1 | ||
}, | ||
{ | ||
"id": "book", | ||
"value": 63, | ||
"weight": 10 | ||
}, | ||
{ | ||
"id": "rx", | ||
"value": 81, | ||
"weight": 1 | ||
}, | ||
{ | ||
"id": "coat", | ||
"value": 44, | ||
"weight": 9 | ||
}, | ||
{ | ||
"id": "keys", | ||
"value": 92, | ||
"weight": 1 | ||
}, | ||
{ | ||
"id": "nuts", | ||
"value": 18, | ||
"weight": 4 | ||
} | ||
] | ||
}, | ||
"statistics": { | ||
"result": { | ||
"custom": { | ||
"constraints": 1, | ||
"status": "TerminationStatusCode.OPTIMAL", | ||
"variables": 11 | ||
}, | ||
"value": 444 | ||
}, | ||
"run": { | ||
"duration": 0.123 | ||
}, | ||
"schema": "v1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package mip | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/nextmv-io/sdk/golden" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
code := m.Run() | ||
os.Exit(code) | ||
} | ||
|
||
func TestGolden(t *testing.T) { | ||
golden.FileTests( | ||
t, | ||
"inputs", | ||
golden.Config{ | ||
Args: []string{ | ||
"-duration", | ||
"30", | ||
}, | ||
TransientFields: []golden.TransientField{ | ||
{ | ||
Key: "$.statistics.result.duration", | ||
Replacement: golden.StableFloat, | ||
}, | ||
{ | ||
Key: "$.statistics.run.duration", | ||
Replacement: golden.StableFloat, | ||
}, | ||
{ | ||
Key: "$.options.output", | ||
Replacement: "output.json", | ||
}, | ||
{ | ||
Key: "$.options.input", | ||
Replacement: "input.json", | ||
}, | ||
}, | ||
ExecutionConfig: &golden.ExecutionConfig{ | ||
Command: "python3", | ||
Args: []string{"../../../knapsack-pyoptinterface/main.py"}, | ||
InputFlag: "-input", | ||
OutputFlag: "-output", | ||
}, | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pip3 install -r requirements.txt |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python3 main.py -input input.json -output output.json -duration 30 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cat input.json | docker run -i --rm \ | ||
-v $(pwd):/app ghcr.io/nextmv-io/runtime/python:3.11 \ | ||
sh -c 'pip install -r requirements.txt > /dev/null && python3 /app/main.py' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/go | ||
{ | ||
"name": "Python", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "ghcr.io/nextmv-io/runtime/python:3.11", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": ["ms-python.debugpy", "ms-python.python"], | ||
"settings": { | ||
"python.defaultInterpreterPath": "python" | ||
} | ||
} | ||
}, | ||
"postCreateCommand": "pip install -r requirements.txt" | ||
} |
Oops, something went wrong.