I am using the genetic algorithms code by R. Dimeo (www.ncnr.nist.gov/
staff/dimeo/idl_programs.html)
for the optimization of image classification. I have tried to pass
data (image matrices) to the function to by optimaze (test_func_1)
from the main program. First I tried with Functargs through keyword
Extra, as in Dimeo's notes pg 80 "Application Development in IDL", but
I got an error that said that the matrices have been undefined =BF?. I
have tried everything but always get the same error. Dimeo's code
works perfectly in my computer but when I put my data in I get my
"undefined variable" error. The funny thing is that actually it runs
the whole genetics algorithm, but at the end it produces the error.
Then I tried to pass the parameter directly as pointers (because they
are matrices 1000x1000) and the error says the same "undefined" or
that the variable should be a pointer.
I use to program in C++, and is my first programming in IDL, The code
of the function is something like this:
function test_func_1, p,G1_ptr,G2_ptr, _EXTRA =3D extra
x1 =3D p[0] & y1 =3D p[1]
z=3Dtotal(x1*(*G1_ptr)-y1*(*G2_ptr))
return,z
end
And the called from the main program
prange =3D [[-1.0,1.0],[-1.0,1.0]]
ofun =3D 'my_obj_fun'
func =3D'test_func_1'
GENES1 =3D fltarr(num_bands,num_cols,num_rows)
GENES2 =3D fltarr(num_bands,num_cols,num_rows)
GENES1[*,*,*]=3Dfid1
GENES2[*,*,*]=3Dfid2
G1 =3D fltarr(num_cols,num_rows)
G2 =3D fltarr(num_cols,num_rows)
G1[*,*]=3DGENES1[1,*,*]
G2[*,*]=3DGENES2[1,*,*]
G1_ptr=3Dptr_new(G1)
G2_ptr=3Dptr_new(G2)
quiet =3D 0B
if ~quiet then begin
xsize =3D 400 & ysize =3D 400
window,0,xsize =3D xsize,ysize =3D ysize
winvis =3D 0
window,/free,/pixmap,xsize =3D xsize,ysize =3D ysize
winpix =3D !d.window
iterargs =3D {winvis:winvis,winpix:winpix}
iterproc =3D 'test_ga_iterproc'
endif
ftol =3D 1.e-2
p =3D rmd_ga( ftol, $
function_value =3D function_value, $
function_name =3D func, $
prange =3D prange, $
; /boltzmann, $
ncalls =3D ncalls, $
quiet =3D quiet, $
objective_function =3D ofun, $
pcross =3D 0.95, $
gene_length =3D 30, $
pmutate =3D 0.01, $
stretch_factor =3D 1., $
itmax =3D 4, $ ; cambiar
esto
iterproc =3D iterproc, $
iterargs =3D iterargs, $
functargs=3D functargs, $
npop =3D 250 )
Do you know why is this error?


|