Skip to content

Commit

Permalink
minor edits
Browse files Browse the repository at this point in the history
  • Loading branch information
erelsgl committed May 15, 2024
1 parent 54dc223 commit 2021d12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions prtpy/objectives.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
"""
Define various optimization objectives for a partition algorithm.
>>> objectives = [MaximizeSmallestSum, MaximizeKSmallestSums(2), MinimizeLargestSum, MinimizeKLargestSums(2), MinimizeDifference]
>>> objectives = [MaximizeSmallestSum, MaximizeKSmallestSums(2), MinimizeLargestSum, MinimizeKLargestSums(2), MinimizeDifference, MinimizeDistAvg]
>>> for o in objectives: print(o.value_to_minimize(sums=[1,2,3,4,5], are_sums_in_ascending_order=True))
-1
-3
5
9
4
3.0
>>> objectives.append(MaximizeSmallestWeightedSum([1, 1, 1, 3, 4]))
>>> for o in objectives: print(o.value_to_minimize(sums=[2,4,1,5,3]))
-1
-3
5
9
4
3.0
-0.75
"""

Expand Down Expand Up @@ -201,6 +203,4 @@ def lower_bound(self, sums:list, sum_of_remaining_items:float, are_sums_in_ascen

if __name__ == "__main__":
import doctest

(failures, tests) = doctest.testmod(report=True)
print("{} failures, {} tests".format(failures, tests))
print(doctest.testmod())
3 changes: 1 addition & 2 deletions prtpy/partitioning/complete_greedy.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


def anytime(
binner: Binner, numbins: int, items: List[any], relative_value: List[any] = None,
binner: Binner, numbins: int, items: List[int], relative_value: List[int] = None,
objective: obj.Objective = obj.MinimizeDifference,
use_lower_bound: bool = True,
# Prune branches whose lower bound (= optimistic value) is at least as large as the current minimum.
Expand Down Expand Up @@ -310,7 +310,6 @@ def anytime(

if __name__ == "__main__":
import doctest, sys

(failures, tests) = doctest.testmod(report=True, optionflags=doctest.FAIL_FAST)
print("{} failures, {} tests".format(failures, tests))
if failures > 0:
Expand Down

0 comments on commit 2021d12

Please sign in to comment.