Test_ComparewIntConstant Test_ComparewIntConstant Icon

Test_ComparewIntConstant

Usage

PrimitiveComponents.Test_ComparewIntConstant()

Behavior

\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( constant_{int\_output_{+}y(t)}, equalthreshold_{intinput\_1_{+}u(t)} \right) \\ \mathrm{connect}\left( constant_{int\_output_{+}y(t)}, equalthreshold_{intinput\_2_{+}u(t)} \right) \\ \mathtt{equalthreshold\_intinput\_1.y}\left( t \right) = ifelse\left( \left| - \mathtt{equalthreshold\_intinput\_1.threshold} + \mathtt{equalthreshold\_intinput\_1.u}\left( t \right)\right| < \mathtt{equalthreshold\_intinput\_1.tolerance}, 1, 0 \right) \\ \mathtt{equalthreshold\_intinput\_2.y}\left( t \right) = ifelse\left( \left| - \mathtt{equalthreshold\_intinput\_2.threshold} + \mathtt{equalthreshold\_intinput\_2.u}\left( t \right)\right| < \mathtt{equalthreshold\_intinput\_2.tolerance}, 1, 0 \right) \\ \mathtt{constant\_int\_output.y}\left( t \right) = \mathtt{constant\_int\_output.k} \\ \end{array} \right] \end{equation} \]

Source

# This test model validates the EqualThreshold_intInput block using two threshold/tolerance settings
# with a single integer input constant.
#
# Test cases include:
#   - Threshold = 9.5, Tolerance = 0.6
#       Input u = 10 → Output y = 1.0  (within tolerance)
#   - Threshold = 11, Tolerance = 0.5
#       Input u = 10 → Output y = 0.0  (outside tolerance)
component Test_ComparewIntConstant
  equalthreshold_intinput_1 = PrimitiveComponents.Compare.ComparewIntConstant(threshold = 9.5, tolerance = 0.6) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 550, "y1": 340, "x2": 650, "y2": 440, "rot": 0}
      }
    }
  }
  equalthreshold_intinput_2 = PrimitiveComponents.Compare.ComparewIntConstant(threshold = 11, tolerance = 0.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 550, "y1": 580, "x2": 650, "y2": 680, "rot": 0}
      }
    }
  }
  constant_int_output = PrimitiveComponents.Sources.ConstantIntegerOutput(k = 10) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 250, "y1": 450, "x2": 350, "y2": 550, "rot": 0}
      }
    }
  }
relations
  connect(equalthreshold_intinput_1.u, constant_int_output.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 456, "y": 390}, {"x": 456, "y": 500}], "E": 2}]}
  }
  connect(constant_int_output.y, equalthreshold_intinput_2.u) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 450, "y": 500}, {"x": 450, "y": 630}], "E": 2}]}
  }
metadata {
  "Dyad": {
    "experiments": {"Test_EqualThreshold_intIinput_": {"stop": 2}},
    "tests": {
      "case1": {
        "stop": 2,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["equalthreshold_intinput_1.y", "equalthreshold_intinput_2.y"]}
      }
    }
  }
}
end
Flattened Source
component Test_ComparewIntConstant
  equalthreshold_intinput_1 = PrimitiveComponents.Compare.ComparewIntConstant(threshold = 9.5, tolerance = 0.6) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 550, "y1": 340, "x2": 650, "y2": 440, "rot": 0}
      }
    }
  }
  equalthreshold_intinput_2 = PrimitiveComponents.Compare.ComparewIntConstant(threshold = 11, tolerance = 0.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 550, "y1": 580, "x2": 650, "y2": 680, "rot": 0}
      }
    }
  }
  constant_int_output = PrimitiveComponents.Sources.ConstantIntegerOutput(k = 10) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 250, "y1": 450, "x2": 350, "y2": 550, "rot": 0}
      }
    }
  }
relations
  connect(equalthreshold_intinput_1.u, constant_int_output.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 456, "y": 390}, {"x": 456, "y": 500}], "E": 2}]}
  }
  connect(constant_int_output.y, equalthreshold_intinput_2.u) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 450, "y": 500}, {"x": 450, "y": 630}], "E": 2}]}
  }
metadata {
  "Dyad": {
    "experiments": {"Test_EqualThreshold_intIinput_": {"stop": 2}},
    "tests": {
      "case1": {
        "stop": 2,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["equalthreshold_intinput_1.y", "equalthreshold_intinput_2.y"]}
      }
    }
  }
}
end


Test Cases

Test Case case1

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