You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now there are probabilistic crossovers out there that would require an extra probability parameter. The options are:
Create yet an extra function type
Add a void* to every function type
Implementing them as classes
Number (3) would be my preferred way in an OOP approach, and the one that we have used so far. However, I would like to do some tests before just to check what is the memory cost of such an approach ie. test the difference in memory usage.
First consider the function version:
classPatapouf;
typedefint (*function) (Patapouf& p, int i);
classPatapouf {
public:
function fn;
int val;
Patapouf(function fn_, int val_) : fn(fn_), val(val_) {}
intcall() {
return (*fn)(*this, val);
}
};
inttest(Patapouf& p, int i) {
return p.val + i*i*(i-5);
}
intmain() {
Patapouf p(test, 3);
return p.call();
}
Output size by avr-size
text data bss dec hex filename
0 264 0 264 108 build/avr/small.hex
text data bss dec hex filename
102 0 0 102 66 build/avr/small.o
text data bss dec hex filename
0 892 0 892 37c build/avr/small.hex
text data bss dec hex filename
202 0 0 202 ca build/avr/small.o
However this seems to be largely due to the inclusion of the delete operator (which gets added anyway in our library). In effect if I remove the virtual destructor here's the trace we get ie. almost the same as for the function:
text data bss dec hex filename
0 292 0 292 124 build/avr/small.hex
text data bss dec hex filename
134 0 0 134 86 build/avr/small.o
Now actually if I remove any virtual code let's see what happens:
In my GA library we are using function / function pointers. The problem is that eg. for crossover we are limited to the signature:
Now there are probabilistic crossovers out there that would require an extra probability parameter. The options are:
Number (3) would be my preferred way in an OOP approach, and the one that we have used so far. However, I would like to do some tests before just to check what is the memory cost of such an approach ie. test the difference in memory usage.
First consider the function version:
Output size by avr-size
Now the class version:
The size trace is a lot larger:
However this seems to be largely due to the inclusion of the delete operator (which gets added anyway in our library). In effect if I remove the virtual destructor here's the trace we get ie. almost the same as for the function:
Now actually if I remove any virtual code let's see what happens:
The trace becomes very very small:
So I think all and all it might not be that bad switching to class-based genetic operators...
The text was updated successfully, but these errors were encountered: