本文整理汇总了Python中dictionary.Dictionary.canPivot方法的典型用法代码示例。如果您正苦于以下问题:Python Dictionary.canPivot方法的具体用法?Python Dictionary.canPivot怎么用?Python Dictionary.canPivot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dictionary.Dictionary
的用法示例。
在下文中一共展示了Dictionary.canPivot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from dictionary import Dictionary [as 别名]
# 或者: from dictionary.Dictionary import canPivot [as 别名]
class Solver:
problem = None
dictionary = None
def __init__(self, problem):
self.problem = problem
self.dictionary = Dictionary(problem)
def solve(self):
# pivot until solution found
while self.dictionary.canPivot():
self.dictionary.pivot()
# unbounded problem
if self.dictionary.unbounded:
raise SolverError("problem is unbounded")
return self.__getSolution()
# returns solution only in primal form
def __getSolution(self):
dic = self.dictionary
# convert dual solutions
if self.problem.dual:
dual = dic.toProblem()
primal = dual.getDual()
dic = Dictionary(primal)
return dic.getSolution()