質問編集履歴

1

エラーメッセージの追加

2021/05/27 11:44

投稿

ym1111
ym1111

スコア16

test CHANGED
File without changes
test CHANGED
@@ -135,3 +135,69 @@
135
135
  print('最適解が求まりませんでした。')
136
136
 
137
137
  ```
138
+
139
+ #エラーメッセージ
140
+
141
+ ```
142
+
143
+ KeyError Traceback (most recent call last)
144
+
145
+ <ipython-input-13-a05dc75399fa> in <module>
146
+
147
+ 35 #制約条件の追加
148
+
149
+ 36 for i in I:
150
+
151
+ ---> 37 model += lpSum(x[i][j] for j in J) <= a[i]
152
+
153
+ 38 print(i)
154
+
155
+ 39 for j in J:
156
+
157
+
158
+
159
+ ~/opt/anaconda3/lib/python3.7/site-packages/pulp/pulp.py in lpSum(vector)
160
+
161
+ 2073 :param vector: A list of linear expressions
162
+
163
+ 2074 """
164
+
165
+ -> 2075 return LpAffineExpression().addInPlace(vector)
166
+
167
+ 2076
168
+
169
+ 2077
170
+
171
+
172
+
173
+ ~/opt/anaconda3/lib/python3.7/site-packages/pulp/pulp.py in addInPlace(self, other)
174
+
175
+ 763 elif (isinstance(other,list)
176
+
177
+ 764 or isinstance(other, Iterable)):
178
+
179
+ --> 765 for e in other:
180
+
181
+ 766 self.addInPlace(e)
182
+
183
+ 767 else:
184
+
185
+
186
+
187
+ <ipython-input-13-a05dc75399fa> in <genexpr>(.0)
188
+
189
+ 35 #制約条件の追加
190
+
191
+ 36 for i in I:
192
+
193
+ ---> 37 model += lpSum(x[i][j] for j in J) <= a[i]
194
+
195
+ 38 print(i)
196
+
197
+ 39 for j in J:
198
+
199
+
200
+
201
+ KeyError: 1
202
+
203
+ ```