-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b407b3
commit aebfa8a
Showing
3 changed files
with
48 additions
and
14 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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
# Nextmv OR-Tools Python template | ||
# Nextmv AMPL Python template | ||
|
||
This template demonstrates how to solve a Mixed Integer Programming problem | ||
using the open source software suite [OR-Tools][or-tools]. | ||
using the AMPL Python package [amplpy][amplpy]. | ||
|
||
To solve a Mixed Integer Problem (MIP) is to optimize a linear objective | ||
function of many variables, subject to linear constraints. We demonstrate this | ||
by solving the knapsack problem using the [integer | ||
optimzation][integer-optimization] interface. | ||
by solving the knapsack problem. | ||
|
||
Knapsack is a classic combinatorial optimization problem. Given a collection of | ||
items with a value and weight, our objective is to maximize the total value | ||
|
@@ -15,10 +14,14 @@ without exceeding the weight capacity of the knapsack. | |
The input defines a number of items which have an id to identify the item, a | ||
weight and a value. Additionally there is a weight capacity. | ||
|
||
The most important files created are `main.py` and `input.json`. | ||
The most important files created are `main.py`, `input.json`, and | ||
`KEY.template`. | ||
|
||
* `main.py` implements a MIP knapsack solver. | ||
* `input.json` is a sample input file. | ||
* `KEY.template` is a file demonstrating how to use the AMPL UUID license key. | ||
Copy this file into a `KEY` file and replace the contents with your actual | ||
license key. | ||
|
||
Follow these steps to run locally. | ||
|
||
|
@@ -28,13 +31,14 @@ Follow these steps to run locally. | |
pip3 install -r requirements.txt | ||
``` | ||
|
||
1. Run the command below to check that everything works as expected: | ||
2. Run the command below to check that everything works as expected: | ||
|
||
```bash | ||
python3 main.py -input input.json -output output.json -duration 30 | ||
python3 main.py -input input.json -output output.json \ | ||
-duration 30 -provider cbc | ||
``` | ||
|
||
1. A file `output.json` should have been created with the optimal knapsack | ||
3. A file `output.json` should have been created with the optimal knapsack | ||
solution. | ||
|
||
## Next steps | ||
|
@@ -45,5 +49,4 @@ Follow these steps to run locally. | |
our [documentation site](https://docs.nextmv.io). | ||
* Need more assistance? Send us an [email](mailto:[email protected])! | ||
|
||
[or-tools]: https://developers.google.com/optimization | ||
[integer-optimization]: https://developers.google.com/optimization/mip | ||
[amplpy]: https://amplpy.ampl.com/en/latest/?_gl=1*16ca5pw*_ga*Nzk4OTUwMDgwLjE3MDgzNTIzMzg.*_ga_FY84K2YRRE*MTcwODQ0NTgwMy42LjEuMTcwODQ0NTgzOC4wLjAuMA.. |
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 |
---|---|---|
@@ -1 +1,32 @@ | ||
ampl-module-amplgsl==20231107 | ||
ampl-module-baron==20230405 | ||
ampl-module-base==20240126 | ||
ampl-module-cbc==20240115 | ||
ampl-module-coin==20240115 | ||
ampl-module-conopt==20211109 | ||
ampl-module-copt==20240115 | ||
ampl-module-cplex==20240115 | ||
ampl-module-gcg==20230919 | ||
ampl-module-gecode==20220504 | ||
ampl-module-gjh==20231111 | ||
ampl-module-gurobi==20240115 | ||
ampl-module-highs==20240115 | ||
ampl-module-ilogcp==20230228 | ||
ampl-module-knitro==20240209 | ||
ampl-module-lgo==20190908 | ||
ampl-module-lindoglobal==20210406 | ||
ampl-module-loqo==20210410 | ||
ampl-module-minos==20211109 | ||
ampl-module-mosek==20240118 | ||
ampl-module-open==20240121 | ||
ampl-module-plugins==20240102 | ||
ampl-module-scip==20240121 | ||
ampl-module-snopt==20211109 | ||
ampl-module-xpress==20240115 | ||
amplpy==0.13.2 | ||
ampltools==0.7.4 | ||
certifi==2024.2.2 | ||
charset-normalizer==3.3.2 | ||
idna==3.6 | ||
requests==2.31.0 | ||
urllib3==2.2.1 |