cellml / cellml-specification

CellML Specification
0 stars 8 forks source link

Resets: What happens with conflicts in the reset variable? #313

Open kerimoyle opened 4 years ago

kerimoyle commented 4 years ago

I'm still struggling to get my head around resets after reading the rule examples doc. What happens in this situation if the variables (A, B, C) = (1, 1, 1)? All are in the same component, and none have equivalences.

  reset #1:
    test_variable: A 
    test_value: 1
    order: 1                 
    reset_variable: B 
    reset_value: 2

  reset #2:
    test_variable: C 
    test_value: 1
    order: 1                  
    reset_variable: B 
    reset_value: 200

The spec says: image

This implies that the above would not be valid - as long as a variable is inside its own "equivalent variable set" (which should be obvious, but isn't quite, especially as we have no equivalences defined ... )

But the reset rules doc says: image

... which tells me that the test variable is the one which should have no order clashes, when I reckon it should be the reset variable?

kerimoyle commented 4 years ago

If I assume that the reset rule doc is wrong and the order is based on the variable not the test_variable, then under what conditions will reset #2 ever be activated?

MichaelClerx commented 4 years ago

You're right the rule should be on the (equivalent set of the) reset variable, not on the test variable

MichaelClerx commented 4 years ago

So that means the example is invalid, as both resets are on B, so they need to have a different order

MichaelClerx commented 4 years ago

as long as a variable is inside its own "equivalent variable set" (which should be obvious, but isn't quite, especially as we have no equivalences defined ... )

Hadn't thought of this one! But I think we're ok actually: 3.10.1 says every variable is in the "variable equivalence network"; then 3.10.11 says all subgraphs are equivalent variable sets. I think that says each var is in its own subset, regardles of the points 3.10.2-3.10.10 which concern map_variableses

kerimoyle commented 4 years ago

Thanks @MichaelClerx ... and now to continue ... If I change the order of reset 2 such that it has order = 2, will it ever be applied?

  reset #1:
    test_variable: A 
    test_value: 1
    order: 1                 
    reset_variable: B 
    reset_value: 2

  reset #2:
    test_variable: C 
    test_value: 1
    order: 2                  
    reset_variable: B 
    reset_value: 200
kerimoyle commented 4 years ago

Hadn't thought of this one! But I think we're ok actually: 3.10.1 says every variable is in the "variable equivalence network"; then 3.10.11 says all subgraphs are equivalent variable sets. I think that says each var is in its own subset, regardles of the points 3.10.2-3.10.10 which concern map_variableses

Yeah, exactly ... I think we're safe, it's just not super clear. I'll mention it in the informative stuff.

MichaelClerx commented 4 years ago

Thanks!

MichaelClerx commented 4 years ago

Thanks @MichaelClerx ... and now to continue ... If I change the order of reset 2 such that it has order = 2, will it ever be applied?

  reset #1:
    test_variable: A 
    test_value: 1
    order: 1                 
    reset_variable: B 
    reset_value: 2

  reset #2:
    test_variable: C 
    test_value: 1
    order: 2                  
    reset_variable: B 
    reset_value: 200

If C == 1 but A != 1

kerimoyle commented 4 years ago

Ahh, of course (facepalm...) But it is possible to write entirely hidden resets? eg:

  reset #1:
    test_variable: A 
    test_value: 1
    order: 1                 
    reset_variable: B 
    reset_value: 2

  reset #2:
    test_variable: A 
    test_value: 1
    order: 2                  
    reset_variable: B 
    reset_value: 200

... or does that get evaluated in the second iteration?

MichaelClerx commented 4 years ago

Yeah that would just never get reached