Generate Design does not work for integer params with trafo
Short example:
param = makeIntegerParam("tst", lower = 0, upper = 10, trafo = function(x) 2*x) ps = makeParamSet(param) generateDesign(10, ps, trafo = TRUE)
-> Error in generateDesign(10, ps, trafo = TRUE) : INTEGER() can only be applied to a 'integer', not a 'double'
Actually the code works, the problem is that your trafo does violate the condition that an integer is mapped to an integer....
Because 2*x is a numeric, so you should write 2L * x. That works as intended.
Now, I do agree
a) that this is something that users either do not know, or, like in our case, we sometimes forget.
b) the error message does not help you a lot.
The problem is I do not see a way to check this in a "cheap way" in the package? Just document it for now?
I could do - when the param set is defined - a simple check that a randomly drawn param value is transformed to the correct type? This might help for other things as well?
Yes, that would be good.
But sometimes we want to use an integer param and use a trafo, that maps the parameter to a double? For example: Integerparameter with parameterspace -15:15 and Trafo 2^x. That was the original trafo i used. Or do we want to use a discrete parameter for such cases?
But sometimes we want to use an integer param and use a trafo, that maps the parameter to a double? For example: Integerparameter with parameterspace -15:15 and Trafo 2^x. That was the original trafo i used.
Hmm. Ok. True. Damn. I am unsure how to handle that though. We would also need to switch of rounding in that case. I need to check this further.
Or do we want to use a discrete parameter for such cases?
This is easy to answer. No.
Or do we want to use a discrete parameter for such cases?
Well we COULD do this, but only if we would support, discrete ORDERED params. Then you would also not need the trafo. But we currently don't.
Perhaps we want to make this a new parameter type?
Can you pls do this?
We should model this internally as an integer 1...n. Then all operations in ParamHelpers must be checked that they work accordingly.
Then we need a issue in mbo that models / optimization works as well.
The trafo issue for integers still remains.
Can you please add "ordered" as soon as possible as we need to upload a new version?
I will then add the test for the problem you mentioned.