質問編集履歴
1
コードを少し変更しました(途中で変数を使わず)が、エラーは同じです。
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,16 +2,17 @@
|
|
2
2
|
c = a * a + b * b
|
3
3
|
TypeError: Non-constant expressions cannot be multiplied
|
4
4
|
がでてきます。
|
5
|
-
|
5
|
+
```python
|
6
|
+
コード
|
6
7
|
from pulp import *
|
7
8
|
import matplotlib.pyplot as plt
|
8
9
|
|
9
10
|
W = 20
|
10
11
|
UB = 30
|
11
|
-
a =
|
12
|
+
a = []
|
12
|
-
b =
|
13
|
+
b = []
|
13
|
-
c =
|
14
|
+
c = []
|
14
|
-
sum_radius =
|
15
|
+
sum_radius = []
|
15
16
|
|
16
17
|
n = 6
|
17
18
|
r = [3, 2, 1, 3, 3, 2]
|
@@ -27,13 +28,10 @@
|
|
27
28
|
|
28
29
|
for i in range(n):
|
29
30
|
for j in range(n):
|
31
|
+
m += {{(x[j] - x[i]) * (x[j] - x[i])} + {(y[j] - y[i]) * (y[j] - y[i])}} >= {(r[i] + r[j]) * (r[i] + r[j])}
|
30
|
-
|
32
|
+
if i < j:
|
31
|
-
b = (y[i] - y[j])
|
32
|
-
c = a * a + b * b
|
33
|
-
|
33
|
+
m += u[i][j] + u[j][i] + v[i][j] + v[j][i] >= 1
|
34
|
-
|
34
|
+
|
35
|
-
m += c >= sum_radius
|
36
|
-
|
37
35
|
for i in range(n):
|
38
36
|
m += x[i] <= W-r[i]
|
39
37
|
m += y[i] <= H-r[i]
|
@@ -65,4 +63,5 @@
|
|
65
63
|
plt.ylabel("depth")
|
66
64
|
|
67
65
|
fig.savefig("test1.png")
|
68
|
-
plt.show()
|
66
|
+
plt.show()
|
67
|
+
```
|