Deadling with Nan in GP

104 views
Skip to first unread message

aytem...@gmail.com

unread,
Mar 10, 2016, 11:04:34 PM3/10/16
to deap-users
Hi,

I have a GP and these are what the results look like:

en	nevals	avg        	max        	min        	std     	avg	max	min	std
0  	300   	6.15233e+13	6.15233e+13	6.15233e+13	0.015625	21 	21 	21 	0  
1  	64    	nan        	nan        	nan        	nan     	22.95	74 	21 	6.61721
<string>:1: RuntimeWarning: overflow encountered in power
<string>:1: RuntimeWarning: invalid value encountered in power
C:\Anaconda3\lib\site-packages\ipykernel\__main__.py:4: RuntimeWarning: invalid value encountered in double_scalars
<string>:1: RuntimeWarning: divide by zero encountered in power
<string>:1: RuntimeWarning: invalid value encountered in subtract
<string>:1: RuntimeWarning: invalid value encountered in multiply
2  	59    	nan        	nan        	nan        	nan     	36.35	204	21 	30.454 
C:\Anaconda3\lib\site-packages\ipykernel\__main__.py:7: RuntimeWarning: overflow encountered in double_scalars
<string>:1: RuntimeWarning: invalid value encountered in add
3  	58    	nan        	nan        	nan        	nan     	41.39	204	19 	32.3023
4  	68    	nan        	nan        	nan        	nan     	41.62	212	15 	30.1641
5  	68    	nan        	nan        	nan        	nan     	46.81	211	11 	38.0452
6  	66    	nan        	nan        	nan        	nan     	60.97	211	11 	51.426 
7  	52    	nan        	nan        	nan        	nan     	57.62	211	7  	46.7521
8  	56    	nan        	nan        	nan        	nan     	60.89	208	7  	50.5685
9  	61    	nan        	nan        	nan        	nan     	53.81	275	7  	48.5423
10 	56    	nan        	nan        	nan        	nan     	50.14	273	19 	42.8761
11 	57    	nan        	nan        	nan        	nan     	52.31	273	14 	42.9303
12 	64    	nan        	nan        	nan        	nan     	52.81	273	14 	43.4214
13 	60    	nan        	nan        	nan        	nan     	55.61	273	6  	50.3118
14 	55    	nan        	nan        	nan        	nan     	63.9 	273	17 	56.7941
15 	59    	nan        	nan        	nan        	nan     	71.32	273	19 	56.7575
16 	61    	nan        	nan        	nan        	nan     	74.79	273	15 	61.7094
17 	56    	nan        	nan        	nan        	nan     	70.07	273	15 	54.4577
18 	53    	nan        	nan        	nan        	nan     	71.16	273	20 	57.2108

Would anyone have any idea on what could be the causes of this and how can I work around this?

Thanks!

Marc-André Gardner

unread,
Mar 11, 2016, 2:45:38 AM3/11/16
to deap-users
Hi!

You seem to have a power primitive in your PrimitiveSet. This kind of primitive can be very tricky to work with, since it is extremely easy for tree to generate numerical errors (because the argument is simply too large). Most of the time, it is not really useful since low-order powers can easily be generated by the evolution by nesting two or more multiplications. If you really want to keep a power primitive, I would advise you to wrap it into a convience function able to cope with overflows, on the same model of the "safeDiv" primitive, which allows the evolution to continue even if one individual tries to divide by zero.

Have fun with DEAP,

Marc-André

aytem...@gmail.com

unread,
Mar 11, 2016, 9:10:48 AM3/11/16
to deap-users
Thanks a bunch for your response. Yes, I created a Power2 function and some other functions to handle this, but I was still getting a lot of Nans. Will try some other functions.

Thanks again!
Reply all
Reply to author
Forward
0 new messages