Skip to content

Commit

Permalink
Merge pull request #442 from NREL/morris_params
Browse files Browse the repository at this point in the history
add param to do out of bounds check for morris
  • Loading branch information
brianlball authored Dec 3, 2018
2 parents 929df7c + fda8a4c commit ab15f93
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
26 changes: 14 additions & 12 deletions docker/R/lib/morris.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ print(paste("levels:",levels))
print(paste("r:",r))
print(paste("r2:",r2))
print(paste("grid_jump:",grid_jump))
print(paste("type:",type))
print(paste("type:",type))
print(paste("check_boundary:",check_boundary))

if (r2 > r) {
r <- c(r,r2)
Expand All @@ -152,17 +153,18 @@ m1 <- as.list(data.frame(t(m$X)))
if (debug_messages == 1) {
print(paste("m1:",m1))
}
print("check bounds")
boundary_check <- logical(ncol(vars))
for (i in 1:ncol(vars)){
boundary_check[i] <- all((m$X[,i] <= maxes[i]) && (m$X[,i] >= mins[i]))
}
if(!all(boundary_check)){
print('SOLUTION SPACE OUT OF BOUNDS, CHECK Grid Jump and Level Values and/or re-run')
stop(options("show.error.messages"=TRUE),"SOLUTION SPACE OUT OF BOUNDS, CHECK Grid Jump and Level Values and/or re-run")
}
print("bounds are satisfied, continuing...")

if (check_boundary == 1) {
print("check bounds")
boundary_check <- logical(ncol(vars))
for (i in 1:ncol(vars)){
boundary_check[i] <- all((m$X[,i] <= maxes[i]) && (m$X[,i] >= mins[i]))
}
if(!all(boundary_check)){
print('SOLUTION SPACE OUT OF BOUNDS, CHECK Grid Jump and Level Values and/or re-run')
stop(options("show.error.messages"=TRUE),"SOLUTION SPACE OUT OF BOUNDS, CHECK Grid Jump and Level Values and/or re-run")
}
print("bounds are satisfied, continuing...")
}
try(results <- clusterApplyLB(cl, m1, f),silent=FALSE)
if (debug_messages == 1) {
print(paste("nrow(results):",nrow(results)))
Expand Down
2 changes: 2 additions & 0 deletions server/app/lib/analysis_library/morris.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def initialize(analysis_id, analysis_job_id, options = {})
r2: 20,
levels: 4,
grid_jump: 2,
check_boundary: 0,
type: 'oat',
norm_type: 'minkowski',
p_power: 2,
Expand Down Expand Up @@ -199,6 +200,7 @@ def perform
r2: @analysis.problem['algorithm']['r2'],
type: @analysis.problem['algorithm']['type'],
grid_jump: @analysis.problem['algorithm']['grid_jump'],
check_boundary: @analysis.problem['algorithm']['check_boundary'],
normtype: @analysis.problem['algorithm']['norm_type'],
ppower: @analysis.problem['algorithm']['p_power'],
objfun: @analysis.problem['algorithm']['objective_functions'],
Expand Down

0 comments on commit ab15f93

Please sign in to comment.