Esempio n. 1
0
    def test_dcp_curvature(self):
        assert_equals(
            m.dcp_curvature(m.INCREASING, Curvature.AFFINE, Sign.POSITIVE,
                            Curvature.CONVEX), Curvature.CONVEX)
        assert_equals(
            m.dcp_curvature(m.NONMONOTONIC, Curvature.AFFINE, Sign.POSITIVE,
                            Curvature.AFFINE), Curvature.AFFINE)
        assert_equals(
            m.dcp_curvature(m.DECREASING, Curvature.UNKNOWN, Sign.POSITIVE,
                            Curvature.CONSTANT), Curvature.CONSTANT)

        assert_equals(
            m.dcp_curvature(m.INCREASING, Curvature.CONVEX, Sign.POSITIVE,
                            Curvature.CONVEX), Curvature.CONVEX)
        assert_equals(
            m.dcp_curvature(m.DECREASING, Curvature.CONVEX, Sign.POSITIVE,
                            Curvature.CONCAVE), Curvature.CONVEX)

        assert_equals(
            m.dcp_curvature(m.INCREASING, Curvature.CONCAVE, Sign.POSITIVE,
                            Curvature.CONCAVE), Curvature.CONCAVE)
        assert_equals(
            m.dcp_curvature(m.DECREASING, Curvature.CONCAVE, Sign.POSITIVE,
                            Curvature.CONVEX), Curvature.CONCAVE)

        assert_equals(
            m.dcp_curvature(m.INCREASING, Curvature.CONCAVE, Sign.POSITIVE,
                            Curvature.CONVEX), Curvature.UNKNOWN)
        assert_equals(
            m.dcp_curvature(m.NONMONOTONIC, Curvature.CONCAVE, Sign.POSITIVE,
                            Curvature.AFFINE), Curvature.CONCAVE)

        assert_equals(
            m.dcp_curvature(m.NONMONOTONIC, Curvature.CONSTANT, Sign.POSITIVE,
                            Curvature.UNKNOWN), Curvature.UNKNOWN)
Esempio n. 2
0
 def test_signed_curvature(self):
     # Convex argument.
     assert_equals(
         m.dcp_curvature(m.SIGNED, Curvature.CONVEX, Sign.POSITIVE,
                         Curvature.CONVEX), Curvature.CONVEX)
     assert_equals(
         m.dcp_curvature(m.SIGNED, Curvature.CONVEX, Sign.NEGATIVE,
                         Curvature.CONVEX), Curvature.UNKNOWN)
     assert_equals(
         m.dcp_curvature(m.SIGNED, Curvature.CONVEX, Sign.UNKNOWN,
                         Curvature.CONVEX), Curvature.UNKNOWN)
     # Concave argument.
     assert_equals(
         m.dcp_curvature(m.SIGNED, Curvature.CONVEX, Sign.POSITIVE,
                         Curvature.CONCAVE), Curvature.UNKNOWN)
     assert_equals(
         m.dcp_curvature(m.SIGNED, Curvature.CONVEX, Sign.NEGATIVE,
                         Curvature.CONCAVE), Curvature.CONVEX)
     assert_equals(
         m.dcp_curvature(m.SIGNED, Curvature.CONVEX, Sign.UNKNOWN,
                         Curvature.CONCAVE), Curvature.UNKNOWN)
     # Affine argument.
     assert_equals(
         m.dcp_curvature(m.SIGNED, Curvature.CONVEX, Sign.POSITIVE,
                         Curvature.AFFINE), Curvature.CONVEX)
     assert_equals(
         m.dcp_curvature(m.SIGNED, Curvature.CONVEX, Sign.NEGATIVE,
                         Curvature.AFFINE), Curvature.CONVEX)
     assert_equals(
         m.dcp_curvature(m.SIGNED, Curvature.CONVEX, Sign.UNKNOWN,
                         Curvature.AFFINE), Curvature.CONVEX)
