ParamHelpers icon indicating copy to clipboard operation
ParamHelpers copied to clipboard

Generate Design does not work for integer params with trafo

Open danielhorn opened this issue 12 years ago • 8 comments

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'

danielhorn avatar Jan 21 '14 15:01 danielhorn

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?

berndbischl avatar Jan 21 '14 17:01 berndbischl

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?

berndbischl avatar Jan 21 '14 17:01 berndbischl

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?

danielhorn avatar Jan 21 '14 18:01 danielhorn

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.

berndbischl avatar Jan 21 '14 18:01 berndbischl

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.

berndbischl avatar Jan 21 '14 18:01 berndbischl

Perhaps we want to make this a new parameter type?

danielhorn avatar Jan 21 '14 18:01 danielhorn

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.

berndbischl avatar Jan 22 '14 11:01 berndbischl

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.

berndbischl avatar Feb 27 '14 19:02 berndbischl