Test_LesserOrEqual Test_LesserOrEqual Icon

Test_LesserOrEqual

Usage

PrimitiveComponents.Test_LesserOrEqual()

Behavior

\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( u1_{+}y(t), lessequal_{logical_{+}u1(t)} \right) \\ \mathrm{connect}\left( u2_{+}y(t), lessequal_{logical_{+}u2(t)} \right) \\ \mathtt{u1.y}\left( t \right) = ifelse\left( t \geq \mathtt{u1.start\_time}, \mathtt{u1.height} + \mathtt{u1.offset}, \mathtt{u1.offset} \right) \\ \mathtt{u2.y}\left( t \right) = ifelse\left( t \geq \mathtt{u2.start\_time}, \mathtt{u2.height} + \mathtt{u2.offset}, \mathtt{u2.offset} \right) \\ \mathtt{lessequal\_logical.y}\left( t \right) = ifelse\left( \mathtt{lessequal\_logical.u1}\left( t \right) \leq \mathtt{lessequal\_logical.u2}\left( t \right), 1, 0 \right) \\ \end{array} \right] \end{equation} \]

Source

# This test demonstrates the behavior of the `LesserOrEqual` component 
#
# Two `Step` blocks provide real-valued signals:
#   - u1 starts at 3 and steps up by 4 at time = 3s → transitions from 3 → 7
#   - u2 starts at 5 and steps up by 5 at time = 5s → transitions from 5 → 10
#
# The `LesserOrEqual` component evaluates whether u1 ≤ u2 at each instant:
#   - Initially (t < 3): u1 = 3, u2 = 5 → y = 1.0  (true)
#   - Between 3 ≤ t < 5: u1 = 7, u2 = 5 → y = 0.0  (false)
#   - After t ≥ 5:       u1 = 7, u2 = 10 → y = 1.0  (true)
component Test_LesserOrEqual
  u1 = BlockComponents.Step(start_time = 3, offset = 3, height = 4) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 200, "y1": 330, "x2": 300, "y2": 430, "rot": 0}
      }
    }
  }
  u2 = BlockComponents.Step(offset = 5, start_time = 5, height = 5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 210, "y1": 640, "x2": 310, "y2": 740, "rot": 0}
      }
    }
  }
  lessequal_logical = PrimitiveComponents.Compare.LesserOrEqual() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 460, "y1": 450, "x2": 560, "y2": 550, "rot": 0}
      }
    }
  }
relations
  connect(lessequal_logical.u1, u1.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 379, "y": 469}, {"x": 379, "y": 380}], "E": 2}]}
  }
  connect(lessequal_logical.u2, u2.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 384, "y": 523}, {"x": 384, "y": 690}], "E": 2}]}
  }
metadata {
  "Dyad": {
    "experiments": {"Test_LessEqual_Logical_": {"stop": 10}},
    "tests": {
      "case1": {
        "stop": 10,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["lessequal_logical.y"]}
      }
    }
  }
}
end
Flattened Source
component Test_LesserOrEqual
  u1 = BlockComponents.Step(start_time = 3, offset = 3, height = 4) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 200, "y1": 330, "x2": 300, "y2": 430, "rot": 0}
      }
    }
  }
  u2 = BlockComponents.Step(offset = 5, start_time = 5, height = 5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 210, "y1": 640, "x2": 310, "y2": 740, "rot": 0}
      }
    }
  }
  lessequal_logical = PrimitiveComponents.Compare.LesserOrEqual() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 460, "y1": 450, "x2": 560, "y2": 550, "rot": 0}
      }
    }
  }
relations
  connect(lessequal_logical.u1, u1.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 379, "y": 469}, {"x": 379, "y": 380}], "E": 2}]}
  }
  connect(lessequal_logical.u2, u2.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 384, "y": 523}, {"x": 384, "y": 690}], "E": 2}]}
  }
metadata {
  "Dyad": {
    "experiments": {"Test_LessEqual_Logical_": {"stop": 10}},
    "tests": {
      "case1": {
        "stop": 10,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["lessequal_logical.y"]}
      }
    }
  }
}
end


Test Cases

Test Case case1

plt
Example block output
  • Examples
  • Experiments
  • Analyses