Esempio n. 3
0
    def test_dcp_curvature(self):
        assert_equals(m.dcp_curvature(m.INCREASING,
                                      Curvature.AFFINE,
                                                 Sign.POSITIVE,
                                                 Curvature.CONVEX),
                      Curvature.CONVEX)
        assert_equals(m.dcp_curvature(m.NONMONOTONIC, Curvature.AFFINE,
                                                   Sign.POSITIVE,
                                                   Curvature.AFFINE),
                    Curvature.AFFINE)
        assert_equals(m.dcp_curvature(m.DECREASING, Curvature.UNKNOWN,
                                                 Sign.POSITIVE,
                                                 Curvature.CONSTANT),
                      Curvature.CONSTANT)

        assert_equals(m.dcp_curvature(m.INCREASING, Curvature.CONVEX,
                                                            Sign.POSITIVE,
                                                            Curvature.CONVEX),
                       Curvature.CONVEX)
        assert_equals(m.dcp_curvature(m.DECREASING, Curvature.CONVEX,
                                                            Sign.POSITIVE,
                                                            Curvature.CONCAVE),
                       Curvature.CONVEX)

        assert_equals(m.dcp_curvature(m.INCREASING, Curvature.CONCAVE,
                                                            Sign.POSITIVE,
                                                            Curvature.CONCAVE),
                      Curvature.CONCAVE)
        assert_equals(m.dcp_curvature(m.DECREASING, Curvature.CONCAVE,
                                                            Sign.POSITIVE,
                                                            Curvature.CONVEX),
                      Curvature.CONCAVE)

        assert_equals(m.dcp_curvature(m.INCREASING, Curvature.CONCAVE,
                                                            Sign.POSITIVE,
                                                            Curvature.CONVEX),
                      Curvature.UNKNOWN)
        assert_equals(m.dcp_curvature(m.NONMONOTONIC, Curvature.CONCAVE,
                                                              Sign.POSITIVE,
                                                              Curvature.AFFINE),
                      Curvature.CONCAVE)

        assert_equals(m.dcp_curvature(m.NONMONOTONIC, Curvature.CONSTANT,
                                                              Sign.POSITIVE,
                                                              Curvature.UNKNOWN),
                      Curvature.UNKNOWN)
Esempio n. 4
0
 def test_signed_curvature(self):
     # Convex argument.
     assert_equals(m.dcp_curvature(m.SIGNED, Curvature.CONVEX,
                                                     Sign.POSITIVE,
                                                     Curvature.CONVEX),
                   Curvature.CONVEX)
     assert_equals(m.dcp_curvature(m.SIGNED, Curvature.CONVEX,
                                                     Sign.NEGATIVE,
                                                     Curvature.CONVEX),
                   Curvature.UNKNOWN)
     assert_equals(m.dcp_curvature(m.SIGNED, Curvature.CONVEX,
                                                     Sign.UNKNOWN,
                                                     Curvature.CONVEX),
                   Curvature.UNKNOWN)
     # Concave argument.
     assert_equals(m.dcp_curvature(m.SIGNED, Curvature.CONVEX,
                                                     Sign.POSITIVE,
                                                     Curvature.CONCAVE),
                   Curvature.UNKNOWN)
     assert_equals(m.dcp_curvature(m.SIGNED, Curvature.CONVEX,
                                                     Sign.NEGATIVE,
                                                     Curvature.CONCAVE),
                   Curvature.CONVEX)
     assert_equals(m.dcp_curvature(m.SIGNED, Curvature.CONVEX,
                                                     Sign.UNKNOWN,
                                                     Curvature.CONCAVE),
                   Curvature.UNKNOWN)
     # Affine argument.
     assert_equals(m.dcp_curvature(m.SIGNED, Curvature.CONVEX,
                                                     Sign.POSITIVE,
                                                     Curvature.AFFINE),
                   Curvature.CONVEX)
     assert_equals(m.dcp_curvature(m.SIGNED, Curvature.CONVEX,
                                                     Sign.NEGATIVE,
                                                     Curvature.AFFINE),
                   Curvature.CONVEX)
     assert_equals(m.dcp_curvature(m.SIGNED, Curvature.CONVEX,
                                                     Sign.UNKNOWN,
                                                     Curvature.AFFINE),
                   Curvature.CONVEX)