Skip to content

Commit

Permalink
Fix HTC factor design creation
Browse files Browse the repository at this point in the history
  • Loading branch information
JTPetter committed Apr 15, 2024
1 parent 02d1eac commit 34e8ea5
Show file tree
Hide file tree
Showing 2 changed files with 235 additions and 68 deletions.
85 changes: 84 additions & 1 deletion R/doeFactorial.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ doeFactorial <- function(jaspResults, dataset, options, ...) {
tb[["totalRuns"]] <- runs
tb[["totalBlocks"]] <- designSpec[["replications"]]
}
if (runs > 1e+05) {
if (!is.na(runs) && runs > 1e+05) {
tb$setError(gettext("Cannote create designs with more than 100000 total runs."))
return()
}
Expand Down Expand Up @@ -140,6 +140,89 @@ doeFactorial <- function(jaspResults, dataset, options, ...) {
runs = options[["categoricalNoLevels"]]^nFactors,
resolution = "Full"
)
} else if (options[["factorialType"]] == "factorialTypeSplit") {
nHtcFactors <- options[["factorialDesignTypeSplitPlotNumberHardToChangeFactors"]]
if (nFactors == 2) {
designs <- data.frame(
name = "Full factorial",
runs = 4,
resolution = "Full"
)
} else if (nFactors == 3) {
designs <- data.frame(
name = "Full factorial",
runs = 8,
resolution = "Full"
)
} else if (nFactors == 4) {
if (nHtcFactors == 1) {
designs <- data.frame(
name = c("1/2 fraction", "Full factorial"),
runs = c(8, 16),
resolution = c("IV", "Full")
)
} else {
designs <- data.frame(
name = "Full factorial",
runs = 16,
resolution = "Full"
)
}
} else if (nFactors == 5) {
if (nHtcFactors == 1) {
designs <- data.frame(
name = c("1/4 fraction", "1/2 fraction", "Full factorial"),
runs = c(8, 16, 32),
resolution = c("III", "V", "Full")
)
} else if (nHtcFactors == 2) {
designs <- data.frame(
name = c("1/2 fraction", "Full factorial"),
runs = c(16, 32),
resolution = c("V", "Full")
)
} else {
designs <- data.frame(
name = "Full factorial",
runs = 32,
resolution = "Full"
)
}
} else if (nFactors == 6) {
if (nHtcFactors <= 2) {
designs <- data.frame(
name = c("1/4 fraction", "1/2 fraction", "Full factorial"),
runs = c(16, 32, 64),
resolution = c("IV", "VI", "Full")
)
} else {
designs <- data.frame(
name = c("1/2 fraction", "Full factorial"),
runs = c(32, 64),
resolution = c("VI", "Full")
)
}
} else if (nFactors == 7) {
if (nHtcFactors <= 2) {
designs <- data.frame(
name = c("1/4 fraction", "1/2 fraction", "Full factorial"),
runs = c(32, 64, 128),
resolution = c("IV", "VII", "Full")
)
} else {
designs <- data.frame(
name = c("1/2 fraction", "Full factorial"),
runs = c(64, 128),
resolution = c("VII", "Full")
)
}
} else if (nFactors > 7) {
designs <- data.frame(
name = "Full factorial",
runs = 2^nFactors,
resolution = "Full"
)
}
} else {
if (nFactors == 2) {
designs <- data.frame(
Expand Down
218 changes: 151 additions & 67 deletions inst/qml/doeFactorial.qml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@ Form

IntegerField
{
id: factorialDesignTypeSplitPlotNumberHardToChangeFactors
name: "factorialDesignTypeSplitPlotNumberHardToChangeFactors"
label: qsTr("Number of hard-to-change factors")
visible: factorialTypeSplit.checked
defaultValue: 1
min: 1
max: numberOfCategorical.value-1
max: {numberOfCategorical.value > 3 ? 3 : numberOfCategorical.value - 1}
}
}

Expand Down Expand Up @@ -149,77 +150,160 @@ Form
return["Full factorial", numberOfLevels.intValue**numberOfCategorical.intValue, "Full"]
} else {
const val = numberOfCategorical.intValue
if (val == 2) {
//const htcVal = numberOffactorialDesignTypeSplitPlotNumberHardToChangeFactorsCategorical.intValue
if (factorialType.value == "factorialTypeSplit") {
if (val == 2) {
return [
"Full factorial", 4, "Full"
];
} else if (val == 3) {
return [
"1/2 fraction", 4, "III",
"Full factorial", 8, "Full"
];
} else if (val == 4) {
return [
"1/2 fraction", 8, "IV",
"Full factorial", 16, "Full"
];
} else if (val == 5) {
return [
"1/4 fraction", 8, "III",
"1/2 fraction", 16, "V",
"Full factorial", 32, "Full",
];
} else if (val == 6) {
return [
"1/8 fraction", 8, "III",
"1/4 fraction", 16, "IV",
"1/2 fraction", 32, "VI",
"Full factorial", 64, "Full",
];
} else if (val == 7) {
return [
"1/16 fraction", 8, "III",
"1/8 fraction", 16, "IV",
"1/4 fraction", 32, "IV",
"1/2 fraction", 64, "VII",
"Full factorial", 128, "Full",
];
} else if (val == 8) {
return [
"1/16 fraction", 16, "IV",
"1/8 fraction", 32, "IV",
"1/4 fraction", 64, "V",
"1/2 fraction", 128, "VIII"
];
} else if (val == 9) {
return [
"1/32 fraction", 16, "III",
"1/16 fraction", 32, "IV",
"1/8 fraction", 64, "IV",
"1/4 fraction", 128, "VI"
];
} else if (val == 10) {
return [
"1/64 fraction", 16, "III",
"1/32 fraction", 32, "IV",
"1/16 fraction", 64, "IV",
"1/8 fraction", 128, "V",
];
} else if (val == 11) {
return [
"1/128 fraction", 16, "III",
"1/64 fraction", 32, "IV",
"1/32 fraction", 64, "IV",
"1/16 fraction", 128, "V",
];
} else if (val >= 12) {
} else if (val == 3) {
return [
"Full factorial", 8, "Full"
];
} else if (val == 4) {
if (factorialDesignTypeSplitPlotNumberHardToChangeFactors.value == 1) {
return [
"1/2 fraction", 8, "IV",
"Full factorial", 16, "Full"
];
} else {
return [
"Full factorial", 16, "Full"
];
}
} else if (val == 5) {
if (factorialDesignTypeSplitPlotNumberHardToChangeFactors.value == 1) {
return [
"1/4 fraction", 8, "III",
"1/2 fraction", 16, "V",
"Full factorial", 32, "Full"
];
} else if (factorialDesignTypeSplitPlotNumberHardToChangeFactors.value == 2) {
return [
"1/2 fraction", 16, "V",
"Full factorial", 32, "Full"
];
} else {
return [
"Full factorial", 32, "Full"
];
}
} else if (val == 6) {
if (factorialDesignTypeSplitPlotNumberHardToChangeFactors.value == 1) {
return [
"1/4 fraction", 16, "IV",
"1/2 fraction", 32, "VI",
"Full factorial", 64, "Full"
];
} else if (factorialDesignTypeSplitPlotNumberHardToChangeFactors.value == 2) {
return [
"1/4 fraction", 16, "IV",
"1/2 fraction", 32, "VI",
"Full factorial", 64, "Full"
];
} else {
return [
"1/2 fraction", 32, "VI",
"Full factorial", 64, "Full"
];
}
} else if (val == 7) {
if (factorialDesignTypeSplitPlotNumberHardToChangeFactors.value == 1) {
return [
"1/4 fraction", 32, "IV",
"1/2 fraction", 64, "VII",
"Full factorial", 128, "Full"
];
} else if (factorialDesignTypeSplitPlotNumberHardToChangeFactors.value == 2) {
return [
"1/4 fraction", 32, "IV",
"1/2 fraction", 64, "VII",
"Full factorial", 128, "Full"
];
} else {
return [
"1/2 fraction", 64, "VII",
"Full factorial", 128, "Full"
];
}
} else {
return [
"Full factorial", 2**numberOfCategorical.intValue, "Full"
];
}
} else {
if (val == 2) {
return [
"1/256 fraction", 16, "III",
"1/128 fraction", 32, "IV",
"1/64 fraction", 64, "IV",
"1/32 fraction", 128, "IV",
"Full factorial", 4, "Full"
];
}
} else if (val == 3) {
return [
"1/2 fraction", 4, "III",
"Full factorial", 8, "Full"
];
} else if (val == 4) {
return [
"1/2 fraction", 8, "IV",
"Full factorial", 16, "Full"
];
} else if (val == 5) {
return [
"1/4 fraction", 8, "III",
"1/2 fraction", 16, "V",
"Full factorial", 32, "Full",
];
} else if (val == 6) {
return [
"1/8 fraction", 8, "III",
"1/4 fraction", 16, "IV",
"1/2 fraction", 32, "VI",
"Full factorial", 64, "Full",
];
} else if (val == 7) {
return [
"1/16 fraction", 8, "III",
"1/8 fraction", 16, "IV",
"1/4 fraction", 32, "IV",
"1/2 fraction", 64, "VII",
"Full factorial", 128, "Full",
];
} else if (val == 8) {
return [
"1/16 fraction", 16, "IV",
"1/8 fraction", 32, "IV",
"1/4 fraction", 64, "V",
"1/2 fraction", 128, "VIII"
];
} else if (val == 9) {
return [
"1/32 fraction", 16, "III",
"1/16 fraction", 32, "IV",
"1/8 fraction", 64, "IV",
"1/4 fraction", 128, "VI"
];
} else if (val == 10) {
return [
"1/64 fraction", 16, "III",
"1/32 fraction", 32, "IV",
"1/16 fraction", 64, "IV",
"1/8 fraction", 128, "V",
];
} else if (val == 11) {
return [
"1/128 fraction", 16, "III",
"1/64 fraction", 32, "IV",
"1/32 fraction", 64, "IV",
"1/16 fraction", 128, "V",
];
} else if (val >= 12) {
return [
"1/256 fraction", 16, "III",
"1/128 fraction", 32, "IV",
"1/64 fraction", 64, "IV",
"1/32 fraction", 128, "IV",
];
}
}
}
}

Expand Down

0 comments on commit 34e8ea5

Please sign in to comment.