Esempio n. 1
0
def opt_basic_5():
    """ It should be able to re-order, but it doesn't.... """
    l1b = parse_constant('upperclosure { < 1 g, 4 g > }').value
    l2b = parse_constant('upperclosure { < 5 g, 3 g > }').value

    assert not less_resources2(l1b, l2b)
    assert less_resources2(l2b, l1b)
Esempio n. 2
0
def opt_basic_3():
    l1b = parse_constant('upperclosure { < 10 g > }').value
    l2b = parse_constant('upperclosure { < 20 g > }').value
    assert less_resources2(l1b, l2b)
    assert not less_resources2(l2b, l1b)

    l1b = parse_constant('upperclosure { < 10 g > }').value
    l2b = parse_constant('upperclosure { < 20 mg > }').value
    assert not less_resources2(l1b, l2b)
    assert less_resources2(l2b, l1b)
Esempio n. 3
0
def check_subtraction1():
    s = """
    mcdp {
            v1 = 10 g
            v2 = 2 g
            v3 = 1 g
            v = v1 - v2 - v3

            requires x = v
        }
    """
    parse_ndp(s)

    s = """
    mcdp {
     t = instance mcdp {
            v1 = 10 g
            v2 = 2 g
            v3 = 1 g
            v = v1 - v2 - v3

            requires x = v
        }
    }
    """
    parse_ndp(s)

    parse_constant("""
    assert_equal(
        solve(<>, mcdp {
            v1 = 10 g
            v2 = 2 g
            v3 = 1 g
            v = v1 - v2 - v3

            requires x = v
        }),
        upperclosure { 7 g }
    )
    """)
Esempio n. 4
0
def check_subtraction1():
    s = """
    mcdp {
            v1 = 10 g
            v2 = 2 g
            v3 = 1 g
            v = v1 - v2 - v3 
            
            requires x = v
        }
    """
    parse_ndp(s)
    
    s = """
    mcdp {
     t = instance mcdp {
            v1 = 10 g
            v2 = 2 g
            v3 = 1 g
            v = v1 - v2 - v3 
            
            requires x = v
        }
    }
    """
    parse_ndp(s)
    
    parse_constant("""
    assert_equal(
        solve(<>, mcdp {
            v1 = 10 g
            v2 = 2 g
            v3 = 1 g
            v = v1 - v2 - v3 
            
            requires x = v
        }),
        upperclosure { 7 g }
    )
    """)
Esempio n. 5
0
def enlarge(value_string, alpha):
    c = parse_constant(value_string)

    l = c.value * (1 - alpha)
    u = c.value * (1 + alpha)

    ls = c.unit.format(l)
    us = c.unit.format(u)

    if '[]' in value_string:
        ls = '%s []' % l
        us = '%s []' % u
    return ls, us
Esempio n. 6
0
def enlarge(value_string, alpha):
    c = parse_constant(value_string)

    l = c.value * (1-alpha)
    u = c.value * (1+alpha)

    ls = c.unit.format(l)
    us = c.unit.format(u)

    if '[]' in value_string:
        ls = '%s []' % l
        us = '%s []' % u
    return ls, us
Esempio n. 7
0
def check_asserts6():

    parse_constant('assert_nonempty(solve(<>, mcdp{}))')
    pass
Esempio n. 8
0
def check_asserts5():
    parse_constant('assert_nonempty({0g})')
    exp_ass('assert_empty({0g})')
Esempio n. 9
0
def check_asserts4():
    parse_constant('assert_equal(0g, 0g)')
    parse_constant('assert_equal(1kg, 1000g)')
    exp_ass('assert_equal(0g, 1g)')
Esempio n. 10
0
def check_asserts3():
    parse_constant('assert_gt(1g, 0g)')
    exp_ass('assert_gt(0g, 0g)')
Esempio n. 11
0
def check_asserts2():
    parse_constant('assert_lt(0g, 1g)')
    exp_ass('assert_lt(0g, 0g)')
Esempio n. 12
0
def check_asserts1():
    parse_constant('assert_leq(0g, 1g)')
    exp_ass('assert_leq(1g, 0g)')
Esempio n. 13
0
def check_misc():
    parse_constant('100 m + 100 km')
    assert_raises(DPSemanticError, parse_constant, '100 m + 100 g')
Esempio n. 14
0
def check_lang_singlespace2():
    P = parse_poset('S(singleton)')
    assert P == FinitePoset(set(['singleton']), [])
    c = parse_constant('S(singleton):*')
    assert c.value == 'singleton'
Esempio n. 15
0
def check_lang_singlespace2():
    P = parse_poset('S(singleton)')
    assert P == FinitePoset(set(['singleton']), [])
    c = parse_constant('S(singleton):*')
    assert c.value == 'singleton'