-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'network' of github.com:stevedwards/gurobi-optimods into…
… network
- Loading branch information
Showing
2 changed files
with
42 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,22 @@ | ||
# Implementation of your new mod. This should be copied to | ||
# src/gurobi_optimods/<mod-name>.py. You may alternatively want to include | ||
# your mod in an existing file, if it coexists naturally with other mods. | ||
# | ||
# In general the public API should be a single class or function. Go with | ||
# whatever makes the most sense for this mod. | ||
|
||
import gurobipy as gp | ||
|
||
|
||
def solve_mod(data): | ||
""" | ||
A sphinx-compatible docstring | ||
:param data1: Data structure for first argument | ||
:type data1: pd.DataFrame | ||
""" | ||
with gp.Env() as env, gp.Model(env=env) as model: | ||
# build model | ||
model.optimize() | ||
# post-process and return solution | ||
return |
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,20 @@ | ||
# Unit tests for your mod. This is separate from the example tests, it should | ||
# test smaller pieces of functionality, and can also test multiple cases. | ||
# This template should be copied to tests/test_<mod-name>.py | ||
|
||
import unittest | ||
|
||
from gurobi_optimods.datasets import load_mod_example_data | ||
from gurobi_optimods.networkdesign import solve_mod | ||
|
||
|
||
class TestMod(unittest.TestCase): | ||
def test_datasets(self): | ||
# If you added something to optimods.datasets, test it here | ||
data = load_mod_example_data() | ||
self.assertEqual(set(data.keys()), {"a", "b", "c"}) | ||
|
||
def test_simple(self): | ||
data = None | ||
solution = solve_mod(data) | ||
self.assertTrue(solution is None) |