質問編集履歴
2
誤字を修正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -108,7 +108,7 @@
|
|
108
108
|
|
109
109
|
constraints = cons,
|
110
110
|
|
111
|
-
bounds=((0,
|
111
|
+
bounds=((0, 500), (0, 100)),
|
112
112
|
|
113
113
|
method="trust-constr",
|
114
114
|
|
@@ -156,7 +156,7 @@
|
|
156
156
|
|
157
157
|
cons = (
|
158
158
|
|
159
|
-
{'type': 'ineq', 'fun': lambda x: 50
|
159
|
+
{'type': 'ineq', 'fun': lambda x: 50.0 - A_sp(x[0],x[1])},
|
160
160
|
|
161
161
|
{'type': 'ineq', 'fun': lambda x: B_sp(x[0],x[1]) - 30}
|
162
162
|
|
@@ -164,15 +164,7 @@
|
|
164
164
|
|
165
165
|
```
|
166
166
|
|
167
|
-
上記の記述に変更かつ`method="slsqp"`と変更すると, エラー
|
167
|
+
上記の記述に変更かつ`method="slsqp"`と変更すると, 同様のエラーが発生します.
|
168
|
-
|
169
|
-
```
|
170
|
-
|
171
|
-
all the input arrays must have same number of dimensions
|
172
|
-
|
173
|
-
```
|
174
|
-
|
175
|
-
が発生します.
|
176
168
|
|
177
169
|
|
178
170
|
|
@@ -186,6 +178,10 @@
|
|
186
178
|
|
187
179
|
)
|
188
180
|
|
181
|
+
|
182
|
+
|
183
|
+
method="slsqp"
|
184
|
+
|
189
185
|
```
|
190
186
|
|
191
187
|
|
1
ご指摘ありがとうございます. 定数が抜けていたため, 追記しました.
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,17 +28,55 @@
|
|
28
28
|
|
29
29
|
from scipy.optimize import minimize, NonlinearConstraint
|
30
30
|
|
31
|
+
xl= np.array([[0.0,100.0,200.0,300.0,400.0]])
|
32
|
+
|
33
|
+
yl= np.array([[0.0,25.0,50.0,75.0,100.0]])
|
34
|
+
|
35
|
+
a = np.array([[60.0,60.0,60.0,60.0,60.0], \
|
36
|
+
|
37
|
+
[100.0,90.0,70.0,45.0,40.0], \
|
38
|
+
|
39
|
+
[120.0,110.0,80.0,35.0,15.0], \
|
40
|
+
|
41
|
+
[130.0,120.0,100.0,40.0,5.0], \
|
42
|
+
|
43
|
+
[140.0,130.0,110.0,50.0,20.0], \
|
44
|
+
|
45
|
+
])
|
46
|
+
|
47
|
+
b = np.array([[0.0,0.0, 0.0, 0.0, 0.0], \
|
48
|
+
|
49
|
+
[60.0, 70.0, 60.0, 45.0, 2.0], \
|
50
|
+
|
51
|
+
[110.0,150.0,150.0,100.0,5.0], \
|
52
|
+
|
53
|
+
[160.0,210.0,230.0,170.0,8.0], \
|
54
|
+
|
55
|
+
[200.0,270.0,300.0,240.0,10.0], \
|
56
|
+
|
57
|
+
])
|
58
|
+
|
59
|
+
c = np.array([[100.0,100.0,100.0,100.0,100.0], \
|
60
|
+
|
61
|
+
[200.0,180.0,140.0,120.0,120.0], \
|
62
|
+
|
63
|
+
[300.0,250.0,200.0,180.0,170.0], \
|
64
|
+
|
65
|
+
[350.0,310.0,250.0,240.0,230.0], \
|
66
|
+
|
67
|
+
[400.0,360.0,300.0,320.0,310.0], \
|
68
|
+
|
69
|
+
])
|
70
|
+
|
71
|
+
|
72
|
+
|
31
|
-
A_sp = interpolate.RectBivariateSpline(x, y, a)
|
73
|
+
A_sp = interpolate.RectBivariateSpline(xl, yl, a)
|
32
|
-
|
74
|
+
|
33
|
-
B_sp = interpolate.RectBivariateSpline(x, y, b)
|
75
|
+
B_sp = interpolate.RectBivariateSpline(xl, yl, b)
|
34
|
-
|
76
|
+
|
35
|
-
C_sp = interpolate.RectBivariateSpline(x, y, c)
|
77
|
+
C_sp = interpolate.RectBivariateSpline(xl, yl, c)
|
36
|
-
|
37
|
-
|
78
|
+
|
38
|
-
|
39
|
-
#(値の取りうる範囲) 0≦x≦
|
79
|
+
#(値の取りうる範囲) 0≦x≦400, 0≦y≦100
|
40
|
-
|
41
|
-
|
42
80
|
|
43
81
|
def A(x):
|
44
82
|
|
@@ -50,7 +88,7 @@
|
|
50
88
|
|
51
89
|
def func(x):
|
52
90
|
|
53
|
-
return C_sp(x[0],x[1])
|
91
|
+
return C_sp(x[0],x[1])
|
54
92
|
|
55
93
|
def cons_f(x):
|
56
94
|
|
@@ -58,7 +96,7 @@
|
|
58
96
|
|
59
97
|
lb = [-np.inf, 30.00]
|
60
98
|
|
61
|
-
ub = [50
|
99
|
+
ub = [50.00, np.inf]
|
62
100
|
|
63
101
|
|
64
102
|
|