本文整理汇总了Python中cylp.cy.CyClpSimplex.setPivotMethod方法的典型用法代码示例。如果您正苦于以下问题:Python CyClpSimplex.setPivotMethod方法的具体用法?Python CyClpSimplex.setPivotMethod怎么用?Python CyClpSimplex.setPivotMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cylp.cy.CyClpSimplex
的用法示例。
在下文中一共展示了CyClpSimplex.setPivotMethod方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: solve
# 需要导入模块: from cylp.cy import CyClpSimplex [as 别名]
# 或者: from cylp.cy.CyClpSimplex import setPivotMethod [as 别名]
def solve(filename, method):
s = CyClpSimplex()
s.readMps(filename)
s.preSolve(feasibilityTolerance=10 ** -8)
#s.useCustomPrimal(1)
if method == 'd':
pivot = DantzigPivot(s)
elif method == 'l':
pivot = LIFOPivot(s)
elif method == 'm':
pivot = MostFrequentPivot(s)
elif method == 'p':
pivot = PositiveEdgePivot(s)
else:
print 'Unkown solution method.'
sys.exit(1)
s.setPivotMethod(pivot)
#s.setPerturbation(50)
start = clock()
s.primal()
print 'Problem solved in %g seconds.' % (clock() - start)
return s.objectiveValue
示例2: test_1
# 需要导入模块: from cylp.cy import CyClpSimplex [as 别名]
# 或者: from cylp.cy.CyClpSimplex import setPivotMethod [as 别名]
def test_1(self):
"""simplest QP test"""
s = CyClpSimplex()
s.readMps(join(currentFilePath, '../input/hs35.qps'))
#self.assertTrue(abs(cbcModel.objectiveValue - 3089.0) < 10 ** -6)
#print s.Hessian.todense()
p = WolfePivot(s)
s.setPivotMethod(p)
s.primal()
print s.primalVariableSolution
print s.objectiveValue
示例3: TestCyClpSimplex
# 需要导入模块: from cylp.cy import CyClpSimplex [as 别名]
# 或者: from cylp.cy.CyClpSimplex import setPivotMethod [as 别名]
class TestCyClpSimplex(unittest.TestCase):
def setUp(self):
self.s = CyClpSimplex()
self.s.readMps(join(currentFilePath, '../input/p0033.mps'))
def test_PE(self):
#pivot = PositiveEdgePivot(self.s)
self.s.setPivotMethod(PositiveEdgePivot(self.s))
self.s.primal()
self.assertEqual(round(self.s.objectiveValue, 4), 2520.5717)
def test_Dantzig(self):
#pivot = DantzigPivot(self.s)
self.s.setPivotMethod(DantzigPivot(self.s))
self.s.primal()
self.assertEqual(round(self.s.objectiveValue, 4), 2520.5717)
def test_LIFO(self):
#pivot = LIFOPivot(self.s)
self.s.setPivotMethod(LIFOPivot(self.s))
self.s.primal()
self.assertEqual(round(self.s.objectiveValue, 4), 2520.5717)
def test_MostFrequent(self):
#pivot = MostFrequentPivot(self.s)
self.s.setPivotMethod(MostFrequentPivot(self.s))
self.s.primal()
self.assertEqual(round(self.s.objectiveValue, 4), 2520.5717)
def test_initialSolve(self):
self.s.initialSolve()
self.assertEqual(round(self.s.objectiveValue, 4), 2520.5717)
def test_initialPrimalSolve(self):
self.s.initialPrimalSolve()
self.assertEqual(round(self.s.objectiveValue, 4), 2520.5717)
def test_initialDualSolve(self):
self.s.initialDualSolve()
self.assertEqual(round(self.s.objectiveValue, 4), 2520.5717)
def test_direction(self):
self.assertEqual(self.s.optimizationDirection, 'min')
self.s.optimizationDirection = 'max'
self.assertEqual(self.s.optimizationDirection, 'max')
示例4: saveWeights
# 需要导入模块: from cylp.cy import CyClpSimplex [as 别名]
# 或者: from cylp.cy.CyClpSimplex import setPivotMethod [as 别名]
#del rc2
return indicesToConsider[ind]
return -1
def saveWeights(self, model, mode):
self.clpModel = model
def isPivotAcceptable(self):
return True
def getMpsExample():
import os
import inspect
cylpDir = os.environ['CYLP_SOURCE_DIR']
return os.path.join(cylpDir, 'cylp', 'input', 'p0033.mps')
if __name__ == "__main__":
if len(sys.argv) == 1:
import doctest
doctest.testmod()
else:
from cylp.cy import CyClpSimplex
from cylp.py.pivots import DantzigPivot
s = CyClpSimplex()
s.readMps(sys.argv[1])
pivot = DantzigPivot(s)
s.setPivotMethod(pivot)
s.primal()