![]() ![]() |
optiGA is a general purpose genetic algorithm ActiveX control that offers the programmer/user a range of existing features but also a good amount of flexibility. In short, optiGA's features include: Binary, real and integer data types, 4 different types of selection method, 4 crossover methods (including a user-defined one), 4 mutation methods (also including a user-defined method), 4 different termination functions and the option to minimize or maximize the objective.
For example, passing something as simple as an integer requires you to pass a reference to a long variable. This effectively requires you to create a variable for every parameter you need to pass to optiGA. Thankfully, most of the optiGA settings can be set using the property sheet shown above.
Another ease issue has little to do with optiGA, but optiGA uses the VARIANT data type to pass things back and forth between the control and your application. This requires you to use SAFEARRAYs and other data types and functions that can overcomplicate simple issues. For example, here is the sample code required to display 4 values of a diophantine equation from the current generation:
void COptiGADlg::OnGenerationReportOptiga(float FAR* BestFitness,
long FAR* GenerationNumber, VARIANT FAR* BinaryGenes,
VARIANT FAR* RealGenes, VARIANT FAR* IntegerGenes,
long FAR* ElapsedTime, float FAR* GenerationMeanFitness)
{
VARIANT *pData;
SafeArrayAccessData(RealGenes->parray,(void**)&pData);
m_dA = pData[0].fltVal;
m_dB = pData[1].fltVal;
m_dC = pData[2].fltVal;
m_dD = pData[3].fltVal;
SafeArrayUnaccessData(RealGenes->parray);
UpdateData(FALSE);
}
Like I've mentioned, this complexity is due to the flexibility the VARIANT data type offers. Once the initial problem of using the SAFEARRAYs to pass information to and from the control, optiGA is easy to use. I managed to create the classic diophantine example relatively quickly, since creating the necessary fitness and generation statistic handlers was trivial using ClassWizard.
optiGA is available in a demonstration form that pops up a information dialog upon startup, see the OptiWater homepage for more details. Overall, optiGA is a good package with great features and excellent documentation but could have been a bit more language-independent.
| 8.3 | |||||||
|
Last Updated: 14/03/2001