Skip to content

Bug - patch sees stale attribute values even when organism properly updates #323

@GondekNP

Description

@GondekNP

I noticed that attributes within state handlers don't appear to properly propagate up the the patch in the way that unconditional organism step logic does. For eg in the following, we see that age and maturity are properly handled at the organism level, but something about the way this is being aggregated to the patch fails to capture maturity.

start patch Default

  Trees.init = create 1 of Tree

  # Patch reads Trees.maturity - should see current computed value
  # At y3: age=3, maturity should be 3/10 = 0.3
  # BUG: This assertion FAILS because patch sees stale value (0)
  # assert.patchSeesMaturity.step
  #  :if(meta.year == 3 count) = mean(Trees.maturity) > 0.2 count

  # Exports for debugging - compare patch perspective vs expected values
  export.year.step = meta.year
  export.patchSeesMaturity.step = mean(Trees.maturity)
  export.patchSeesAge.step = mean(Trees.age)
  export.patchSeesIsAdult.step = mean(Trees.isAdult)

end patch

start organism Tree

  age.init = 0 count
  age.step = prior.age + 1 count

  maturity.init = 0 count

  state.init = "juvenile"
  state.step:if(current.maturity > 0.5 count) = "adult"

  # Organism-level assertion - checks own maturity
  # This PASSES because organism correctly computes maturity internally
  assert.selfMaturity.step
    :if(current.age == 3 count) = current.maturity > 0.2 count

  isAdult.init = 0 count
  isAdult.step
    :if(current.state == "adult") = 1 count
    :else = 0 count

  start state "juvenile"
    maturity.step = current.age / 10 count
  end state

  start state "adult"
    maturity.step = 1 count
  end state

end organism

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions