本文整理匯總了Python中pyutilib.misc.Options.kwds方法的典型用法代碼示例。如果您正苦於以下問題:Python Options.kwds方法的具體用法?Python Options.kwds怎麽用?Python Options.kwds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyutilib.misc.Options
的用法示例。
在下文中一共展示了Options.kwds方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_t1
# 需要導入模塊: from pyutilib.misc import Options [as 別名]
# 或者: from pyutilib.misc.Options import kwds [as 別名]
def test_t1(self):
# Run a simple model
model = ConcreteModel()
model.A = RangeSet(1,4)
model.x = Var(model.A, bounds=(-1,1))
def obj_rule(model):
return sum_product(model.x)
model.obj = Objective(rule=obj_rule)
def c_rule(model):
expr = 0
for i in model.A:
expr += i*model.x[i]
return expr == 0
model.c = Constraint(rule=c_rule)
#
data = Options()
data.suffixes = {}
data.solver_options = {}
data.warmstart_filename = None
data.filename = currdir+'t1.lp'
model.write(data['filename'])
INPUT = open(data['filename'],'r')
data['file'] = INPUT.read()
INPUT.close()
data['opt'] = 'glpk'
data.kwds = {}
#
results = self.worker.process(data)
# Decode, evaluate and unpickle results
if using_pyro4:
# These two conversions are in place to unwrap
# the hacks placed in the pyro_mip_server
# before transmitting the results
# object. These hacks are put in place to
# avoid errors when transmitting the pickled
# form of the results object with the default Pyro4
# serializer (Serpent)
if six.PY3:
results = base64.decodebytes(
ast.literal_eval(results))
else:
results = base64.decodestring(results)
results = pickle.loads(results)
#
results.write(filename=currdir+"t1.out", format='json')
self.assertMatchesJsonBaseline(currdir+"t1.out",currdir+"t1.txt", tolerance=1e-4)
self.assertEqual(results._smap_id, None)
os.remove(data['filename'])