|
From: | Fabio Mascelloni |
Subject: | Re: Problems with Map |
Date: | Fri, 19 Mar 1999 12:04:15 +0100 |
"Marcus G. Daniels" wrote:
Nothing jumps out at me. I suggest that you put diagnosticsThe problem has disappeared as soon as I've replaced the lines:
describing the map before and after each insertion. The diagnostics
should print the fitness values, and the object pointer values.
Then you should be able see where things go wrong.
with the lines:
[sel_list_Idx setOffSet: offSet1];
selMem1=[[sel_list_idx get] copy:[self getZone]];
[sel_list_Idx setOffSet:offSet2];
selMem2=[[sel_list_idx get] copy:[self getZone]];
where the copy: method is implemented in this way (with regard to this:is it correct?)
- copy:(id) aZone
{
Resource *obj;
unsigned idx;
obj=[aZone allocIVars:[self class]];
obj->selfFitness = selfFitness;
obj->selfLength = selfLength;
obj->selfConfig=[aZone alloc: selfLength*sizeof(float)];
for (idx = 0 ;idx < selfLength; idx++)
*(obj->selfConfig+idx)=*(selfConfig+idx);
return obj;
}
Even if I realize the first method was not much correct (if the same
member of the list was selected twice in the same iteration every change
on selMem1 had the side effect to change also selMem2),I still don't understand
why that caused an unordered insertion in the Map.
Finally one more question on memory allocation:every time a new iteration
of the for loop is entered, copies of two elements of the selection list
are assigned to selMem1 & selMem2; are these copies put in the same
memory zone in which selMem1 & selMem2 were first created,or in a new
zone?If is this the case ,is it advisable to free the memory allocated
to them at the end of each iteration and how can I do this?
Fabio.
[Prev in Thread] | Current Thread | [Next in Thread] |