99infillOptFocus = function (infill.crit , models , control , par.set , opt.path , design , iter , ... ) {
1010 global.y = Inf
1111
12- discreteVectorPars = filterParams(par.set , type = c(" discretevector" , " logicalvector" ))
12+ discrete.vector.pars = filterParams(par.set , type = c(" discretevector" , " logicalvector" ))
1313
14- allRequirements = extractSubList(par.set $ pars , " requires" , simplify = FALSE )
15- allRequirementVars = unique(unlist(lapply(allRequirements , all.vars )))
16- forbiddenRequirementVars = getParamIds(discreteVectorPars )
17- if (any(allRequirementVars %in% forbiddenRequirementVars )) {
14+ all.requirements = extractSubList(par.set $ pars , " requires" , simplify = FALSE )
15+ all.requirement.vars = unique(unlist(lapply(all.requirements , all.vars )))
16+ if (any(all.requirement.vars %in% getParamIds(discrete.vector.pars ))) {
1817 stop(" Cannot do focus search when some variables have requirements that depend on discrete or logical vector parameters." )
1918 }
2019
@@ -27,20 +26,20 @@ infillOptFocus = function(infill.crit, models, control, par.set, opt.path, desig
2726 # Handle discrete vectors (and logical vectors):
2827 # The problem is that for discrete vectors, we can't adjust the range dimension-wise.
2928 # Instead we store the range of each discrete vectorparameter dimension in the list of named characters
30- # `discreteVectorMapping `. In each iteration a random value (that does not contain
29+ # `discrete.vector.mapping `. In each iteration a random value (that does not contain
3130 # the optimum) is dropped from each vector on this list. The $values of the parameters in the parameterset also
3231 # need to be modified to reflect the reduced range: from them, always the last value is dropped.
33- # Then `discreteVectorMapping ` is a mapping that maps, for each discrete vector param dimension
32+ # Then `discrete.vector.mapping ` is a mapping that maps, for each discrete vector param dimension
3433 # with originally n values, from the sampled value (levels 1 to n - #(dropped levels)) to the acutal levels with
3534 # random dropouts.
3635 #
3736 # Since the requirements of the param set are queried while generating the design, this breaks if
3837 # there are requirements depending on discrete vector parameters.
39- discreteVectorMapping = lapply(discreteVectorPars $ pars ,
38+ discrete.vector.mapping = lapply(discrete.vector.pars $ pars ,
4039 function (param ) rep(list (setNames(names(param $ values ), names(param $ values ))), param $ len ))
41- discreteVectorMapping = unlist(discreteVectorMapping , recursive = FALSE )
42- if (! isEmpty(discreteVectorPars )) {
43- names(discreteVectorMapping ) = getParamIds(discreteVectorPars , with.nr = TRUE , repeated = TRUE )
40+ discrete.vector.mapping = unlist(discrete.vector.mapping , recursive = FALSE )
41+ if (! isEmpty(discrete.vector.pars )) {
42+ names(discrete.vector.mapping ) = getParamIds(discrete.vector.pars , with.nr = TRUE , repeated = TRUE )
4443 }
4544
4645
@@ -53,8 +52,8 @@ infillOptFocus = function(infill.crit, models, control, par.set, opt.path, desig
5352 newdesign = convertDataFrameCols(newdesign , ints.as.num = TRUE , logicals.as.factor = TRUE )
5453
5554 # handle discrete vectors
56- for (dfindex in names(discreteVectorMapping )) {
57- mapping = discreteVectorMapping [[dfindex ]]
55+ for (dfindex in names(discrete.vector.mapping )) {
56+ mapping = discrete.vector.mapping [[dfindex ]]
5857 levels(newdesign [[dfindex ]]) = mapping [levels(newdesign [[dfindex ]])]
5958 }
6059
@@ -102,20 +101,20 @@ infillOptFocus = function(infill.crit, models, control, par.set, opt.path, desig
102101 par $ values [[to.del ]] = NULL
103102 } else {
104103 # we remove the last element of par$values and a random element for
105- # each dimension in discreteVectorMapping .
104+ # each dimension in discrete.vector.mapping .
106105 par $ values = par $ values [- length(par $ values )]
107106 if (par $ type != " logicalvector" ) {
108107 # for discretevectorparam val would be a list; convert to character vector
109108 val = names(val )
110109 }
111110 for (dimnum in seq_len(par $ len )) {
112111 dfindex = paste0(par $ id , dimnum )
113- newmap = val.names = discreteVectorMapping [[dfindex ]]
112+ newmap = val.names = discrete.vector.mapping [[dfindex ]]
114113 val.names = val.names [val.names != val [dimnum ]]
115114 to.del = sample(val.names , 1 )
116115 newmap = newmap [newmap != to.del ]
117116 names(newmap ) = names(par $ values )
118- discreteVectorMapping [[dfindex ]] <<- newmap
117+ discrete.vector.mapping [[dfindex ]] <<- newmap
119118 }
120119 }
121120 }
0 commit comments