Test_ComparewConstant Icon
Test_ComparewConstant
Usage
PrimitiveComponents.Test_ComparewConstant()
Behavior
\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( constant_{1_{+}y(t)}, equalthreshold_{1_{+}u(t)} \right) \\ \mathrm{connect}\left( constant_{2_{+}y(t)}, equalthreshold_{2_{+}u(t)} \right) \\ \mathrm{connect}\left( constant_{3_{+}y(t)}, equalthreshold_{3_{+}u(t)} \right) \\ \mathrm{connect}\left( constant_{4_{+}y(t)}, equalthreshold_{4_{+}u(t)} \right) \\ \mathrm{connect}\left( constant_{5_{+}y(t)}, equalthreshold_{5_{+}u(t)} \right) \\ \mathtt{equalthreshold\_1.y}\left( t \right) = ifelse\left( \left| - \mathtt{equalthreshold\_1.threshold} + \mathtt{equalthreshold\_1.u}\left( t \right)\right| < \mathtt{equalthreshold\_1.tolerance}, 1, 0 \right) \\ \mathtt{equalthreshold\_2.y}\left( t \right) = ifelse\left( \left| - \mathtt{equalthreshold\_2.threshold} + \mathtt{equalthreshold\_2.u}\left( t \right)\right| < \mathtt{equalthreshold\_2.tolerance}, 1, 0 \right) \\ \mathtt{equalthreshold\_3.y}\left( t \right) = ifelse\left( \left| - \mathtt{equalthreshold\_3.threshold} + \mathtt{equalthreshold\_3.u}\left( t \right)\right| < \mathtt{equalthreshold\_3.tolerance}, 1, 0 \right) \\ \mathtt{equalthreshold\_4.y}\left( t \right) = ifelse\left( \left| - \mathtt{equalthreshold\_4.threshold} + \mathtt{equalthreshold\_4.u}\left( t \right)\right| < \mathtt{equalthreshold\_4.tolerance}, 1, 0 \right) \\ \mathtt{equalthreshold\_5.y}\left( t \right) = ifelse\left( \left| - \mathtt{equalthreshold\_5.threshold} + \mathtt{equalthreshold\_5.u}\left( t \right)\right| < \mathtt{equalthreshold\_5.tolerance}, 1, 0 \right) \\ \mathtt{constant\_1.y}\left( t \right) = \mathtt{constant\_1.k} \\ \mathtt{constant\_2.y}\left( t \right) = \mathtt{constant\_2.k} \\ \mathtt{constant\_3.y}\left( t \right) = \mathtt{constant\_3.k} \\ \mathtt{constant\_4.y}\left( t \right) = \mathtt{constant\_4.k} \\ \mathtt{constant\_5.y}\left( t \right) = \mathtt{constant\_5.k} \\ \end{array} \right] \end{equation} \]
Source
# This test model validates the ComparewConstant block using five constant inputs
# around a threshold of 5.0 with a tolerance of 1e-5.
#
# The test cases include:
# 5.0 → 1.0 (exact match)
# 5.000001 → 1.0 (within tolerance)
# 4.99999 → 1.0 (within tolerance)
# 5.1 → 0.0 (outside tolerance)
# 4.8 → 0.0 (outside tolerance)
component Test_ComparewConstant
equalthreshold_1 = PrimitiveComponents.Compare.ComparewConstant(threshold = 5, tolerance = 1e-5) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 450, "y1": 40, "x2": 550, "y2": 140, "rot": 0}
}
}
}
equalthreshold_2 = PrimitiveComponents.Compare.ComparewConstant(threshold = 5, tolerance = 1e-5) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 450, "y1": 230, "x2": 550, "y2": 330, "rot": 0}
}
}
}
equalthreshold_3 = PrimitiveComponents.Compare.ComparewConstant(threshold = 5, tolerance = 1e-5) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 450, "y1": 450, "x2": 550, "y2": 550, "rot": 0}
}
}
}
equalthreshold_4 = PrimitiveComponents.Compare.ComparewConstant(threshold = 5, tolerance = 1e-5) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 450, "y1": 630, "x2": 550, "y2": 730, "rot": 0}
}
}
}
equalthreshold_5 = PrimitiveComponents.Compare.ComparewConstant(threshold = 5, tolerance = 1e-5) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 450, "y1": 850, "x2": 550, "y2": 950, "rot": 0}
}
}
}
constant_1 = BlockComponents.Constant(k = 5.0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 130, "y1": 40, "x2": 230, "y2": 140, "rot": 0}
}
}
}
constant_2 = BlockComponents.Constant(k = 5.000001) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 130, "y1": 230, "x2": 230, "y2": 330, "rot": 0}
}
}
}
constant_3 = BlockComponents.Constant(k = 4.99999) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 130, "y1": 450, "x2": 230, "y2": 550, "rot": 0}
}
}
}
constant_4 = BlockComponents.Constant(k = 5.1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 140, "y1": 630, "x2": 240, "y2": 730, "rot": 0}
}
}
}
constant_5 = BlockComponents.Constant(k = 4.8) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 150, "y1": 850, "x2": 250, "y2": 950, "rot": 0}
}
}
}
relations
connect(constant_1.y, equalthreshold_1.u) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
connect(constant_2.y, equalthreshold_2.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(constant_3.y, equalthreshold_3.u) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
connect(constant_4.y, equalthreshold_4.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(equalthreshold_5.u, constant_5.y) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
metadata {
"Dyad": {
"experiments": {"Test_EqualThreshold_": {"stop": 2}},
"tests": {
"case1": {
"stop": 2,
"abstol": 0.00001,
"reltol": 0.00001,
"expect": {
"signals": [
"equalthreshold_1.y",
"equalthreshold_2.y",
"equalthreshold_3.y",
"equalthreshold_4.y",
"equalthreshold_4.y"
]
}
}
}
}
}
end
Flattened Source
component Test_ComparewConstant
equalthreshold_1 = PrimitiveComponents.Compare.ComparewConstant(threshold = 5, tolerance = 1e-5) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 450, "y1": 40, "x2": 550, "y2": 140, "rot": 0}
}
}
}
equalthreshold_2 = PrimitiveComponents.Compare.ComparewConstant(threshold = 5, tolerance = 1e-5) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 450, "y1": 230, "x2": 550, "y2": 330, "rot": 0}
}
}
}
equalthreshold_3 = PrimitiveComponents.Compare.ComparewConstant(threshold = 5, tolerance = 1e-5) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 450, "y1": 450, "x2": 550, "y2": 550, "rot": 0}
}
}
}
equalthreshold_4 = PrimitiveComponents.Compare.ComparewConstant(threshold = 5, tolerance = 1e-5) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 450, "y1": 630, "x2": 550, "y2": 730, "rot": 0}
}
}
}
equalthreshold_5 = PrimitiveComponents.Compare.ComparewConstant(threshold = 5, tolerance = 1e-5) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 450, "y1": 850, "x2": 550, "y2": 950, "rot": 0}
}
}
}
constant_1 = BlockComponents.Constant(k = 5.0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 130, "y1": 40, "x2": 230, "y2": 140, "rot": 0}
}
}
}
constant_2 = BlockComponents.Constant(k = 5.000001) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 130, "y1": 230, "x2": 230, "y2": 330, "rot": 0}
}
}
}
constant_3 = BlockComponents.Constant(k = 4.99999) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 130, "y1": 450, "x2": 230, "y2": 550, "rot": 0}
}
}
}
constant_4 = BlockComponents.Constant(k = 5.1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 140, "y1": 630, "x2": 240, "y2": 730, "rot": 0}
}
}
}
constant_5 = BlockComponents.Constant(k = 4.8) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 150, "y1": 850, "x2": 250, "y2": 950, "rot": 0}
}
}
}
relations
connect(constant_1.y, equalthreshold_1.u) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
connect(constant_2.y, equalthreshold_2.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(constant_3.y, equalthreshold_3.u) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
connect(constant_4.y, equalthreshold_4.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(equalthreshold_5.u, constant_5.y) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
metadata {
"Dyad": {
"experiments": {"Test_EqualThreshold_": {"stop": 2}},
"tests": {
"case1": {
"stop": 2,
"abstol": 0.00001,
"reltol": 0.00001,
"expect": {
"signals": [
"equalthreshold_1.y",
"equalthreshold_2.y",
"equalthreshold_3.y",
"equalthreshold_4.y",
"equalthreshold_4.y"
]
}
}
}
}
}
endTest Cases
Test Case case1
pltpltpltpltpltRelated
- Examples
- Experiments
- Analyses