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 ¿?. 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 = extra
x1 = p[0] & y1 = p[1]
z=total(x1*(*G1_ptr)-y1*(*G2_ptr))
return,z
end
And the called from the main program
prange = [[-1.0,1.0],[-1.0,1.0]]
ofun = 'my_obj_fun'
func ='test_func_1'
GENES1 = fltarr(num_bands,num_cols,num_rows)
GENES2 = fltarr(num_bands,num_cols,num_rows)
GENES1[*,*,*]=fid1
GENES2[*,*,*]=fid2
G1 = fltarr(num_cols,num_rows)
G2 = fltarr(num_cols,num_rows)
G1[*,*]=GENES1[1,*,*]
G2[*,*]=GENES2[1,*,*]
G1_ptr=ptr_new(G1)
G2_ptr=ptr_new(G2)
quiet = 0B
if ~quiet then begin
xsize = 400 & ysize = 400
window,0,xsize = xsize,ysize = ysize
winvis = 0
window,/free,/pixmap,xsize = xsize,ysize = ysize
winpix = !d.window
iterargs = {winvis:winvis,winpix:winpix}
iterproc = 'test_ga_iterproc'
endif
ftol = 1.e-2
p = rmd_ga( ftol, $
function_value = function_value, $
function_name = func, $
prange = prange, $
; /boltzmann, $
ncalls = ncalls, $
quiet = quiet, $
objective_function = ofun, $
pcross = 0.95, $
gene_length = 30, $
pmutate = 0.01, $
stretch_factor = 1., $
itmax = 4, $ ; cambiar
esto
iterproc = iterproc, $
iterargs = iterargs, $
functargs= functargs, $
npop = 250 )
Do you know why is this error?
|