Project: Моделирование труднорешаемых задач
Views: 16Visibility: Unlisted (only visible to those who know the link)
Image: ubuntu2204Kernel: Python 3 (ipykernel)
In [1]:
Генератор тестовых данных
In [2]:
In [3]:
(3,
10,
50,
array([[ 10, 0, -3],
[ -9, -4, -10],
[ -7, -9, -9],
[ 0, -9, -8],
[ 2, 10, 3],
[ -2, -5, 9],
[ -1, 1, 1],
[ -9, 5, -4],
[ -7, 9, 3],
[ -8, 1, -2],
[ 6, -9, 8],
[ -3, 9, -2],
[-10, 9, 6],
[ -9, -2, 7],
[ -9, -1, 1],
[ 6, -10, 5],
[ -9, 2, 10],
[ 8, -4, -5],
[-10, 1, -7],
[ 3, 0, -5],
[ -7, -3, -9],
[ -4, -8, -3],
[ -8, 10, -3],
[ -7, -3, 8],
[ 0, -4, 0],
[ 1, 9, 0],
[ 0, 5, -10],
[ -9, -8, 0],
[ 3, -4, 10],
[ -4, -2, 7],
[ 8, 3, 0],
[ 4, -6, 1],
[ -9, -6, 9],
[ 9, 6, -3],
[ -6, 0, -10],
[ 0, 3, -10],
[ 2, 4, 6],
[ -5, -5, -2],
[ 4, -4, 9],
[ 3, -10, 2],
[ 3, 8, -7],
[ -7, 0, -8],
[ 0, 2, -10],
[-10, -3, -8],
[ 9, 10, 5],
[ -9, 0, -7],
[-10, -3, 1],
[ -3, 10, 10],
[ -3, 5, -4],
[ -4, 2, 10]]))
Pyomo-модель
In [4]:
In [5]:
# ==========================================================
# = Solver Results =
# ==========================================================
# ----------------------------------------------------------
# Problem Information
# ----------------------------------------------------------
Problem:
- Name: unknown
Lower bound: 49.0
Upper bound: 49.0
Number of objectives: 1
Number of constraints: 178
Number of variables: 60
Number of binary variables: 210
Number of integer variables: 210
Number of nonzeros: 50
Sense: maximize
# ----------------------------------------------------------
# Solver Information
# ----------------------------------------------------------
Solver:
- Status: ok
User time: -1.0
System time: 0.03
Wallclock time: 0.04
Termination condition: optimal
Termination message: Model was solved to optimality (subject to tolerances), and an optimal solution is available.
Statistics:
Branch and bound:
Number of bounded subproblems: 0
Number of created subproblems: 0
Black box:
Number of iterations: 1
Error rc: 0
Time: 0.07517719268798828
# ----------------------------------------------------------
# Solution Information
# ----------------------------------------------------------
Solution:
- number of solutions: 0
number of solutions displayed: 0
In [6]:
49.0
In [7]:
{0: 1.0,
1: 1.0,
2: 0.0,
3: 0.0,
4: 0.0,
5: 0.0,
6: 0.0,
7: 1.0,
8: 0.0,
9: 0.0}
In [8]:
{0: 1.0,
1: 1.0,
2: 1.0,
3: 1.0,
4: 1.0,
5: 1.0,
6: 1.0,
7: 1.0,
8: 1.0,
9: 1.0,
10: 1.0,
11: 1.0,
12: 1.0,
13: 1.0,
14: 1.0,
15: 1.0,
16: 1.0,
17: 1.0,
18: 1.0,
19: 1.0,
20: 1.0,
21: 1.0,
22: 1.0,
23: 1.0,
24: 1.0,
25: 1.0,
26: 1.0,
27: 1.0,
28: 1.0,
29: 1.0,
30: 1.0,
31: 1.0,
32: 1.0,
33: 1.0,
34: 1.0,
35: 1.0,
36: 1.0,
37: 1.0,
38: 1.0,
39: 1.0,
40: 1.0,
41: 1.0,
42: 1.0,
43: 1.0,
44: 0.0,
45: 1.0,
46: 1.0,
47: 1.0,
48: 1.0,
49: 1.0}
In [9]:
[True, True, False, False, False, False, False, True, False, False]
In [10]:
[[False, False, True],
[True, True, True],
[True, True, True],
[False, True, False],
[True, False, False],
[False, True, False],
[False, True, True],
[True, False, True],
[True, False, False],
[False, True, False],
[False, True, True],
[True, False, False],
[True, False, False],
[True, False, False],
[True, False, True],
[False, True, False],
[True, True, False],
[True, True, True],
[True, True, True],
[False, False, True],
[True, True, True],
[True, False, True],
[False, False, True],
[True, True, True],
[False, True, False],
[True, False, False],
[False, False, True],
[True, False, False],
[False, True, False],
[True, False, False],
[True, False, False],
[False, True, True],
[True, True, False],
[False, False, True],
[True, False, True],
[False, False, True],
[True, False, False],
[True, True, False],
[False, True, False],
[False, True, True],
[False, True, True],
[True, False, False],
[False, True, True],
[True, True, False],
[False, False, False],
[True, False, True],
[True, True, True],
[True, False, False],
[True, False, True],
[True, True, False]]
Вероятностная проверка SAT
In [11]:
In [12]:
array([[ 2, -1, 5],
[ 5, -4, 6],
[-1, -1, 4],
[ 6, -4, -4],
[ 3, -5, -3],
[ 3, 5, 4],
[ 4, -2, 3],
[-2, -2, -2],
[ 6, 2, -2],
[ 3, -5, 5]])
In [13]:
In [14]:
In [15]:
In [16]:
Yay!
In [ ]: