Test_GreaterEqualThreshold Test_GreaterEqualThreshold Icon

Test_GreaterEqualThreshold

Usage

PrimitiveComponents.Test_GreaterEqualThreshold()

Behavior

\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( step_{1_{+}y(t)}, greaterequalthreshold_{1_{+}u(t)} \right) \\ \mathrm{connect}\left( step_{2_{+}y(t)}, greaterequalthreshold_{2_{+}u(t)} \right) \\ \mathtt{greaterequalthreshold\_1.y}\left( t \right) = ifelse\left( \mathtt{greaterequalthreshold\_1.u}\left( t \right) \geq \mathtt{greaterequalthreshold\_1.threshold}, 1, 0 \right) \\ \mathtt{greaterequalthreshold\_2.y}\left( t \right) = ifelse\left( \mathtt{greaterequalthreshold\_2.u}\left( t \right) \geq \mathtt{greaterequalthreshold\_2.threshold}, 1, 0 \right) \\ \mathtt{step\_1.y}\left( t \right) = ifelse\left( t \geq \mathtt{step\_1.start\_time}, \mathtt{step\_1.height} + \mathtt{step\_1.offset}, \mathtt{step\_1.offset} \right) \\ \mathtt{step\_2.y}\left( t \right) = ifelse\left( t \geq \mathtt{step\_2.start\_time}, \mathtt{step\_2.height} + \mathtt{step\_2.offset}, \mathtt{step\_2.offset} \right) \\ \end{array} \right] \end{equation} \]

Source

# This test the `GreaterEqualThreshold` component when comparing time-varying input signals against a fixed threshold value.
#
# Two `Step` blocks generate real-valued input signals:
#   - step_1 starts at 3 and increases by 4 at time = 5s → transitions from 3 → 7
#   - step_2 starts at 5 and decreases by 2 at time = 5s → transitions from 5 → 3
#
# Each signal is connected to a separate `GreaterEqualThreshold` block (threshold = 5),
# which outputs 1.0 when the input is greater than or equal to the threshold, and 0.0 otherwise.
#
# The GreaterEqualThreshold component evaluates whether u ≥ threshold at each instant:
#   - For step_1:
#       • Initially (t < 5): u = 3 → y = 0.0 (false)
#       • After t ≥ 5:       u = 7 → y = 1.0 (true)
#   - For step_2:
#       • Initially (t < 5): u = 5 → y = 1.0 (true)
#       • After t ≥ 5:       u = 3 → y = 0.0 (false)
component Test_GreaterEqualThreshold
  greaterequalthreshold_1 = PrimitiveComponents.Compare.GreaterOrEqualThreshold(threshold = 5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 230, "x2": 550, "y2": 330, "rot": 0}
      }
    }
  }
  greaterequalthreshold_2 = PrimitiveComponents.Compare.GreaterOrEqualThreshold(threshold = 5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 460, "y1": 590, "x2": 560, "y2": 690, "rot": 0}
      }
    }
  }
  step_1 = BlockComponents.Step(offset = 3, start_time = 5, height = 4) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 130, "y1": 230, "x2": 230, "y2": 330, "rot": 0}
      }
    }
  }
  step_2 = BlockComponents.Step(offset = 5, start_time = 5, height = -2) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 130, "y1": 590, "x2": 230, "y2": 690, "rot": 0}
      }
    }
  }
relations
  connect(greaterequalthreshold_1.u, step_1.y) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(greaterequalthreshold_2.u, step_2.y) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
metadata {
  "Dyad": {
    "experiments": {"Test_GreaterEqualThreshold_": {"stop": 10}},
    "tests": {
      "case1": {
        "stop": 10,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["greaterequalthreshold_1.y", "greaterequalthreshold_2.y"]}
      }
    }
  }
}
end
Flattened Source
component Test_GreaterEqualThreshold
  greaterequalthreshold_1 = PrimitiveComponents.Compare.GreaterOrEqualThreshold(threshold = 5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 230, "x2": 550, "y2": 330, "rot": 0}
      }
    }
  }
  greaterequalthreshold_2 = PrimitiveComponents.Compare.GreaterOrEqualThreshold(threshold = 5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 460, "y1": 590, "x2": 560, "y2": 690, "rot": 0}
      }
    }
  }
  step_1 = BlockComponents.Step(offset = 3, start_time = 5, height = 4) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 130, "y1": 230, "x2": 230, "y2": 330, "rot": 0}
      }
    }
  }
  step_2 = BlockComponents.Step(offset = 5, start_time = 5, height = -2) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 130, "y1": 590, "x2": 230, "y2": 690, "rot": 0}
      }
    }
  }
relations
  connect(greaterequalthreshold_1.u, step_1.y) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(greaterequalthreshold_2.u, step_2.y) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
metadata {
  "Dyad": {
    "experiments": {"Test_GreaterEqualThreshold_": {"stop": 10}},
    "tests": {
      "case1": {
        "stop": 10,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["greaterequalthreshold_1.y", "greaterequalthreshold_2.y"]}
      }
    }
  }
}
end


Test Cases

Test Case case1

plt
Example block output
plt
Example block output
  • Examples
  • Experiments
  • Analyses