Skip to content

Commit

Permalink
Optimization "RI" matrix weightings now correctly show 0 ("zero") for…
Browse files Browse the repository at this point in the history
… any objective trait which is left "NA". This seems to avoid a matrix multiplication failure in a couple of the selection algorithms.
  • Loading branch information
RichardBruskiewich committed Sep 2, 2014
1 parent b175376 commit 778796a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: explora
Version: 0.3-0
Version: 0.3-1
Date: 2014-08-15
Title: Bioversity Seed4Needs Explora Germplasm Selection Tool
Authors@R: c( person(given="Maarten", family = "van Zonneveld", role = c("aut",
Expand Down
29 changes: 25 additions & 4 deletions R/algorithms.r
Original file line number Diff line number Diff line change
Expand Up @@ -180,19 +180,23 @@ DialogSelectOptimization <- function( win, notebook ){

lytg4var[3,1] <- varop1c <- gdroplist(c("NA", names.continuous), container = lytg4var)
lytg4var[3,2] <- fvarop1c <- gdroplist(f.items.cont, container = lytg4var)
lytg4var[3,3] <- ri1c <- gspinbutton(from = 1, to = 10, by = 1, value = 0, container = lytg4var)
lytg4var[3,3] <- ri1c <- gspinbutton(from = 1, to = 10, by = 1, value = 0, container = lytg4var)

lytg4var[4,1] <- varop2c <- gdroplist(c("NA", names.continuous), container = lytg4var)
lytg4var[4,2] <- fvarop2c <- gdroplist(f.items.cont, container = lytg4var)
lytg4var[4,3] <- ri2c <- gspinbutton(from = 1, to = 10, by = 1, value = 0, container = lytg4var)

lytg4var[5,1] <- varop3c <- gdroplist(c("NA", names.continuous), container = lytg4var)
lytg4var[5,2] <- fvarop3c <- gdroplist(f.items.cont, container = lytg4var)
lytg4var[5,3] <- ri3c <- gspinbutton(from = 1, to = 10, by = 1, value = 0, container = lytg4var)

lytg4var[6,1] <- varop4c <- gdroplist(c("NA", names.continuous), container = lytg4var)
lytg4var[6,2] <- fvarop4c <- gdroplist(f.items.cont, container = lytg4var)
lytg4var[6,3] <- ri4c <- gspinbutton(from = 1, to = 10, by = 1, value = 0, container = lytg4var)

lytg4var[7,1] <- varop5c <- gdroplist(c("NA", names.continuous), container = lytg4var)
lytg4var[7,2] <- fvarop5c <- gdroplist(f.items.cont, container = lytg4var)
lytg4var[7,3] <- ri5c <- gspinbutton(from = 1, to = 10, by = 1, value = 0, container = lytg4var)
lytg4var[7,3] <- ri5c <- gspinbutton(from = 1, to = 10, by = 1, value = 0, container = lytg4var)

lytg4var[8,1] <- glabel("Optimization Strategy for Nominal Variables: ", container = lytg4var)
lytg4var[9,1] <- glabel("Variable: ", container = lytg4var)
Expand Down Expand Up @@ -234,8 +238,24 @@ DialogSelectOptimization <- function( win, notebook ){

saveOptimizationTargets <- function() {

RI <- matrix(c(svalue(ri1c), svalue(ri2c), svalue(ri3c), svalue(ri4c), svalue(ri5c),
svalue(ri1n), svalue(ri2n), svalue(ri3n), svalue(ri4n), svalue(ri5n)), ncol = 2)
# RMB: BUG FIX, Sept 2, 2014: If varop?c is "NA",
# then the ri?c weightings should be zero...
if( svalue(varop1c) != "NA") { ri1c <- svalue(ri1c) } else { ri1c <- 0 }
if( svalue(varop2c) != "NA") { ri2c <- svalue(ri2c) } else { ri2c <- 0 }
if( svalue(varop3c) != "NA") { ri3c <- svalue(ri3c) } else { ri3c <- 0 }
if( svalue(varop4c) != "NA") { ri4c <- svalue(ri4c) } else { ri4c <- 0 }
if( svalue(varop5c) != "NA") { ri5c <- svalue(ri5c) } else { ri5c <- 0 }
if( svalue(varop1n) != "NA") { ri1n <- svalue(ri1n) } else { ri1n <- 0 }
if( svalue(varop2n) != "NA") { ri2n <- svalue(ri2n) } else { ri2n <- 0 }
if( svalue(varop3n) != "NA") { ri3n <- svalue(ri3n) } else { ri3n <- 0 }
if( svalue(varop4n) != "NA") { ri4n <- svalue(ri4n) } else { ri4n <- 0 }
if( svalue(varop5n) != "NA") { ri5n <- svalue(ri5n) } else { ri5n <- 0 }

RI <- matrix(
c( ri1c, ri2c, ri3c, ri4c, ri5c,
ri1n, ri2n, ri3n, ri4n, ri5n ),
ncol = 2
)

colnames(RI)<-c("ric", "rin")

Expand Down Expand Up @@ -779,6 +799,7 @@ WSM.type.opt <- function(){

##Exclude zero-valued weights
weights <- weights[weights != 0]

cat("\n")
cat("Weights:")
cat("\n")
Expand Down

0 comments on commit 778796a

Please sign in to comment.