Test_LesserOrEqualThreshold Test_LesserOrEqualThreshold Icon

Test_LesserOrEqualThreshold

Usage

PrimitiveComponents.Test_LesserOrEqualThreshold()

Behavior

\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( step_{1_{+}y(t)}, lessequalthreshold_{1_{+}u(t)} \right) \\ \mathrm{connect}\left( step_{2_{+}y(t)}, lessequalthreshold_{2_{+}u(t)} \right) \\ \mathtt{lessequalthreshold\_1.y}\left( t \right) = ifelse\left( \mathtt{lessequalthreshold\_1.u}\left( t \right) \leq \mathtt{lessequalthreshold\_1.threshold}, 1, 0 \right) \\ \mathtt{lessequalthreshold\_2.y}\left( t \right) = ifelse\left( \mathtt{lessequalthreshold\_2.u}\left( t \right) \leq \mathtt{lessequalthreshold\_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 `LesserOrEqualThreshold` 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 increases by 1 at time = 5s → transitions from 5 → 6
#
# Each signal is connected to a separate `LesserOrEqualThreshold` block (threshold = 5),
# which outputs 1.0 when the input is less than or equal to the threshold, and 0.0 otherwise.
#
# The LesserOrEqualThreshold component evaluates whether u ≤ threshold at each instant:
#   - For step_1:
#       • Initially (t < 5): u = 3 → y = 1.0 (true)
#       • After t ≥ 5:       u = 7 → y = 0.0 (false)
#   - For step_2:
#       • Initially (t < 5): u = 5 → y = 1.0 (true)
#       • After t ≥ 5:       u = 6 → y = 0.0 (false)
component Test_LesserOrEqualThreshold
  lessequalthreshold_1 = PrimitiveComponents.Compare.LesserOrEqualThreshold(threshold = 5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 230, "x2": 550, "y2": 330, "rot": 0}
      }
    }
  }
  lessequalthreshold_2 = PrimitiveComponents.Compare.LesserOrEqualThreshold(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 = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 130, "y1": 590, "x2": 230, "y2": 690, "rot": 0}
      }
    }
  }
relations
  connect(lessequalthreshold_1.u, step_1.y) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(lessequalthreshold_2.u, step_2.y) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
metadata {
  "Dyad": {
    "experiments": {"Test_LessEqualThreshold_": {"stop": 10}},
    "tests": {
      "case1": {
        "stop": 10,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["lessequalthreshold_1.y", "lessequalthreshold_2.y"]}
      }
    }
  }
}
end
Flattened Source
component Test_LesserOrEqualThreshold
  lessequalthreshold_1 = PrimitiveComponents.Compare.LesserOrEqualThreshold(threshold = 5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 230, "x2": 550, "y2": 330, "rot": 0}
      }
    }
  }
  lessequalthreshold_2 = PrimitiveComponents.Compare.LesserOrEqualThreshold(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 = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 130, "y1": 590, "x2": 230, "y2": 690, "rot": 0}
      }
    }
  }
relations
  connect(lessequalthreshold_1.u, step_1.y) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(lessequalthreshold_2.u, step_2.y) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
metadata {
  "Dyad": {
    "experiments": {"Test_LessEqualThreshold_": {"stop": 10}},
    "tests": {
      "case1": {
        "stop": 10,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["lessequalthreshold_1.y", "lessequalthreshold_2.y"]}
      }
    }
  }
}
end


Test Cases

Test Case case1

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