Project: Моделирование труднорешаемых задач
Views: 22Visibility: Unlisted (only visible to those who know the link)
Image: ubuntu2204Kernel: Python 3 (ipykernel)
In [10]:
Генератор тестовых данных
In [11]:
In [12]:
(3,
10,
50,
array([[ 0, -4, 6],
[ 0, -8, -1],
[ -8, 8, -2],
[ 0, -3, -9],
[ 1, -4, -8],
[ 10, -3, 5],
[-10, -8, 3],
[ 7, -3, -8],
[ -1, -10, -1],
[ 1, -1, 8],
[ -8, -5, 0],
[ -5, 3, -4],
[ -4, -10, 1],
[ -2, 2, 2],
[ 3, 0, 5],
[ 5, -4, -6],
[ -5, 4, 6],
[ 10, 4, -9],
[ -4, 8, -1],
[ 7, -1, -9],
[ -1, -9, -2],
[ -5, -3, 0],
[ 6, -9, -9],
[ -2, 2, -8],
[ -7, -3, -3],
[ 8, 1, 0],
[ 2, 9, 0],
[ -4, -8, 2],
[ 2, -1, 9],
[ -2, 3, 5],
[ -3, -9, 6],
[ -9, 9, 0],
[ -7, 1, 5],
[ 4, 0, 0],
[ 1, -9, -1],
[ 9, -8, 1],
[ 2, -2, 4],
[ -3, -7, -10],
[ -7, -10, -1],
[ 10, 7, 6],
[ 3, 4, 0],
[ 7, -7, 4],
[ 6, -2, -2],
[ 3, 0, 8],
[ -4, 5, -5],
[ 10, 3, 0],
[ -1, -7, -2],
[ 3, 9, 4],
[ 3, 4, -7],
[ -8, 0, 8]]))
Pyomo-модель
In [13]:
In [14]:
# ==========================================================
# = Solver Results =
# ==========================================================
# ----------------------------------------------------------
# Problem Information
# ----------------------------------------------------------
Problem:
- Name: unknown
Lower bound: 35.0
Upper bound: 35.0
Number of objectives: 1
Number of constraints: 170
Number of variables: 60
Number of binary variables: 210
Number of integer variables: 210
Number of nonzeros: 50
Sense: minimize
# ----------------------------------------------------------
# Solver Information
# ----------------------------------------------------------
Solver:
- Status: ok
User time: -1.0
System time: 0.04
Wallclock time: 0.05
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: 0
Error rc: 0
Time: 0.12422013282775879
# ----------------------------------------------------------
# Solution Information
# ----------------------------------------------------------
Solution:
- number of solutions: 0
number of solutions displayed: 0
In [15]:
35.0
In [16]:
{0: 1.0,
1: 1.0,
2: 1.0,
3: 0.0,
4: 1.0,
5: 0.0,
6: 1.0,
7: 1.0,
8: 1.0,
9: 1.0}
In [17]:
{0: 1.0,
1: 0.0,
2: 1.0,
3: 0.0,
4: 1.0,
5: 1.0,
6: 1.0,
7: 1.0,
8: 0.0,
9: 1.0,
10: 0.0,
11: 1.0,
12: 1.0,
13: 1.0,
14: 1.0,
15: 1.0,
16: 0.0,
17: 1.0,
18: 1.0,
19: 1.0,
20: 0.0,
21: 0.0,
22: 0.0,
23: 1.0,
24: 0.0,
25: 1.0,
26: 1.0,
27: 1.0,
28: 1.0,
29: 1.0,
30: 0.0,
31: 1.0,
32: 1.0,
33: 0.0,
34: 1.0,
35: 1.0,
36: 1.0,
37: 0.0,
38: 0.0,
39: 1.0,
40: 1.0,
41: 1.0,
42: 0.0,
43: 1.0,
44: 1.0,
45: 1.0,
46: 0.0,
47: 1.0,
48: 1.0,
49: 1.0}
Вероятностная проверка SAT
In [18]:
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
/var/data/cocalc/1d588dae-0d14-422a-88b4-c470ec2c8303/hard-problems-formulations/minimum-k-satisfiability.ipynb Cell 12 line 1
----> <a href='vscode-notebook-cell://xn--17-6kce2c.xn--80apqgfe.xn--p1ai/var/data/cocalc/1d588dae-0d14-422a-88b4-c470ec2c8303/hard-problems-formulations/minimum-k-satisfiability.ipynb#X14sdnNjb2RlLXJlbW90ZQ%3D%3D?line=0'>1</a> raise NotImplementedError("Not yet ready")
NotImplementedError: Not yet ready
In [0]:
In [0]:
array([[ 4, 1, -5],
[-1, 5, 4],
[-2, 2, 1],
[-6, -2, -6],
[ 4, -4, -5],
[ 2, -5, -1],
[ 1, 5, -1],
[ 3, 4, -6],
[ 4, -4, -1],
[ 2, 4, 1]])
In [0]:
In [0]:
In [0]:
In [0]:
Discrpeancy found! C:
[[ 2 1 -4]
[ 4 3 4]
[ 2 2 -4]]
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Input In [23], in <cell line: 13>()
9 return False
11 return True
---> 13 assert test_3sat()
14 print("Yay!")
AssertionError:
In [0]: