MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / main

Function main

examples/machine_learning/geneticalgorithm.cpp:160–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160int main(int argc, char** argv) {
161 bool console = false;
162 const int n = 32;
163 const int nSamples = 16;
164 if (argc > 2 || (argc == 2 && strcmp(argv[1], "-"))) {
165 printf("usage: %s [-]\n", argv[0]);
166 return -1;
167 } else if (argc == 2 && argv[1][0] == '-') {
168 console = true;
169 }
170
171 try {
172 af::info();
173 printf(
174 "** ArrayFire Genetic Algorithm Search Demo **\n\n"
175 "Search for trueMax in a search space where the objective "
176 "function is defined as :\n\n"
177 "SS(x ,y) = min(x, n - (x + 1)) + min(y, n - (y + 1))\n\n"
178 "(x, y) belongs to RxR; R = [0, n); n = %d\n\n",
179 n);
180 if (!console) {
181 printf(
182 "The left figure shows the objective function.\n"
183 "The right figure shows current generation's "
184 "parameters and function values.\n\n");
185 }
186 geneticSearch(console, nSamples, n);
187 } catch (af::exception& e) { fprintf(stderr, "%s\n", e.what()); }
188
189 return 0;
190}

Callers

nothing calls this directly

Calls 2

infoFunction · 0.85
geneticSearchFunction · 0.85

Tested by

no test coverage detected