-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfitness.f90
41 lines (38 loc) · 1.06 KB
/
fitness.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function fitness(vector)
use numz
use global_test
use map_stuff
implicit none
real(b8) fitness
integer, dimension(:),target :: vector
integer isize,i,tot
test_vect=>vector
isize=size(vector)
tot=0
! our function compares the color of every state
! to those to which it shares a boarder
! map(i)%list is the list of boarding states for state i
do i=1,isize
my_color=vector(i)
tot=tot+ltest(map(i)%list)
enddo
fitness=(100.0_b8-tot)/100.0_b8
end function
! function used by the fitness function
! compares the color of a list of states
! to "mycolor" adds 1 for each match
recursive function ltest(list) result (connect)
use list_stuff
use global_test
type(llist),pointer :: list
integer connect,tmp
if(.not. associated(list))then
connect=0
else
if(test_vect(list%index) == my_color)then
connect=1+ltest(list%next)
else
connect=ltest(list%next)
endif
endif
end function ltest