//' Determines the Remaining useful life of a system based on its accumulated degradation value //' @title Compute Remaining Useful Life (computeRUL) //' @param lifeTab The life table created from createLifeTab or updateLifeTab. //' @param accDegVal The final accumulated degredation value of your data. //' @return The estimated remaining useful life of the system. //' @export // [[Rcpp::export]] double computeRUL(List lifeTab, double accDegVal){ NumericMatrix lifeTabMat = lifeTab[0]; for(int i = 0; i < lifeTabMat.nrow(); i++){ if(lifeTabMat.at(i,0)<accDegVal) return lifeTabMat.at(i,1); } return 0; }
// Initializes a food source void init( int index, NumericVector & fitness, NumericVector & f, IntegerVector & trial, Function & fun, NumericMatrix & Foods, const NumericVector & lb, const NumericVector & ub ) { for (int j=0; j<lb.size(); j++) Foods.at(index,j) = runif(1, lb.at(j), ub.at(j))[0]; f[index] = as<double>(fun(Foods(index,_))); fitness[index] = CalculateFitness(f[index]); trial[index] = 0; return; }