-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmin_gen_set.py
More file actions
65 lines (53 loc) · 1.36 KB
/
min_gen_set.py
File metadata and controls
65 lines (53 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import flowpaths as fp
def example1():
numbers = [2,4,6,7,9]
total=13
mgs_solver = fp.MinGenSet(
numbers,
total=total,
weight_type=int,
# remove_sums_of_two=False,
# remove_complement_values=False,
)
mgs_solver.solve()
process_solution(mgs_solver)
def example2():
numbers = [2,4,6,7,9]
total=13
partition_constraints = [[6,4,3]]
mgs_solver = fp.MinGenSet(
numbers,
total=total,
weight_type=int,
partition_constraints=partition_constraints,
# remove_sums_of_two=False,
# remove_complement_values=False,
)
mgs_solver.solve()
process_solution(mgs_solver)
def example3():
numbers = [2,4,6,7,9]
total=13
partition_constraints = []
mgs_solver = fp.MinGenSet(
numbers,
total=total,
weight_type=int,
partition_constraints=partition_constraints,
# remove_sums_of_two=False,
# remove_complement_values=False,
)
mgs_solver.solve()
process_solution(mgs_solver)
def process_solution(model: fp.MinGenSet):
if model.is_solved():
print(model.get_solution())
else:
print("Model could not be solved.")
print(model.solve_statistics)
def main():
example1()
example2()
example3()
if __name__ == "__main__":
main()