locked
Switch depending on state of subarray of boolean variable array? RRS feed

  • Question

  • Hi, 

    I woud like to write a model where I switch depending on the state of a few variables within a boolean variable array. That is,  I have a model where some nodes have several parents in the layer above; these nodes take different states depending on whether any of their parents is true (i.e. at least one parent true). 

    So ideally I would like to use a something like Variable.AnyTrue for boolean variable arrays (together with subarray - the indices of the parents are modelled as observables of a jagged variable array)? Any ideas on how to implement this efficiently? I have tried to implement the model using  .NET arrays of variables rather than variable arrays, but I then run very soon into the System.OutOfMemory exception. How difficult would it be to implement something like a Variable.AnyTrue method (Variable(Boolean[])) corresponding to the Variable.AllTrue one?

    Thanks, 

    flo

    Tuesday, July 10, 2012 10:59 AM

Answers

All replies

  • You could 'Not' the boolean variable array, then do AllTrue, then 'Not' the result.

    John


    Tuesday, July 10, 2012 3:18 PM
    Owner
  • Thank you so much, John, really appreciated! [although I do feel a little bit embarrassed not having seen the obvious...]
    • Edited by fl0m0 Tuesday, July 10, 2012 5:07 PM
    Tuesday, July 10, 2012 5:07 PM