Skip to content

Commit

Permalink
NK-landscapes: evaluate active links the other way around for compati…
Browse files Browse the repository at this point in the history
…bility with Raphael's code
  • Loading branch information
Jakob Bossek committed Feb 5, 2024
1 parent 3fa490b commit bd251e3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
1 change: 1 addition & 0 deletions R/makeNKFunction.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ makeNKFunction = function(N, K) {

# delegate to flexible generator
nk_properties = generateRMNKFunction(M = 1L, N, K, rho = 0)
# print(nk_properties)

makeNKFunctionInternal(nk_properties, m = 1L)
}
Expand Down
26 changes: 13 additions & 13 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,18 +530,18 @@ BEGIN_RCPP
END_RCPP
}

RcppExport SEXP evaluateBBOBFunctionCPP(SEXP, SEXP, SEXP, SEXP);
RcppExport SEXP evaluateUFFunction(SEXP, SEXP, SEXP);
RcppExport SEXP getOptimumForBBOBFunctionCPP(SEXP, SEXP, SEXP);
RcppExport SEXP mof_MOP1(SEXP);
RcppExport SEXP mof_MOP2(SEXP);
RcppExport SEXP mof_MOP3(SEXP);
RcppExport SEXP mof_MOP4(SEXP);
RcppExport SEXP mof_MOP5(SEXP);
RcppExport SEXP mof_MOP6(SEXP);
RcppExport SEXP mof_MOP7(SEXP);
RcppExport SEXP mof_bk1(SEXP);
RcppExport SEXP mof_viennet(SEXP);
RcppExport SEXP evaluateBBOBFunctionCPP(void *, void *, void *, void *);
RcppExport SEXP evaluateUFFunction(void *, void *, void *);
RcppExport SEXP getOptimumForBBOBFunctionCPP(void *, void *, void *);
RcppExport SEXP mof_bk1(void *);
RcppExport SEXP mof_MOP1(void *);
RcppExport SEXP mof_MOP2(void *);
RcppExport SEXP mof_MOP3(void *);
RcppExport SEXP mof_MOP4(void *);
RcppExport SEXP mof_MOP5(void *);
RcppExport SEXP mof_MOP6(void *);
RcppExport SEXP mof_MOP7(void *);
RcppExport SEXP mof_viennet(void *);

static const R_CallMethodDef CallEntries[] = {
{"_smoof_dtlz_1", (DL_FUNC) &_smoof_dtlz_1, 2},
Expand Down Expand Up @@ -589,14 +589,14 @@ static const R_CallMethodDef CallEntries[] = {
{"evaluateBBOBFunctionCPP", (DL_FUNC) &evaluateBBOBFunctionCPP, 4},
{"evaluateUFFunction", (DL_FUNC) &evaluateUFFunction, 3},
{"getOptimumForBBOBFunctionCPP", (DL_FUNC) &getOptimumForBBOBFunctionCPP, 3},
{"mof_bk1", (DL_FUNC) &mof_bk1, 1},
{"mof_MOP1", (DL_FUNC) &mof_MOP1, 1},
{"mof_MOP2", (DL_FUNC) &mof_MOP2, 1},
{"mof_MOP3", (DL_FUNC) &mof_MOP3, 1},
{"mof_MOP4", (DL_FUNC) &mof_MOP4, 1},
{"mof_MOP5", (DL_FUNC) &mof_MOP5, 1},
{"mof_MOP6", (DL_FUNC) &mof_MOP6, 1},
{"mof_MOP7", (DL_FUNC) &mof_MOP7, 1},
{"mof_bk1", (DL_FUNC) &mof_bk1, 1},
{"mof_viennet", (DL_FUNC) &mof_viennet, 1},
{NULL, NULL, 0}
};
Expand Down
7 changes: 5 additions & 2 deletions src/nk_landscapes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ NumericVector evaluate_nk_landscape(Rcpp::List values, Rcpp::List links, Integer
unsigned int K = links_n.size();

// take into consideration the n-th bit-position itself
unsigned int offset = int(x[n]); // x[n] * pow(2, 0) = x[n] since pow(2, 0) = 1;
unsigned int offset = int(x[n]) * pow(2, K); //

// ... and for all epistatic links ...
for (int k = 0; k < K; ++k) {
// ... build the offset for the values table
int power2 = 1 << (k + 1);
int power2 = 1 << (K - k - 1);
//int power2 = pow(2, K - k - 1);
offset += int(x[links_n[k]]) * power2;
}
// workaround
// offset = pow(2, K + 1) - offset;

fval += as<NumericVector>(values[n])[offset];
}
Expand Down

0 comments on commit bd251e3

Please sign in to comment.