Skip to content

Commit

Permalink
remove mypy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lperron committed Jul 24, 2024
1 parent 43765b0 commit c0c709c
Show file tree
Hide file tree
Showing 11 changed files with 1,868 additions and 1,735 deletions.
148 changes: 137 additions & 11 deletions examples/python/arc_flow_cutting_stock_sat.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,143 @@


DESIRED_LENGTHS = [
2490, 3980, 2490, 3980, 2391, 2391, 2391, 596, 596, 596, 2456, 2456, 3018,
938, 3018, 938, 943, 3018, 943, 3018, 2490, 3980, 2490, 3980, 2391, 2391,
2391, 596, 596, 596, 2456, 2456, 3018, 938, 3018, 938, 943, 3018, 943,
3018, 2890, 3980, 2890, 3980, 2391, 2391, 2391, 596, 596, 596, 2856, 2856,
3018, 938, 3018, 938, 943, 3018, 943, 3018, 3290, 3980, 3290, 3980, 2391,
2391, 2391, 596, 596, 596, 3256, 3256, 3018, 938, 3018, 938, 943, 3018,
943, 3018, 3690, 3980, 3690, 3980, 2391, 2391, 2391, 596, 596, 596, 3656,
3656, 3018, 938, 3018, 938, 943, 3018, 943, 3018, 2790, 3980, 2790, 3980,
2391, 2391, 2391, 596, 596, 596, 2756, 2756, 3018, 938, 3018, 938, 943,
3018, 943, 3018, 2790, 3980, 2790, 3980, 2391, 2391, 2391, 596, 596, 596,
2756, 2756, 3018, 938, 3018, 938, 943
2490,
3980,
2490,
3980,
2391,
2391,
2391,
596,
596,
596,
2456,
2456,
3018,
938,
3018,
938,
943,
3018,
943,
3018,
2490,
3980,
2490,
3980,
2391,
2391,
2391,
596,
596,
596,
2456,
2456,
3018,
938,
3018,
938,
943,
3018,
943,
3018,
2890,
3980,
2890,
3980,
2391,
2391,
2391,
596,
596,
596,
2856,
2856,
3018,
938,
3018,
938,
943,
3018,
943,
3018,
3290,
3980,
3290,
3980,
2391,
2391,
2391,
596,
596,
596,
3256,
3256,
3018,
938,
3018,
938,
943,
3018,
943,
3018,
3690,
3980,
3690,
3980,
2391,
2391,
2391,
596,
596,
596,
3656,
3656,
3018,
938,
3018,
938,
943,
3018,
943,
3018,
2790,
3980,
2790,
3980,
2391,
2391,
2391,
596,
596,
596,
2756,
2756,
3018,
938,
3018,
938,
943,
3018,
943,
3018,
2790,
3980,
2790,
3980,
2391,
2391,
2391,
596,
596,
596,
2756,
2756,
3018,
938,
3018,
938,
943,
]
POSSIBLE_CAPACITIES = [4000, 5000, 6000, 7000, 8000]

Expand Down
21 changes: 10 additions & 11 deletions examples/python/balance_group_sat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
Furthermore, if one color is an a group, at least k items with this color must
be in that group.
"""
from typing import Sequence
from typing import Dict, Sequence

from absl import app

from ortools.sat.python import cp_model


Expand Down Expand Up @@ -88,18 +90,15 @@ def main(argv: Sequence[str]) -> None:
num_items_per_group = num_items // num_groups

# Collect all items in a given color.
items_per_color = {}
for c in all_colors:
items_per_color[c] = []
items_per_color: Dict[int, list[int]] = {}
for color in all_colors:
items_per_color[color] = []
for i in all_items:
if colors[i] == c:
items_per_color[c].append(i)
if colors[i] == color:
items_per_color[color].append(i)

print(
"Model has %i items, %i groups, and %i colors"
% (num_items, num_groups, num_colors)
)
print(" average sum per group = %i" % average_sum_per_group)
print(f"Model has {num_items} items, {num_groups} groups, and {num_colors} colors")
print(f" average sum per group = {average_sum_per_group}")

# Model.

Expand Down
Loading

0 comments on commit c0c709c

Please sign in to comment.