IMSL, Fortran - Rank of matrix function, rank(A), gives wrong results when used in Genetic Algorithm

IMSL, Fortran - Rank of matrix function, rank(A), gives wrong results when used in Genetic Algorithm

Dear friends,

I have got the problem with function of 'rank' when using it as a function calculating rank of a matrix in subroutine which has been called by Genetic Algorithm (GA) in Fortran code.

I have run two separate projects which used rank(A) as a function to calculate rank of matrix A which is built after a long procedure:

1. The first project, WITHOUT using GA, rank(A) is called just one time. Then, it gives a correct result of rank of matrix A which I have checked with Matlab

Here is the code and output file for the first project

Fortran short code which employed 'rank' function in main program

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

program main

use imsl_libraries
use linear_operators
!DEC$ OBJCOMMENT LIB:'libiomp5md.lib'
character*12 infile, outfile, plotfile,strfile
include 'comsol.f'
include 'link_fnl_shared.h'
integer i,j,k,nsol,nfinal
real*8 err(mki),fsol(mem),ginv(600,700)
integer ifile,rnk

...

...
call input
call mkcon !Build the Incidence matrix [C]
call mklen !Build the length matrix
call mkaaa !Build A matrix
!call dlsvrr(neq,nuk,aat,meq,21,1.d-5,irank,sval,uuu,meq,www,muk)
irank=rank(aat) !att is A matrix
nsi=nuk-irank
nki=nsi+neq-nuk
...
write(6,9001) irank,nsi,nki
...
9001 format(/5x,'irank : rank of matrix A....................',t50,i3,
+ /5x,'nsi (s): degree of statical indeterminacy....',t50,i3,
+ /5x,'nki (m): degree of kinematical indeterminacy.',t50,i3)
...
end

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Short Output file which show A matrix and calculated value of rank(A) from first project

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

....
Final A matrix

0.000E+00 0.000E+00 0.100E+01 0.000E+00 0.000E+00 0.707E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00
0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 -0.707E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00
0.100E+01 0.000E+00 0.000E+00 0.000E+00 0.707E+00 -0.707E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00
0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.707E+00 0.707E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00
0.000E+00 0.100E+01 -0.100E+01 0.707E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00
0.000E+00 0.000E+00 0.000E+00 -0.707E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00
-0.100E+01 0.000E+00 0.000E+00 -0.707E+00 0.000E+00 0.000E+00 -0.100E+01 0.000E+00 0.000E+00 0.000E+00
0.000E+00 0.000E+00 0.000E+00 0.707E+00 0.000E+00 0.000E+00 0.000E+00 -0.100E+01 0.000E+00 0.000E+00
0.000E+00 -0.100E+01 0.000E+00 0.000E+00 -0.707E+00 0.000E+00 0.000E+00 0.000E+00 -0.100E+01 0.000E+00
0.000E+00 0.000E+00 0.000E+00 0.000E+00 -0.707E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 -0.100E+01

....

irank : rank of matrix A................... 10
nsi (s): degree of statical indeterminacy... 0
nki (m): degree of kinematical indeterminacy 0
....

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

2. The second project, using GA, rank(A) is called THOUSANDS OF time due to searching algorithm of GA, it is needed to calculate rank of matrix for each candidate selected by GA. Then, it gives a WRONG result of rank of matrix A even for the candidate which gives identical A matrix in problem of first project 

Here is the code and output file for the second project

Fortran short code which employed 'rank' function in subroutine

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

subroutine ChkFrcMtd
!
use imsl_libraries
use linear_operators
!DEC$ OBJCOMMENT LIB:'libiomp5md.lib'
include 'link_fnl_shared.h'
!
include 'comsol.f'
integer nsi,nki,ark !irank,
real*8 uuu,www,fsval
...
irank=0
...
call mkcon !Build the Incidence matrix [C]
call mklen !Build the length matrix
call mkaaa !Build A matrix
!call dlsvrr(neq,nuk,aat,meq,20,1.d-10,irank,fsval,uuu,meq,www,muk)
irank = rank(aat) !att is A matrix
nsi=nuk-irank
nki=nsi+neq-nuk
...
write(6,*) 'irank: mathematical rank of matrix A...........',irank
write(6,*) 'nsi (s): degree of statical indeterminacy......',nsi
write(6,*) 'nki (m): degree of kinematical indeterminacy...',nki
...
return
end

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Short Output file selected from the candidate by GA which show identical A matrix to the first project with single try

...
Final A matrix

0.000E+00 0.000E+00 0.100E+01 0.000E+00 0.000E+00 0.707E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00
0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 -0.707E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00
0.100E+01 0.000E+00 0.000E+00 0.000E+00 0.707E+00 -0.707E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00
0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.707E+00 0.707E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00
0.000E+00 0.100E+01 -0.100E+01 0.707E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00
0.000E+00 0.000E+00 0.000E+00 -0.707E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00
-0.100E+01 0.000E+00 0.000E+00 -0.707E+00 0.000E+00 0.000E+00 -0.100E+01 0.000E+00 0.000E+00 0.000E+00
0.000E+00 0.000E+00 0.000E+00 0.707E+00 0.000E+00 0.000E+00 0.000E+00 -0.100E+01 0.000E+00 0.000E+00
0.000E+00 -0.100E+01 0.000E+00 0.000E+00 -0.707E+00 0.000E+00 0.000E+00 0.000E+00 -0.100E+01 0.000E+00
0.000E+00 0.000E+00 0.000E+00 0.000E+00 -0.707E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 -0.100E+01

...

irank: mathematical rank of matrix A........... 12
nsi (s): degree of statical indeterminacy...... -2
nki (m): degree of kinematical indeterminacy... -2

...

-----------------------------------------------------------------------------------------------------------

Have you ever met this kind of phenomena?

Is there any problem with my code or imsl library?

Please help me to clarify this issue.

Please let me know if you need more information or short code for clarifying the problem.

Thank you in advance.

Xuan-Hoang.

1 Beitrag / 0 neu
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.