Skip to content

Commit 6d20714

Browse files
committed
minor optimizations
1 parent 86f0e33 commit 6d20714

File tree

4 files changed

+4
-14
lines changed

4 files changed

+4
-14
lines changed

src/RcppExports.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,3 @@ BEGIN_RCPP
3434
return rcpp_result_gen;
3535
END_RCPP
3636
}
37-
38-
static const R_CallMethodDef CallEntries[] = {
39-
{"_eive_cga_generate_chromosome", (DL_FUNC) &_eive_cga_generate_chromosome, 2},
40-
{"_eive_cga", (DL_FUNC) &_eive_cga, 3},
41-
{NULL, NULL, 0}
42-
};
43-
44-
RcppExport void R_init_eive(DllInfo *dll) {
45-
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
46-
R_useDynamicSymbols(dll, FALSE);
47-
}

src/ccga.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ NumericVector cga(int chsize, int popsize, Function evalFunc)
2727
NumericVector winner, loser;
2828
NumericVector cost1, cost2;
2929
int i, t;
30+
double mutation = 1.0 / (double)popsize;
3031
while (1)
3132
{
3233
cga_generate_chromosome(prob_vec, chromosome1);
@@ -47,11 +48,11 @@ NumericVector cga(int chsize, int popsize, Function evalFunc)
4748
{
4849
if (winner[i] == 1)
4950
{
50-
prob_vec[i] = prob_vec[i] + (1.0 / popsize);
51+
prob_vec[i] = prob_vec[i] + mutation;
5152
}
5253
else
5354
{
54-
prob_vec[i] = prob_vec[i] - (1.0 / popsize);
55+
prob_vec[i] = prob_vec[i] - mutation;
5556
}
5657
}
5758
}

src/registerDynamicSymbol.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <Rinternals.h>
55
#include <R_ext/Rdynload.h>
66

7-
void R_init_forega(DllInfo *info)
7+
void R_init_eive(DllInfo *info)
88
{
99
R_registerRoutines(info, NULL, NULL, NULL, NULL);
1010
R_useDynamicSymbols(info, TRUE);

src/symbols.rds

-4.38 KB
Binary file not shown.

0 commit comments

Comments
 (0)