Esempio n. 1
0
 def test_acos(self):
     yl, yu = interval.acos(-0.5, 0.5, -math.inf, math.inf)
     self.assertEqual(yl, -math.inf)
     self.assertEqual(yu, math.inf)
     yl, yu = interval.acos(-0.5, 0.5, -0.5*math.pi, 0.5*math.pi)
     self.assertAlmostEqual(yl, -0.5*math.pi, 12)
     self.assertAlmostEqual(yu, 0.5*math.pi, 12)
     yl, yu = interval.acos(-0.5, 0.5, 0, math.pi)
     self.assertAlmostEqual(yl, math.acos(0.5))
     self.assertAlmostEqual(yu, math.acos(-0.5))
     yl, yu = interval.acos(-0.5, 0.5, 0-0.1, math.pi+0.1)
     self.assertAlmostEqual(yl, math.acos(0.5))
     self.assertAlmostEqual(yu, math.acos(-0.5))
     yl, yu = interval.acos(-0.5, 0.5, 0+0.1, math.pi-0.1)
     self.assertAlmostEqual(yl, math.acos(0.5))
     self.assertAlmostEqual(yu, math.acos(-0.5))
     yl, yu = interval.acos(-0.5, 0.5, -math.pi, 0)
     self.assertAlmostEqual(yl, -math.acos(-0.5), 12)
     self.assertAlmostEqual(yu, -math.acos(0.5), 12)
     yl, yu = interval.acos(-0.5, 0.5, -math.pi-0.1, 0+0.1)
     self.assertAlmostEqual(yl, -math.acos(-0.5), 12)
     self.assertAlmostEqual(yu, -math.acos(0.5), 12)
     yl, yu = interval.acos(-0.5, 0.5, -math.pi+0.1, 0-0.1)
     self.assertAlmostEqual(yl, -math.acos(-0.5), 12)
     self.assertAlmostEqual(yu, -math.acos(0.5), 12)
Esempio n. 2
0
def _prop_bnds_leaf_to_root_acos(node, bnds_dict):
    """

    Parameters
    ----------
    node: pyomo.core.expr.numeric_expr.UnaryFunctionExpression
    bnds_dict: ComponentMap
    """
    assert len(node.args) == 1
    arg = node.args[0]
    lb1, ub1 = bnds_dict[arg]
    bnds_dict[node] = interval.acos(lb1, ub1, -math.inf, math.inf)
Esempio n. 3
0
 def test_acos(self):
     yl, yu = interval.acos(-0.5,
                            0.5,
                            -interval.inf,
                            interval.inf,
                            feasibility_tol=1e-8)
     self.assertEqual(yl, -interval.inf)
     self.assertEqual(yu, interval.inf)
     yl, yu = interval.acos(-0.5,
                            0.5,
                            -0.5 * math.pi,
                            0.5 * math.pi,
                            feasibility_tol=1e-8)
     self.assertAlmostEqual(yl, -0.5 * math.pi, 12)
     self.assertAlmostEqual(yu, 0.5 * math.pi, 12)
     yl, yu = interval.acos(-0.5, 0.5, 0, math.pi, feasibility_tol=1e-8)
     self.assertAlmostEqual(yl, math.acos(0.5))
     self.assertAlmostEqual(yu, math.acos(-0.5))
     yl, yu = interval.acos(-0.5,
                            0.5,
                            0 - 0.1,
                            math.pi + 0.1,
                            feasibility_tol=1e-8)
     self.assertAlmostEqual(yl, math.acos(0.5))
     self.assertAlmostEqual(yu, math.acos(-0.5))
     yl, yu = interval.acos(-0.5,
                            0.5,
                            0 + 0.1,
                            math.pi - 0.1,
                            feasibility_tol=1e-8)
     self.assertAlmostEqual(yl, math.acos(0.5))
     self.assertAlmostEqual(yu, math.acos(-0.5))
     yl, yu = interval.acos(-0.5, 0.5, -math.pi, 0, feasibility_tol=1e-8)
     self.assertAlmostEqual(yl, -math.acos(-0.5), 12)
     self.assertAlmostEqual(yu, -math.acos(0.5), 12)
     yl, yu = interval.acos(-0.5,
                            0.5,
                            -math.pi - 0.1,
                            0 + 0.1,
                            feasibility_tol=1e-8)
     self.assertAlmostEqual(yl, -math.acos(-0.5), 12)
     self.assertAlmostEqual(yu, -math.acos(0.5), 12)
     yl, yu = interval.acos(-0.5,
                            0.5,
                            -math.pi + 0.1,
                            0 - 0.1,
                            feasibility_tol=1e-8)
     self.assertAlmostEqual(yl, -math.acos(-0.5), 12)
     self.assertAlmostEqual(yu, -math.acos(0.5), 12)
Esempio n. 4
0
def _prop_bnds_root_to_leaf_cos(node, bnds_dict):
    """

    Parameters
    ----------
    node: pyomo.core.expr.expr_pyomo5.UnaryFunctionExpression
    bnds_dict: ComponentMap
    """
    assert len(node.args) == 1
    arg = node.args[0]
    lb0, ub0 = bnds_dict[node]
    lb1, ub1 = bnds_dict[arg]
    _lb1, _ub1 = interval.acos(lb0, ub0, lb1, ub1)
    if _lb1 > lb1:
        lb1 = _lb1
    if _ub1 < ub1:
        ub1 = _ub1
    bnds_dict[arg] = (lb1, ub1)
Esempio n. 5
0
def _prop_bnds_root_to_leaf_cos(node, bnds_dict):
    """

    Parameters
    ----------
    node: pyomo.core.expr.numeric_expr.UnaryFunctionExpression
    bnds_dict: ComponentMap
    """
    assert len(node.args) == 1
    arg = node.args[0]
    lb0, ub0 = bnds_dict[node]
    lb1, ub1 = bnds_dict[arg]
    _lb1, _ub1 = interval.acos(lb0, ub0, lb1, ub1)
    if _lb1 > lb1:
        lb1 = _lb1
    if _ub1 < ub1:
        ub1 = _ub1
    bnds_dict[arg] = (lb1, ub1)