Variable.Array, Variable.Constant, Variable.Observed (Migrated from community.research.microsoft.com) RRS feed

  • Question

  • laura posted on 03-17-2009 5:23 AM


    Do Variable.Array, Variable.Constant, and Variable.Observed differ in more than just different default settings of the isReadOnly and ObservedValue property?

    I would like to use the convenient constructor for jagged arrays of Variable.Constant to yield an observed Variable.

    The following code works:

        let varArray= (Variable.Constant<Discrete>((myNestedArray:_[][]), outerRange , innerRange))
        do varArray.AddAttribute(valueRange)
        do varArray.IsReadOnly <- false

    later I can change the value by

        do varArray.ObservedValue<- otherNestedArray


    Is there a difference between this varArray and an array that is created via the Variable.Observed constructor?


    I guess I can create an analogous variable via Variable.Array

    let varArray = (Variable.Array<_>(Variable.Array<Discrete>(innerRange), outerRange))

    and call

        do varArray.ObservedValue<- otherNestedArray




    Friday, June 3, 2011 4:47 PM


  • John Guiver replied on 03-18-2009 8:42 AM

    These should all be equivalent.

    Note that setting the IsReadOnly flag forces a recompilation the next time you do inference

    Setting the ObservedValue will trigger a recompilation if and only if the value was not previously observed, otherwise it will just trigger a call to Reset().

    John G

    Friday, June 3, 2011 4:48 PM