Skip to content

Commit

Permalink
feat(ParameterVector): All parameters are vectors
Browse files Browse the repository at this point in the history
to allow for time-varying parameters. Also, removed old log because it
was conflicting on Windows. Tests are update as well as vignettes.
  • Loading branch information
kellijohnson-NOAA committed Sep 24, 2024
1 parent a3a09e8 commit b0efac2
Show file tree
Hide file tree
Showing 35 changed files with 2,750 additions and 1,799 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ project(FIMS
) # CXX is the language name

# GoogleTest requires at least C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

include(FetchContent)

Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
export(AgeComp)
export(BevertonHoltRecruitment)
export(CreateTMBModel)
export(SetFIMSFunctions)
export(Finalize)
export(DoubleLogisticSelectivity)
export(EWAAgrowth)
export(FIMSFrame)
Expand All @@ -16,7 +18,9 @@ export(Population)
export(TMBDlnormDistribution)
export(TMBDmultinomDistribution)
export(TMBDnormDistribution)
export(ToJSON)
export(clear)
export(get_log)
export(clear_logs)
export(get_fixed)
export(get_random)
Expand Down
12 changes: 6 additions & 6 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ Rcpp::loadModule(module = "fims", what = TRUE)
library.dynam.unload("FIMS", libpath)
}

setMethod("[<-", signature(x = "Rcpp_ParameterVector", i = "numeric"),
function(x, i) {
(x$at(i))
return(x)
})

setMethod("[<-", signature(x = "Rcpp_ParameterVector"), function(x, i, j, value) {
x$set(i - 1, value) # R uses 1-based indexing, C++ uses 0-based indexing
x # Return the modified object
})

setMethod("[", signature(x = "Rcpp_ParameterVector", i = "numeric"),
function(x, i) {
return(x$at(i))
return(x$get(i-1))
})

# setMethod("lapply", signature(X = "Rcpp_ParameterVector", FUN = "sum"),
Expand Down
27 changes: 1 addition & 26 deletions inst/include/common/def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// comments used to assist in diagnosing model issues and tracking progress.
// These files will only be created if a logs folder is added to the root model
// directory.
std::ofstream FIMS_LOG("logs/fims.log"); /**< Generic log file */
std::ofstream FIMS_LOG_OLD("logs/fims.log"); /**< Generic log file */
std::ofstream INFO_LOG("logs/info.log"); /**< Information.hpp log file */
std::ofstream ERROR_LOG("logs/error.log"); /**< Error tracking log file */
std::ofstream DATA_LOG("logs/data.log"); /**< Data input tracking log file */
Expand Down Expand Up @@ -50,31 +50,6 @@ std::ofstream DEBUG_LOG(

namespace fims {

/**
* A static class for FIMS logging.
*/

class fims_log {
public:
static std::map<std::string, std::ofstream>
FIMS_LOGS; /**< Map Log of files */
/**
* Static getter for retrieving a specific log file.
*/
static std::ofstream& get(const std::string& l) {
typename std::map<std::string, std::ofstream>::iterator it;
it = fims_log::FIMS_LOGS.find(l);
if (it == fims_log::FIMS_LOGS.end()) {
std::ofstream& of = fims_log::FIMS_LOGS[l];
of.open(l.c_str());
}

return fims_log::FIMS_LOGS[l];
}
};

std::map<std::string, std::ofstream> fims_log::FIMS_LOGS;

} // namespace fims

#endif /* TRAITS_HPP */
Loading

0 comments on commit b0efac2

Please sign in to comment.