質問編集履歴
2
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -174,6 +174,96 @@
|
|
174
174
|
|
175
175
|
|
176
176
|
|
177
|
+
---------------------------------------------------------------------------
|
178
|
+
|
179
|
+
TypeError Traceback (most recent call last)
|
180
|
+
|
181
|
+
C:\Users\hashimoto\Anaconda3\lib\site-packages\deap\base.py in setValues(self, values)
|
182
|
+
|
183
|
+
184 try:
|
184
|
+
|
185
|
+
--> 185 self.wvalues = tuple(map(mul, values, self.weights))
|
186
|
+
|
187
|
+
186 except TypeError:
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
TypeError: 'numpy.float64' object is not iterable
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
During handling of the above exception, another exception occurred:
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
TypeError Traceback (most recent call last)
|
200
|
+
|
201
|
+
<ipython-input-1-b85bc257b291> in <module>
|
202
|
+
|
203
|
+
92
|
204
|
+
|
205
|
+
93 if __name__ == "__main__":
|
206
|
+
|
207
|
+
---> 94 main()
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
<ipython-input-1-b85bc257b291> in main()
|
212
|
+
|
213
|
+
87 stats.register("max", numpy.max)
|
214
|
+
|
215
|
+
88
|
216
|
+
|
217
|
+
---> 89 algorithms.eaSimple(pop, toolbox, cxpb=0.5, mutpb=0.2, ngen=1000, stats=stats,halloffame=hof)
|
218
|
+
|
219
|
+
90
|
220
|
+
|
221
|
+
91 return pop, stats, hof
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
C:\Users\hashimoto\Anaconda3\lib\site-packages\deap\algorithms.py in eaSimple(population, toolbox, cxpb, mutpb, ngen, stats, halloffame, verbose)
|
226
|
+
|
227
|
+
150 fitnesses = toolbox.map(toolbox.evaluate, invalid_ind)
|
228
|
+
|
229
|
+
151 for ind, fit in zip(invalid_ind, fitnesses):
|
230
|
+
|
231
|
+
--> 152 ind.fitness.values = fit
|
232
|
+
|
233
|
+
153
|
234
|
+
|
235
|
+
154 if halloffame is not None:
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
C:\Users\hashimoto\Anaconda3\lib\site-packages\deap\base.py in setValues(self, values)
|
240
|
+
|
241
|
+
191 "fitness with weights %s."
|
242
|
+
|
243
|
+
192 % (self.__class__, values, type(values),
|
244
|
+
|
245
|
+
--> 193 self.weights)).with_traceback(traceback)
|
246
|
+
|
247
|
+
194
|
248
|
+
|
249
|
+
195 def delValues(self):
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
C:\Users\hashimoto\Anaconda3\lib\site-packages\deap\base.py in setValues(self, values)
|
254
|
+
|
255
|
+
183 def setValues(self, values):
|
256
|
+
|
257
|
+
184 try:
|
258
|
+
|
259
|
+
--> 185 self.wvalues = tuple(map(mul, values, self.weights))
|
260
|
+
|
261
|
+
186 except TypeError:
|
262
|
+
|
263
|
+
187 _, _, traceback = sys.exc_info()
|
264
|
+
|
265
|
+
|
266
|
+
|
177
267
|
TypeError: Both weights and assigned values must be a sequence of numbers when assigning to values of <class 'deap.creator.FitnessMax'>. Currently assigning value(s) -1.3549805685970155 of <class 'numpy.float64'> to a fitness with weights (1.0,).
|
178
268
|
|
179
269
|
|
1
読みづらかったため<code>状にコードを挿入しました!
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
```ここに言語を入力
|
2
|
+
|
1
3
|
#必要なライブラリ,モジュールのインポートーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
|
2
4
|
|
3
5
|
import random
|
@@ -178,4 +180,10 @@
|
|
178
180
|
|
179
181
|
|
180
182
|
|
183
|
+
```
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
181
189
|
長文失礼します.プログラムが何故か動きません.おそらく最後の二行に問題があると思うのですがどなたか助けていただけないでしょうか.
|