Skip to content

Commit

Permalink
add test for knapsack
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeisel committed Feb 6, 2024
1 parent 9f0d4bb commit 0bb3bee
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/test_costFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,39 @@ def test_max_cut(self):
)
self.assertEqual(response.status_code, 200)
print(response.get_json())

def test_knapsack(self):
response = self.client.post(
"/objective/knapsack",
data=json.dumps(
{
"items": [
{
"value": 5,
"weight": 2
},
{
"value": 2,
"weight": 1
},
{
"value": 3,
"weight": 2
}
],
"max_weights": 20,
"counts": {
"100000": 30,
"100001": 10,
"110000": 50,
"011110": 20,
"010110": 40
},
"objFun": "Expectation",
"visualization": "True"
}
),
content_type="application/json",
)
self.assertEqual(response.status_code, 200)
print(response.get_json())

0 comments on commit 0bb3bee

Please sign in to comment.