当前位置: 首页>>代码示例>>Python>>正文


Python Solver.compile方法代码示例

本文整理汇总了Python中solver.Solver.compile方法的典型用法代码示例。如果您正苦于以下问题:Python Solver.compile方法的具体用法?Python Solver.compile怎么用?Python Solver.compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在solver.Solver的用法示例。


在下文中一共展示了Solver.compile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_equalities_give_pseudo_boolean_constraints

# 需要导入模块: from solver import Solver [as 别名]
# 或者: from solver.Solver import compile [as 别名]
def test_equalities_give_pseudo_boolean_constraints(ls, m):
    solver = Solver()
    variables = [variable(i) for i in range(len(ls))]
    objective = sum(l * v for l, v in zip(ls, variables))
    constraint = solver.compile(objective == m)
    pseudo_boolean = solver.builder.pseudo_boolean_constraint(
        [(l, solver.compile(v)) for l, v in zip(ls, variables)], m, m)
    assert constraint == pseudo_boolean
开发者ID:DRMacIver,项目名称:PseudoBoolean,代码行数:10,代码来源:test_solver.py

示例2: test_intervals_give_pseudo_boolean_constraints

# 需要导入模块: from solver import Solver [as 别名]
# 或者: from solver.Solver import compile [as 别名]
def test_intervals_give_pseudo_boolean_constraints(ls, m, n):
    assume(m <= n)
    solver = Solver()
    variables = [variable(i) for i in range(len(ls))]
    objective = sum(l * v for l, v in zip(ls, variables))
    constraint = solver.compile((objective >= m) & (objective <= n))
    pseudo_boolean = solver.builder.pseudo_boolean_constraint(
        [(l, solver.compile(v)) for l, v in zip(ls, variables)], m, n)
    assert constraint == pseudo_boolean
开发者ID:DRMacIver,项目名称:PseudoBoolean,代码行数:11,代码来源:test_solver.py

示例3: test_upper_bound_gives_pseudo_boolean_constraint

# 需要导入模块: from solver import Solver [as 别名]
# 或者: from solver.Solver import compile [as 别名]
def test_upper_bound_gives_pseudo_boolean_constraint(ls, m):
    solver = Solver()
    variables = [variable(i) for i in range(len(ls))]
    objective = sum(l * v for l, v in zip(ls, variables))
    constraint = solver.compile(objective <= m)
    pseudo_boolean = solver.builder.pseudo_boolean_constraint(
        [(l, solver.compile(v)) for l, v in zip(ls, variables)],
        -sum(map(abs, ls)), m)
    assert constraint == pseudo_boolean
开发者ID:DRMacIver,项目名称:PseudoBoolean,代码行数:11,代码来源:test_solver.py

示例4: test_can_multiply_associatively

# 需要导入模块: from solver import Solver [as 别名]
# 或者: from solver.Solver import compile [as 别名]
def test_can_multiply_associatively():
    solver = Solver()
    x = variable('x')
    assert solver.compile((x * 2) * 3 == x * 6) is True
开发者ID:DRMacIver,项目名称:PseudoBoolean,代码行数:6,代码来源:test_solver.py


注:本文中的solver.Solver.compile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。