locked
Is it possible to constrain a Variable<double> with a Variable<int>? RRS feed

  • Question

  • When using Variable<int> to specify ranges for VariableArrays, such as for observed data, it can also be useful to use them to constrain other double variables from a particular model. Is it possible to do this?

    I've tried several different ways, but haven't found a solution yet.

    • The Variable.ConstrainX functions require input variables to be of the same type (and when using Variable.ConstrainTrue, the overloaded comparison operators also requires variables of the same type.)
    • Variable.Copy doesn't support changing the type of a variable.

    A workaround seems to be to create two sets of variables (arrays), both int and double, and set them both to equal values when observing them, and use them each where needed. However, this seems kind of hacky.

    Thanks,

    Andrew

    Tuesday, January 13, 2015 7:50 PM

Answers

  • Use Variable.Double.
    • Marked as answer by Andrew Mao Wednesday, January 14, 2015 4:02 PM
    Wednesday, January 14, 2015 9:41 AM
    Owner