Ejemplo n.º 1
0
    def test_inv(self):
        lb, ub = interval.inv(0.1, 0.2, feasibility_tol=1e-8)
        self.assertAlmostEqual(lb, 5)
        self.assertAlmostEqual(ub, 10)

        lb, ub = interval.inv(0, 0.1, feasibility_tol=1e-8)
        self.assertEqual(lb, -math.inf)
        self.assertEqual(ub, math.inf)

        lb, ub = interval.inv(0, 0, feasibility_tol=1e-8)
        self.assertEqual(lb, -math.inf)
        self.assertEqual(ub, math.inf)

        lb, ub = interval.inv(-0.1, 0, feasibility_tol=1e-8)
        self.assertEqual(lb, -math.inf)
        self.assertEqual(ub, math.inf)

        lb, ub = interval.inv(-0.2, -0.1, feasibility_tol=1e-8)
        self.assertAlmostEqual(lb, -10)
        self.assertAlmostEqual(ub, -5)

        lb, ub = interval.inv(0, -1e-16, feasibility_tol=1e-8)
        self.assertEqual(lb, -math.inf)
        self.assertEqual(ub, math.inf)

        lb, ub = interval.inv(1e-16, 0, feasibility_tol=1e-8)
        self.assertEqual(lb, -math.inf)
        self.assertAlmostEqual(ub, math.inf)

        lb, ub = interval.inv(-1, 1, feasibility_tol=1e-8)
        self.assertAlmostEqual(lb, -math.inf)
        self.assertAlmostEqual(ub, math.inf)
Ejemplo n.º 2
0
    def test_inv(self):
        lb, ub = interval.inv(0.1, 0.2, feasibility_tol=1e-8)
        self.assertAlmostEqual(lb, 5)
        self.assertAlmostEqual(ub, 10)

        lb, ub = interval.inv(0, 0.1, feasibility_tol=1e-8)
        self.assertEqual(lb, 10)
        self.assertEqual(ub, interval.inf)

        with self.assertRaises(interval.IntervalException):
            lb, ub = interval.inv(0, 0, feasibility_tol=1e-8)

        lb, ub = interval.inv(-0.1, 0, feasibility_tol=1e-8)
        self.assertEqual(lb, -interval.inf)
        self.assertEqual(ub, -10)

        lb, ub = interval.inv(-0.2, -0.1, feasibility_tol=1e-8)
        self.assertAlmostEqual(lb, -10)
        self.assertAlmostEqual(ub, -5)

        with self.assertRaises(interval.IntervalException):
            lb, ub = interval.inv(0, -1e-16, feasibility_tol=1e-8)

        with self.assertRaises(interval.IntervalException):
            lb, ub = interval.inv(1e-16, 0, feasibility_tol=1e-8)

        lb, ub = interval.inv(-1, 1, feasibility_tol=1e-8)
        self.assertAlmostEqual(lb, -interval.inf)
        self.assertAlmostEqual(ub, interval.inf)
Ejemplo n.º 3
0
def _prop_bnds_leaf_to_root_ReciprocalExpression(node, bnds_dict):
    """

    Parameters
    ----------
    node: pyomo.core.expr.expr_pyomo5.ReciprocalExpression
    bnds_dict: ComponentMap
    """
    assert len(node.args) == 1
    arg = node.args[0]
    lb1, ub1 = bnds_dict[arg]
    bnds_dict[node] = interval.inv(lb1, ub1)
Ejemplo n.º 4
0
def _prop_bnds_leaf_to_root_ReciprocalExpression(node, bnds_dict):
    """

    Parameters
    ----------
    node: pyomo.core.expr.numeric_expr.ReciprocalExpression
    bnds_dict: ComponentMap
    """
    assert len(node.args) == 1
    arg = node.args[0]
    lb1, ub1 = bnds_dict[arg]
    bnds_dict[node] = interval.inv(lb1, ub1)
Ejemplo n.º 5
0
def _prop_bnds_root_to_leaf_ReciprocalExpression(node, bnds_dict):
    """

    Parameters
    ----------
    node: pyomo.core.expr.expr_pyomo5.ProductExpression
    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.inv(lb0, ub0)
    if _lb1 > lb1:
        lb1 = _lb1
    if _ub1 < ub1:
        ub1 = _ub1
    bnds_dict[arg] = (lb1, ub1)
Ejemplo n.º 6
0
def _prop_bnds_root_to_leaf_ReciprocalExpression(node, bnds_dict):
    """

    Parameters
    ----------
    node: pyomo.core.expr.numeric_expr.ProductExpression
    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.inv(lb0, ub0)
    if _lb1 > lb1:
        lb1 = _lb1
    if _ub1 < ub1:
        ub1 = _ub1
    bnds_dict[arg] = (lb1, ub1)