-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 0.6.9 - small improvements, method to enhance functions with …
…boundaries
- Loading branch information
Showing
11 changed files
with
143 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
^Meta$ | ||
^temp$ | ||
^log$ | ||
^vignettes/log$ | ||
^\.github$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: simplaceUtil | ||
Title: Provides Utility Functions and ShinyApps to work with the modeling framework 'SIMPLACE' | ||
Version: 0.6.8 | ||
Date: 2024-06-20 | ||
Version: 0.6.9 | ||
Date: 2024-07-10 | ||
Authors@R: | ||
person("Gunther", "Krauss", , "[email protected]", role = c("aut", "cre")) | ||
Description: Provides Utility Functions and ShinyApps to work with the modeling framework 'SIMPLACE'. It visualises components of a solution, runs simulations and displays results. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#' Modifies function to return a penalty value for parameters outside boundaries | ||
#' | ||
#' The method takes a function as well as values for lower and upper boundaries | ||
#' and returns a modified function. The modified function returns the value of | ||
#' the original function when the parameters are within boundaries and the penalty | ||
#' value otherwise. | ||
#' | ||
#' Optionally an own function can be supplied to calculate whether the parameter | ||
#' is valid. The boundary function must take 3 arguments: parameter, | ||
#' lower boundary and upper boundary and must return TRUE or FALSE. | ||
#' | ||
#' A main use case of this method are optimisation / calibration tasks. If the | ||
#' optimisation method and the function to optimise are both ignorant to boundaries | ||
#' one can turn the function into a boundary sensitive one. | ||
#' | ||
#' @param fun function to be modified | ||
#' @param l_bound vector with lower boundary values | ||
#' @param u_bound vector with upper boundary values | ||
#' @param penalty_value value if parameter outside boundaries | ||
#' @param boundary_fun optional function for complex boundary conditions | ||
#' @param ... arguments passed to original function | ||
#' @param param_pos argument position of the parameter | ||
#' @return a modified function that considers boundaries | ||
#' @export | ||
#' @examples | ||
#' sqrt_bd <- enhanceFunctionWithBoundaries(sqrt, 0, 10) | ||
#' sqrt_bd(-1) | ||
#' sqrt_bd(1) | ||
#' sqrt_bd(11) | ||
#' | ||
enhanceFunctionWithBoundaries <- function(fun, l_bound, u_bound, | ||
penalty_value=Inf, | ||
boundary_fun=NULL, | ||
param_pos=1, | ||
...) { | ||
function(...) { | ||
invalid <- FALSE | ||
if(!is.null(boundary_fun)) { | ||
invalid <- !boundary_fun(...elt(param_pos),l_bound, u_bound) | ||
} | ||
else { | ||
invalid <- !all(l_bound <= ...elt(param_pos) & ...elt(param_pos) <= u_bound) | ||
} | ||
if(invalid) { | ||
penalty_value | ||
} | ||
else { | ||
fun(...) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,4 @@ | |
#' package = "simplaceUtil")) | ||
#' DiagrammeR::render_graph(graph) | ||
#' @name simplaceUtil | ||
NULL | ||
"_PACKAGE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.