Best JavaScript code snippet using storybook-root
test_rosmaster_paramserver.py
Source:test_rosmaster_paramserver.py
...91 reg_manager = RegistrationManager(ThreadPoolMock())92 param_server = ParamDictionary(reg_manager)93 # subscribe to parameter that has not been set yet94 self.last_update = None95 self.assertEquals({}, param_server.subscribe_param('/foo', ('node1', 'http://node1:1')))96 param_server.set_param('/foo', 1, notify_task=self.notify_task)97 self.assertEquals([([('node1', 'http://node1:1')], '/foo/', 1), ], self.last_update)98 99 # resubscribe100 self.assertEquals(1, param_server.subscribe_param('/foo', ('node1', 'http://node1:1')))101 param_server.set_param('/foo', 2, notify_task=self.notify_task)102 self.assertEquals([([('node1', 'http://node1:1')], '/foo/', 2), ], self.last_update)103 # resubscribe (test canonicalization of parameter name)104 self.assertEquals(2, param_server.subscribe_param('/foo/', ('node1', 'http://node1:1')))105 param_server.set_param('/foo', 'resub2', notify_task=self.notify_task)106 self.assertEquals([([('node1', 'http://node1:1')], '/foo/', 'resub2'), ], self.last_update)107 108 # change the URI109 self.assertEquals('resub2', param_server.subscribe_param('/foo', ('node1', 'http://node1b:1')))110 self.assertEquals('http://node1b:1', reg_manager.get_node('node1').api)111 param_server.set_param('/foo', 3, notify_task=self.notify_task)112 self.assertEquals([([('node1', 'http://node1b:1')], '/foo/', 3), ], self.last_update)113 114 # multiple subscriptions to same param115 self.assertEquals(3, param_server.subscribe_param('/foo', ('node2', 'http://node2:2')))116 self.assertEquals('http://node2:2', reg_manager.get_node('node2').api)117 param_server.set_param('/foo', 4, notify_task=self.notify_task)118 self.assertEquals([([('node1', 'http://node1b:1'), ('node2', 'http://node2:2')], '/foo/', 4), ], self.last_update)119 def test_subscribe_param_tree(self):120 from rosmaster.registrations import RegistrationManager121 from rosmaster.paramserver import ParamDictionary122 # setup node and subscriber data123 reg_manager = RegistrationManager(ThreadPoolMock())124 param_server = ParamDictionary(reg_manager)125 # Test Parameter Tree Subscriptions126 # simple case - subscribe and set whole tree127 gains = {'p': 'P', 'i': 'I', 'd' : 'D'}128 self.assertEquals({}, param_server.subscribe_param('/gains', ('ptnode', 'http://ptnode:1')))129 param_server.set_param('/gains', gains.copy(), notify_task=self.notify_task)130 self.assertEquals([([('ptnode', 'http://ptnode:1')], '/gains/', gains), ], self.last_update)131 # - test with trailing slash132 param_server.set_param('/gains/', gains.copy(), notify_task=self.notify_task)133 self.assertEquals([([('ptnode', 'http://ptnode:1')], '/gains/', gains), ], self.last_update)134 # change params within tree135 param_server.set_param('/gains/p', 'P2', notify_task=self.notify_task)136 self.assertEquals([([('ptnode', 'http://ptnode:1')], '/gains/p/', 'P2'), ], self.last_update)137 param_server.set_param('/gains/i', 'I2', notify_task=self.notify_task)138 self.assertEquals([([('ptnode', 'http://ptnode:1')], '/gains/i/', 'I2'), ], self.last_update)139 # test overlapping subscriptions140 self.assertEquals('P2', param_server.subscribe_param('/gains/p', ('ptnode2', 'http://ptnode2:2')))141 param_server.set_param('/gains', gains.copy(), notify_task=self.notify_task)142 self.assertEquals([([('ptnode', 'http://ptnode:1')], '/gains/', gains), \143 ([('ptnode2', 'http://ptnode2:2')], '/gains/p/', 'P'), \144 ], self.last_update)145 # - retest with trailing slash on subscribe146 self.last_update = None147 self.assertEquals('P', param_server.subscribe_param('/gains/p/', ('ptnode2', 'http://ptnode2:2')))148 param_server.set_param('/gains', gains.copy(), notify_task=self.notify_task)149 self.assertEquals([([('ptnode', 'http://ptnode:1')], '/gains/', gains), \150 ([('ptnode2', 'http://ptnode2:2')], '/gains/p/', 'P'), \151 ], self.last_update)152 # test with overlapping (change to sub param)153 param_server.set_param('/gains/p', 'P3', notify_task=self.notify_task)154 # - this is a bit overtuned as a more optimal ps could use one update155 ptnode2 = ([('ptnode2', 'http://ptnode2:2')], '/gains/p/', 'P3')156 ptnode = ([('ptnode', 'http://ptnode:1')], '/gains/p/', 'P3')157 self.assertTrue(len(self.last_update) == 2)158 self.assertTrue(ptnode2 in self.last_update)159 self.assertTrue(ptnode in self.last_update)160 # virtual deletion: subscribe to subparam, parameter tree reset161 self.last_update = None162 param_server.set_param('/gains2', gains.copy(), notify_task=self.notify_task)163 self.assertEquals('P', param_server.subscribe_param('/gains2/p/', ('ptnode3', 'http://ptnode3:3')))164 # - erase the sub parameters165 param_server.set_param('/gains2', {}, notify_task=self.notify_task) 166 self.assertEquals([([('ptnode3', 'http://ptnode3:3')], '/gains2/p/', {}), ], self.last_update) 167 #Final test: test subscription to entire tree168 self.last_update = None169 param_server.delete_param('/gains')170 param_server.delete_param('/gains2') 171 self.assertEquals({}, param_server.get_param('/'))172 self.assertEquals({}, param_server.subscribe_param('/', ('allnode', 'http://allnode:1')))173 param_server.set_param('/one', 1, notify_task=self.notify_task)174 self.assertEquals([([('allnode', 'http://allnode:1')], '/one/', 1), ], self.last_update)175 param_server.set_param('/two', 2, notify_task=self.notify_task)176 self.assertEquals([([('allnode', 'http://allnode:1')], '/two/', 2), ], self.last_update)177 param_server.set_param('/foo/bar', 'bar', notify_task=self.notify_task)178 self.assertEquals([([('allnode', 'http://allnode:1')], '/foo/bar/', 'bar'), ], self.last_update)179 180 # verify that subscribe_param works with parameter deletion181 def test_subscribe_param_deletion(self):182 from rosmaster.registrations import RegistrationManager183 from rosmaster.paramserver import ParamDictionary184 # setup node and subscriber data185 reg_manager = RegistrationManager(ThreadPoolMock())186 param_server = ParamDictionary(reg_manager)187 # subscription to then delete parameter188 self.assertEquals({}, param_server.subscribe_param('/foo', ('node1', 'http://node1:1')))189 param_server.set_param('/foo', 1, notify_task=self.notify_task)190 param_server.delete_param('/foo', notify_task=self.notify_task)191 self.assertEquals([([('node1', 'http://node1:1')], '/foo/', {}), ], self.last_update)192 193 # subscribe to and delete whole tree194 gains = {'p': 'P', 'i': 'I', 'd' : 'D'}195 self.assertEquals({}, param_server.subscribe_param('/gains', ('deltree', 'http://deltree:1')))196 param_server.set_param('/gains', gains.copy(), notify_task=self.notify_task)197 param_server.delete_param('/gains', notify_task=self.notify_task)198 self.assertEquals([([('deltree', 'http://deltree:1')], '/gains/', {}), ], self.last_update)199 # subscribe to and delete params within subtree200 self.assertEquals({}, param_server.subscribe_param('/gains2', ('deltree2', 'http://deltree2:2')))201 param_server.set_param('/gains2', gains.copy(), notify_task=self.notify_task)202 param_server.delete_param('/gains2/p', notify_task=self.notify_task)203 self.assertEquals([([('deltree2', 'http://deltree2:2')], '/gains2/p/', {}), ], self.last_update)204 param_server.delete_param('/gains2/i', notify_task=self.notify_task)205 self.assertEquals([([('deltree2', 'http://deltree2:2')], '/gains2/i/', {}), ], self.last_update) 206 param_server.delete_param('/gains2', notify_task=self.notify_task)207 self.assertEquals([([('deltree2', 'http://deltree2:2')], '/gains2/', {}), ], self.last_update)208 209 # delete parent tree210 k = '/ns1/ns2/ns3/key'211 self.assertEquals({}, param_server.subscribe_param(k, ('del_parent', 'http://del_parent:1')))212 param_server.set_param(k, 1, notify_task=self.notify_task)213 param_server.delete_param('/ns1/ns2', notify_task=self.notify_task)214 self.assertEquals([([('del_parent', 'http://del_parent:1')], '/ns1/ns2/ns3/key/', {}), ], self.last_update)215 216 def test_unsubscribe_param(self):217 from rosmaster.registrations import RegistrationManager218 from rosmaster.paramserver import ParamDictionary219 # setup node and subscriber data220 reg_manager = RegistrationManager(ThreadPoolMock())221 param_server = ParamDictionary(reg_manager)222 # basic test223 self.last_update = None224 self.assertEquals({}, param_server.subscribe_param('/foo', ('node1', 'http://node1:1')))225 param_server.set_param('/foo', 1, notify_task=self.notify_task)226 self.assertEquals([([('node1', 'http://node1:1')], '/foo/', 1), ], self.last_update)227 # - return value is actually generated by Registrations228 code, msg, val = param_server.unsubscribe_param('/foo', ('node1', 'http://node1:1'))229 self.assertEquals(1, code)230 self.assertEquals(1, val)231 self.last_update = None232 param_server.set_param('/foo', 2, notify_task=self.notify_task)233 self.assertEquals(None, self.last_update)234 # - repeat the unsubscribe235 code, msg, val = param_server.unsubscribe_param('/foo', ('node1', 'http://node1:1'))236 self.assertEquals(1, code)237 self.assertEquals(0, val)238 self.last_update = None239 param_server.set_param('/foo', 2, notify_task=self.notify_task)240 self.assertEquals(None, self.last_update)241 # verify that stale unsubscribe has no effect on active subscription242 self.last_update = None243 self.assertEquals({}, param_server.subscribe_param('/bar', ('barnode', 'http://barnode:1')))244 param_server.set_param('/bar', 3, notify_task=self.notify_task)245 self.assertEquals([([('barnode', 'http://barnode:1')], '/bar/', 3), ], self.last_update)246 code, msg, val = param_server.unsubscribe_param('/foo', ('barnode', 'http://notbarnode:1'))247 self.assertEquals(1, code)248 self.assertEquals(0, val)249 param_server.set_param('/bar', 4, notify_task=self.notify_task)250 self.assertEquals([([('barnode', 'http://barnode:1')], '/bar/', 4), ], self.last_update)251 252 253 def _set_param(self, ctx, my_state, test_vals, param_server):254 ctx = make_global_ns(ctx)255 for type, vals in test_vals:256 try:257 caller_id = ns_join(ctx, "node")258 count = 0259 for val in vals:260 key = ns_join(caller_id, "%s-%s"%(type,count))261 param_server.set_param(key, val)262 self.assert_(param_server.has_param(key))263 true_key = ns_join(ctx, key)264 my_state[true_key] = val265 count += 1266 except Exception:267 assert "getParam failed on type[%s], val[%s]"%(type,val)268 #self._check_param_state(my_state)269 def _check_param_state(self, param_server, my_state):270 for (k, v) in my_state.items():271 assert param_server.has_param(k)272 #print "verifying parameter %s"%k273 try:274 v2 = param_server.get_param(k)275 except:276 raise Exception("Exception raised while calling param_server.get_param(%s): %s"%(k, traceback.format_exc()))277 278 self.assertEquals(v, v2)279 param_names = my_state.keys()280 ps_param_names = param_server.get_param_names()281 assert not set(param_names) ^ set(ps_param_names), "parameter server keys do not match local: %s"%(set(param_names)^set(ps_param_names))282 # test_has_param: test has_param API283 def test_has_param(self):284 from rosmaster.paramserver import ParamDictionary285 param_server = ParamDictionary(None)286 self.failIf(param_server.has_param('/new_param'))287 param_server.set_param('/new_param', 1)288 self.assert_(param_server.has_param('/new_param'))289 # test with param in sub-namespace290 self.failIf(param_server.has_param('/sub/sub2/new_param2'))291 # - verify that parameter tree does not exist yet (#587)292 for k in ['/sub/sub2/', '/sub/sub2', '/sub/', '/sub']:293 self.failIf(param_server.has_param(k))294 param_server.set_param('/sub/sub2/new_param2', 1)295 self.assert_(param_server.has_param('/sub/sub2/new_param2'))296 # - verify that parameter tree now exists (#587)297 for k in ['/sub/sub2/', '/sub/sub2', '/sub/', '/sub']:298 self.assert_(param_server.has_param(k))299 300 ## test ^param naming, i.e. upwards-looking get access301 ## @param self302 def test_search_param(self):303 from rosmaster.paramserver import ParamDictionary304 param_server = ParamDictionary(None)305 caller_id = '/node'306 # vals are mostly identical, save some randomness. we want307 # identical structure in order to stress lookup rules308 val1 = { 'level1_p1': random.randint(0, 10000),309 'level1_p2' : { 'level2_p2': random.randint(0, 10000) }}310 val2 = { 'level1_p1': random.randint(0, 10000),311 'level1_p2' : { 'level2_p2': random.randint(0, 10000) }}312 val3 = { 'level1_p1': random.randint(0, 10000),313 'level1_p2' : { 'level2_p2': random.randint(0, 10000) }}314 val4 = { 'level1_p1': random.randint(0, 10000),315 'level1_p2' : { 'level2_p2': random.randint(0, 10000) }}316 full_dict = {}317 # test invalid input318 for k in ['', None, '~param']:319 try:320 param_server.search_param('/level1/level2', k)321 self.fail("param_server search should have failed on [%s]"%k)322 except ValueError: pass323 for ns in ['', None, 'relative', '~param']:324 try:325 param_server.search_param(ns, 'param')326 self.fail("param_server search should have failed on %s"%k)327 except ValueError: pass328 # set the val parameter at four levels so we can validate search329 330 # - set val1331 self.failIf(param_server.has_param('/level1/param'))332 self.failIf(param_server.search_param('/level1/node', 'param')) 333 param_server.set_param('/level1/param', val1)334 335 # - test param on val1336 for ns in ['/level1/node', '/level1/level2/node', '/level1/level2/level3/node']:337 self.assertEquals('/level1/param', param_server.search_param(ns, 'param'), "failed with ns[%s]"%ns)338 self.assertEquals('/level1/param/', param_server.search_param(ns, 'param/'))339 self.assertEquals('/level1/param/level1_p1', param_server.search_param(ns, 'param/level1_p1'))340 self.assertEquals('/level1/param/level1_p2/level2_p2', param_server.search_param(ns, 'param/level1_p2/level2_p2'))341 self.assertEquals(None, param_server.search_param('/root', 'param'))342 self.assertEquals(None, param_server.search_param('/root', 'param/')) 343 # - set val2344 self.failIf(param_server.has_param('/level1/level2/param'))345 param_server.set_param('/level1/level2/param', val2)346 # - test param on val2347 for ns in ['/level1/level2/node', '/level1/level2/level3/node', '/level1/level2/level3/level4/node']:348 self.assertEquals('/level1/level2/param', param_server.search_param(ns, 'param'))349 self.assertEquals('/level1/level2/param/', param_server.search_param(ns, 'param/'))350 self.assertEquals('/level1/param', param_server.search_param('/level1/node', 'param'))351 self.assertEquals('/level1/param/', param_server.search_param('/level1/node', 'param/')) 352 self.assertEquals(None, param_server.search_param('/root', 'param'))353 354 # - set val3355 self.failIf(param_server.has_param('/level1/level2/level3/param'))356 param_server.set_param('/level1/level2/level3/param', val3)357 # - test param on val3358 for ns in ['/level1/level2/level3/node', '/level1/level2/level3/level4/node']:359 self.assertEquals('/level1/level2/level3/param', param_server.search_param(ns, 'param'))360 self.assertEquals('/level1/level2/param', param_server.search_param('/level1/level2/node', 'param'))361 self.assertEquals('/level1/param', param_server.search_param('/level1/node', 'param'))362 # test subparams before we set val4 on the root363 # - test looking for param/sub_param364 self.assertEquals(None, param_server.search_param('/root', 'param'))365 self.assertEquals(None, param_server.search_param('/root', 'param/level1_p1'))366 self.assertEquals(None, param_server.search_param('/not/level1/level2/level3/level4/node', 'param/level1_p1'))367 tests = [368 ('/level1/node', '/level1/param/'),369 ('/level1/level2/', '/level1/level2/param/'),370 ('/level1/level2', '/level1/level2/param/'),371 ('/level1/level2/node', '/level1/level2/param/'),372 ('/level1/level2/notlevel3', '/level1/level2/param/'),373 ('/level1/level2/notlevel3/node', '/level1/level2/param/'),374 ('/level1/level2/level3/level4', '/level1/level2/level3/param/'),375 ('/level1/level2/level3/level4/', '/level1/level2/level3/param/'),376 ('/level1/level2/level3/level4/node', '/level1/level2/level3/param/'),377 378 ]379 for ns, pbase in tests:380 self.assertEquals(pbase+'level1_p1',381 param_server.search_param(ns, 'param/level1_p1'))382 retval = param_server.search_param(ns, 'param/level1_p2/level2_p2')383 self.assertEquals(pbase+'level1_p2/level2_p2', retval,384 "failed with ns[%s] pbase[%s]: %s"%(ns, pbase, retval))385 # - set val4 on the root386 self.failIf(param_server.has_param('/param'))387 param_server.set_param('/param', val4)388 self.assertEquals('/param', param_server.search_param('/root', 'param'))389 self.assertEquals('/param', param_server.search_param('/notlevel1/node', 'param'))390 self.assertEquals('/level1/param', param_server.search_param('/level1/node', 'param'))391 self.assertEquals('/level1/param', param_server.search_param('/level1', 'param'))392 self.assertEquals('/level1/param', param_server.search_param('/level1/', 'param'))393 # make sure that partial match works394 val5 = { 'level1_p1': random.randint(0, 10000),395 'level1_p2' : { }}396 397 self.failIf(param_server.has_param('/partial1/param'))398 param_server.set_param('/partial1/param', val5)399 self.assertEquals('/partial1/param', param_server.search_param('/partial1', 'param'))400 self.assertEquals('/partial1/param/level1_p1',401 param_server.search_param('/partial1', 'param/level1_p1'))402 # - this is the important check, should return key even if it doesn't exist yet based on stem match403 self.assertEquals('/partial1/param/non_existent',404 param_server.search_param('/partial1', 'param/non_existent'))405 self.assertEquals('/partial1/param/level1_p2/non_existent',406 param_server.search_param('/partial1', 'param/level1_p2/non_existent'))407 # test_get_param: test basic getParam behavior. Value encoding verified separately by testParamValues408 def test_get_param(self):409 from rosmaster.paramserver import ParamDictionary410 param_server = ParamDictionary(None)411 val = random.randint(0, 10000)412 full_dict = {}413 414 # very similar to has param sequence415 self.failIf(param_server.has_param('/new_param'))416 self.failIf(param_server.has_param('/new_param/')) 417 self.assertGetParamFail(param_server, '/new_param')418 param_server.set_param('/new_param', val)419 full_dict['new_param'] = val420 self.assertEquals(val, param_server.get_param('/new_param'))421 self.assertEquals(val, param_server.get_param('/new_param/'))422 # - test homonym423 self.assertEquals(val, param_server.get_param('/new_param//'))424 425 # test full get426 self.assertEquals(full_dict, param_server.get_param('/'))427 428 # test with param in sub-namespace429 val = random.randint(0, 10000) 430 self.failIf(param_server.has_param('/sub/sub2/new_param2'))431 self.assertGetParamFail(param_server, '/sub/sub2/new_param2')432 param_server.set_param('/sub/sub2/new_param2', val)433 full_dict['sub'] = {'sub2': { 'new_param2': val }}434 self.assertEquals(val, param_server.get_param('/sub/sub2/new_param2'))435 # - test homonym436 self.assertEquals(val, param_server.get_param('/sub///sub2/new_param2/'))437 438 # test full get439 self.assertEquals(full_dict, param_server.get_param('/'))440 # test that parameter server namespace-get (#587)441 val1 = random.randint(0, 10000)442 val2 = random.randint(0, 10000)443 val3 = random.randint(0, 10000)444 445 for k in ['/gains/P', '/gains/I', '/gains/D', '/gains']:446 self.assertGetParamFail(param_server, k)447 self.failIf(param_server.has_param(k))448 param_server.set_param('/gains/P', val1)449 param_server.set_param('/gains/I', val2)450 param_server.set_param('/gains/D', val3) 451 pid = {'P': val1, 'I': val2, 'D': val3}452 full_dict['gains'] = pid453 self.assertEquals(pid,454 param_server.get_param('/gains'))455 self.assertEquals(pid,456 param_server.get_param('/gains/'))457 self.assertEquals(full_dict,458 param_server.get_param('/'))459 self.failIf(param_server.has_param('/ns/gains/P'))460 self.failIf(param_server.has_param('/ns/gains/I'))461 self.failIf(param_server.has_param('/ns/gains/D'))462 self.failIf(param_server.has_param('/ns/gains'))463 464 param_server.set_param('/ns/gains/P', val1)465 param_server.set_param('/ns/gains/I', val2)466 param_server.set_param('/ns/gains/D', val3)467 full_dict['ns'] = {'gains': pid}468 469 self.assertEquals(pid,470 param_server.get_param('/ns/gains'))471 self.assertEquals({'gains': pid},472 param_server.get_param('/ns/'))473 self.assertEquals({'gains': pid},474 param_server.get_param('/ns'))475 self.assertEquals(full_dict,476 param_server.get_param('/'))477 478 479 def test_delete_param(self):480 from rosmaster.paramserver import ParamDictionary481 param_server = ParamDictionary(None)482 try:483 param_server.delete_param('/fake')484 self.fail("delete_param of non-existent should have failed")485 except: pass486 try:487 param_server.delete_param('/')488 self.fail("delete_param of root should have failed")489 except: pass490 param_server.set_param('/foo', 'foo')491 param_server.set_param('/bar', 'bar') 492 self.assert_(param_server.has_param('/foo'))493 self.assert_(param_server.has_param('/bar')) 494 param_server.delete_param('/foo')495 self.failIf(param_server.has_param('/foo'))496 # - test with trailing slash497 param_server.delete_param('/bar/')498 self.failIf(param_server.has_param('/bar'))499 # test with namespaces500 param_server.set_param("/sub/key/x", 1)501 param_server.set_param("/sub/key/y", 2)502 try:503 param_server.delete_param('/sub/key/z')504 self.fail("delete_param of non-existent should have failed")505 except: pass506 try:507 param_server.delete_param('/sub/sub2/z')508 self.fail("delete_param of non-existent should have failed")509 except: pass510 self.assert_(param_server.has_param('/sub/key/x'))511 self.assert_(param_server.has_param('/sub/key/y'))512 self.assert_(param_server.has_param('/sub/key')) 513 param_server.delete_param('/sub/key')514 self.failIf(param_server.has_param('/sub/key')) 515 self.failIf(param_server.has_param('/sub/key/x'))516 self.failIf(param_server.has_param('/sub/key/y'))517 # test with namespaces (dictionary vals)518 param_server.set_param('/sub2', {'key': { 'x' : 1, 'y' : 2}})519 self.assert_(param_server.has_param('/sub2/key/x'))520 self.assert_(param_server.has_param('/sub2/key/y'))521 self.assert_(param_server.has_param('/sub2/key')) 522 param_server.delete_param('/sub2/key')523 self.failIf(param_server.has_param('/sub2/key')) 524 self.failIf(param_server.has_param('/sub2/key/x'))525 self.failIf(param_server.has_param('/sub2/key/y'))526 # test with namespaces: treat value as if its a namespace527 # - try to get the dictionary-of-dictionary code to fail528 # by descending a value key as if it is a namespace529 param_server.set_param('/a', 'b')530 self.assert_(param_server.has_param('/a'))531 try:532 param_server.delete_param('/a/b/c')533 self.fail_("should have raised key error")534 except: pass535 536 537 # test_set_param: test basic set_param behavior. Value encoding verified separately by testParamValues538 def test_set_param(self):539 from rosmaster.paramserver import ParamDictionary540 param_server = ParamDictionary(None)541 caller_id = '/node'542 val = random.randint(0, 10000)543 # verify error behavior with root544 try:545 param_server.set_param('/', 1)546 self.fail("ParamDictionary allowed root to be set to non-dictionary")547 except: pass548 # very similar to has param sequence549 self.failIf(param_server.has_param('/new_param'))550 param_server.set_param('/new_param', val)551 self.assertEquals(val, param_server.get_param('/new_param'))552 self.assertEquals(val, param_server.get_param('/new_param/'))553 self.assert_(param_server.has_param('/new_param'))554 # test with param in sub-namespace555 val = random.randint(0, 10000) 556 self.failIf(param_server.has_param('/sub/sub2/new_param2'))557 param_server.set_param('/sub/sub2/new_param2', val)558 self.assertEquals(val, param_server.get_param('/sub/sub2/new_param2'))559 # test with param type mutation560 vals = ['a', {'a': 'b'}, 1, 1., 'foo', {'c': 'd'}, 4, {'a': {'b': 'c'}}, 3]561 for v in vals:562 param_server.set_param('/multi/multi_param', v)563 self.assertEquals(v, param_server.get_param('/multi/multi_param'))564 # - set value within subtree that mutates higher level value565 param_server.set_param('/multi2/multi_param', 1)566 self.assertEquals(1, param_server.get_param('/multi2/multi_param'))567 param_server.set_param('/multi2/multi_param/a', 2)568 self.assertEquals(2, param_server.get_param('/multi2/multi_param/a'))569 self.assertEquals({'a': 2}, param_server.get_param('/multi2/multi_param/')) 570 param_server.set_param('/multi2/multi_param/a/b', 3)571 self.assertEquals(3, param_server.get_param('/multi2/multi_param/a/b'))572 self.assertEquals({'b': 3}, param_server.get_param('/multi2/multi_param/a/'))573 self.assertEquals({'a': {'b': 3}}, param_server.get_param('/multi2/multi_param/')) 574 575 # test that parameter server namespace-set (#587)576 self.failIf(param_server.has_param('/gains/P'))577 self.failIf(param_server.has_param('/gains/I'))578 self.failIf(param_server.has_param('/gains/D')) 579 self.failIf(param_server.has_param('/gains'))580 pid = {'P': random.randint(0, 10000), 'I': random.randint(0, 10000), 'D': random.randint(0, 10000)}581 param_server.set_param('/gains', pid)582 self.assertEquals(pid, param_server.get_param('/gains'))583 self.assertEquals(pid['P'], param_server.get_param('/gains/P'))584 self.assertEquals(pid['I'], param_server.get_param('/gains/I'))585 self.assertEquals(pid['D'], param_server.get_param('/gains/D'))586 subns = {'gains1': pid, 'gains2': pid}587 param_server.set_param('/ns', subns)588 self.assertEquals(pid['P'], param_server.get_param('/ns/gains1/P'))589 self.assertEquals(pid['I'], param_server.get_param('/ns/gains1/I'))590 self.assertEquals(pid['D'], param_server.get_param('/ns/gains1/D'))591 self.assertEquals(pid, param_server.get_param('/ns/gains1'))592 self.assertEquals(pid, param_server.get_param('/ns/gains2'))593 self.assertEquals(subns, param_server.get_param('/ns/'))594 # test empty dictionary set595 param_server.set_param('/ns', {})596 # - param should still exist597 self.assert_(param_server.has_param('/ns/'))598 # - value should remain dictionary599 self.assertEquals({}, param_server.get_param('/ns/'))600 # - value2 below /ns/ should be erased601 self.failIf(param_server.has_param('/ns/gains1'))602 self.failIf(param_server.has_param('/ns/gains1/P'))603 604 # verify that root can be set and that it erases all values605 param_server.set_param('/', {})606 self.failIf(param_server.has_param('/new_param'))607 param_server.set_param('/', {'foo': 1, 'bar': 2, 'baz': {'a': 'a'}})608 self.assertEquals(1, param_server.get_param('/foo'))609 self.assertEquals(1, param_server.get_param('/foo/')) 610 self.assertEquals(2, param_server.get_param('/bar'))611 self.assertEquals(2, param_server.get_param('/bar/'))612 self.assertEquals('a', param_server.get_param('/baz/a'))613 self.assertEquals('a', param_server.get_param('/baz/a/'))614 # test_param_values: test storage of all XML-RPC compatible types"""615 def test_param_values(self):616 import math617 from rosmaster.paramserver import ParamDictionary618 param_server = ParamDictionary(None)619 test_vals = [620 ['int', [0, 1024, 2147483647, -2147483647]],621 ['boolean', [True, False]],622 #no longer testing null char623 #['string', ['', '\0', 'x', 'hello', ''.join([chr(n) for n in range(0, 255)])]],624 ['unicode-string', [u'', u'hello', u'Andr\302\202'.encode('utf-8'), u'\377\376A\000n\000d\000r\000\202\000'.encode('utf-16')]],625 ['string-easy-ascii', [chr(n) for n in range(32, 128)]],626 #['string-mean-ascii-low', [chr(n) for n in range(9, 10)]], #separate for easier book-keeping627 #['string-mean-ascii-low', [chr(n) for n in range(1, 31)]], #separate for easier book-keeping628 #['string-mean-signed', [chr(n) for n in range(129, 256)]],629 ['string', ['', 'x', 'hello-there', 'new\nline', 'tab\t']],630 ['double', [0.0, math.pi, -math.pi, 3.4028235e+38, -3.4028235e+38]],631 #TODO: microseconds?632 ['datetime', [datetime.datetime(2005, 12, 6, 12, 13, 14), datetime.datetime(1492, 12, 6, 12, 13, 14)]],633 ['array', [[], [1, 2, 3], ['a', 'b', 'c'], [0.0, 0.1, 0.2, 2.0, 2.1, -4.0],634 [1, 'a', True], [[1, 2, 3], ['a', 'b', 'c'], [1.0, 2.1, 3.2]]]635 ],636 ]637 print("Putting parameters onto the server")638 # put our params into the parameter server639 contexts = ['', 'scope1', 'scope/subscope1', 'scope/sub1/sub2']640 my_state = {}641 failures = []642 for ctx in contexts:643 self._set_param(ctx, my_state, test_vals, param_server)644 self._check_param_state(param_server, my_state)645 646 print("Deleting all of our parameters")647 # delete all of our parameters648 count = 0649 for key in list(my_state.keys()):650 count += 1651 param_server.delete_param(key)652 del my_state[key]653 # far too intensive to check every time654 if count % 50 == 0:655 self._check_param_state(param_server, my_state)656 self._check_param_state(param_server, my_state)657 def assertGetParamFail(self, param_server, param):658 try:659 param_server.get_param(param)660 self.fail("get_param[%s] did not raise KeyError"%(param))...
kernel_specs.py
Source:kernel_specs.py
1# Copyright 2014-2016 Nervana Systems Inc. All rights reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14from builtins import str15import re16import os.path17import subprocess18import pycuda.driver as drv19from pycuda.tools import context_dependent_memoize20from neon import logger as neon_logger21from neon.util.persist import get_cache_dir22# helpful for kernel development23debug = 024base_dir = os.path.dirname(__file__)25maxas_dir = os.path.join(base_dir, "kernels", "maxas")26sass_dir = os.path.join(base_dir, "kernels", "sass")27ptx_dir = get_cache_dir(['kernels', 'ptx'])28pre_dir = get_cache_dir(['kernels', 'pre'])29cubin_dir = get_cache_dir(['kernels', 'cubin'])30dump_dir = get_cache_dir(['kernels', 'dump'])31kernels = {32 "sconv_direct_fprop_128x128": {"threads": 256, "sass": "sconv_xprop_X128_N128", "params": "fprop", "share": "128*8*2 + 128*8*2 + 10", "args": {"prop": "f"}},33 "sconv_direct_bprop_128x128": {"threads": 256, "sass": "sconv_xprop_X128_N128", "params": "bprop", "share": "128*8*2 + 128*8*2 + 10", "args": {"prop": "b"}},34 "hconv_direct_fprop_128x128": {"threads": 256, "sass": "hconv_xprop_X128_N128", "params": "fprop", "share": "128*8*2 + 128*8*2 + 10", "args": {"prop": "f"}},35 "hconv_direct_bprop_128x128": {"threads": 256, "sass": "hconv_xprop_X128_N128", "params": "bprop", "share": "128*8*2 + 128*8*2 + 10", "args": {"prop": "b"}},36 "sconv_direct_fprop_64x128": {"threads": 128, "sass": "sconv_xprop_X64_N128", "params": "fprop", "share": " 64*8*2 + 128*8*2 + 10", "args": {"prop": "f"}},37 "sconv_direct_bprop_64x128": {"threads": 128, "sass": "sconv_xprop_X64_N128", "params": "bprop", "share": " 64*8*2 + 128*8*2 + 10", "args": {"prop": "b"}},38 "hconv_direct_fprop_64x128": {"threads": 128, "sass": "hconv_xprop_X64_N128", "params": "fprop", "share": " 64*8*2 + 128*8*2 + 10", "args": {"prop": "f"}},39 "hconv_direct_bprop_64x128": {"threads": 128, "sass": "hconv_xprop_X64_N128", "params": "bprop", "share": " 64*8*2 + 128*8*2 + 10", "args": {"prop": "b"}},40 "sconv_direct_fprop_32x128": {"threads": 64, "sass": "sconv_xprop_X32_N128", "params": "fprop", "share": " 32*8*2 + 128*8*2 + 10", "args": {"prop": "f"}},41 "sconv_direct_bprop_32x128": {"threads": 64, "sass": "sconv_xprop_X32_N128", "params": "bprop", "share": " 32*8*2 + 128*8*2 + 10", "args": {"prop": "b"}},42 "hconv_direct_fprop_32x128": {"threads": 64, "sass": "hconv_xprop_X32_N128", "params": "fprop", "share": " 32*8*2 + 128*8*2 + 10", "args": {"prop": "f"}},43 "hconv_direct_bprop_32x128": {"threads": 64, "sass": "hconv_xprop_X32_N128", "params": "bprop", "share": " 32*8*2 + 128*8*2 + 10", "args": {"prop": "b"}},44 "sconv_direct_fprop_128x64": {"threads": 128, "sass": "sconv_xprop_X128_N64", "params": "fprop", "share": "128*8*2 + 64*8*2 + 10", "args": {"prop": "f"}},45 "sconv_direct_bprop_128x64": {"threads": 128, "sass": "sconv_xprop_X128_N64", "params": "bprop", "share": "128*8*2 + 64*8*2 + 10", "args": {"prop": "b"}},46 "hconv_direct_fprop_128x64": {"threads": 128, "sass": "hconv_xprop_X128_N64", "params": "fprop", "share": "128*8*2 + 64*8*2 + 10", "args": {"prop": "f"}},47 "hconv_direct_bprop_128x64": {"threads": 128, "sass": "hconv_xprop_X128_N64", "params": "bprop", "share": "128*8*2 + 64*8*2 + 10", "args": {"prop": "b"}},48 "sconv_direct_fprop_64x64": {"threads": 64, "sass": "sconv_xprop_X64_N64", "params": "fprop", "share": " 64*8*2 + 64*8*2 + 10", "args": {"prop": "f"}},49 "sconv_direct_bprop_64x64": {"threads": 64, "sass": "sconv_xprop_X64_N64", "params": "bprop", "share": " 64*8*2 + 64*8*2 + 10", "args": {"prop": "b"}},50 "hconv_direct_fprop_64x64": {"threads": 64, "sass": "hconv_xprop_X64_N64", "params": "fprop", "share": " 64*8*2 + 64*8*2 + 10", "args": {"prop": "f"}},51 "hconv_direct_bprop_64x64": {"threads": 64, "sass": "hconv_xprop_X64_N64", "params": "bprop", "share": " 64*8*2 + 64*8*2 + 10", "args": {"prop": "b"}},52 "sconv_direct_fprop_64x32": {"threads": 128, "sass": "xconv_direct_xprop_64x32", "params": "fprop2", "share": "(32 + 64)*32*2 + 4", "args": {"type":"s","prop":"f"}},53 "sconv_direct_bprop_64x32": {"threads": 128, "sass": "xconv_direct_xprop_64x32", "params": "bprop2", "share": "(32 + 64)*32*2 + 4", "args": {"type":"s","prop":"b"}},54 "hconv_direct_fprop_64x32": {"threads": 128, "sass": "xconv_direct_xprop_64x32", "params": "fprop2", "share": "(32 + 64)*32*2 + 4", "args": {"type":"h","prop":"f"}},55 "hconv_direct_bprop_64x32": {"threads": 128, "sass": "xconv_direct_xprop_64x32", "params": "bprop2", "share": "(32 + 64)*32*2 + 4", "args": {"type":"h","prop":"b"}},56 "sconv_direct_updat_64x32": {"threads": 128, "sass": "xconv_direct_updat_64x32", "params": "updat2", "share": "(32 + 64)*33*2 + 8", "args": {"type": "s",}},57 "hconv_direct_updat_64x32": {"threads": 128, "sass": "xconv_direct_updat_64x32", "params": "updat2", "share": "(32 + 64)*33*2 + 8", "args": {"type": "h",}},58 "sconv_winograd_2x2_3x3_32x32": {"threads": 256, "sass": "xconv_winograd_2x2_3x3_32x32", "params": "fpropw", "share": "512*4*4", "args": {"type": "s"}},59 "hconv_winograd_2x2_3x3_32x32": {"threads": 256, "sass": "xconv_winograd_2x2_3x3_32x32", "params": "fpropw", "share": "512*4*4", "args": {"type": "h"}},60 "sconv_winograd_3x3_2x2_32x32": {"threads": 256, "sass": "xconv_winograd_3x3_2x2_32x32", "params": "updatw", "share": "(512*4 + 32)*4 + 8", "args": {"type": "s"}},61 "hconv_winograd_3x3_2x2_32x32": {"threads": 256, "sass": "xconv_winograd_3x3_2x2_32x32", "params": "updatw", "share": "(512*4 + 32)*4 + 8", "args": {"type": "h"}},62 "sconv_winograd_4x4_3x3_32x32": {"threads": 640, "sass": "xconv_winograd_4x4_3x3_32x32", "params": "fpropw4", "share": "32*36*2*4 + 64 + 8", "args": {"type": "s"}},63 "hconv_winograd_4x4_3x3_32x32": {"threads": 640, "sass": "xconv_winograd_4x4_3x3_32x32", "params": "fpropw4", "share": "32*36*2*4 + 64 + 8", "args": {"type": "h"}},64 "sconv_winograd_4x4_3x3_32x32_X": {"threads": 640, "sass": "xconv_winograd_4x4_3x3_32x32_X", "params": "fpropw4X", "share": "32*36*2*4 + 64 + 8", "args": {"type": "s"}},65 "hconv_winograd_4x4_3x3_32x32_X": {"threads": 640, "sass": "xconv_winograd_4x4_3x3_32x32_X", "params": "fpropw4X", "share": "32*36*2*4 + 64 + 8", "args": {"type": "h"}},66 "sconv_winograd_3x3_4x4_32x32": {"threads": 640, "sass": "xconv_winograd_3x3_4x4_32x32", "params": "updatw4", "share": "32*36*2*4 + 64 + 8", "args": {"type": "s"}},67 "hconv_winograd_3x3_4x4_32x32": {"threads": 640, "sass": "xconv_winograd_3x3_4x4_32x32", "params": "updatw4", "share": "32*36*2*4 + 64 + 8", "args": {"type": "h"}},68 "sconv_winograd_2x2_5x5_32x32": {"threads": 640, "sass": "xconv_winograd_2x2_5x5_32x32", "params": "fpropw5", "share": "32*36*2*4 + 64 + 8", "args": {"type": "s"}},69 "hconv_winograd_2x2_5x5_32x32": {"threads": 640, "sass": "xconv_winograd_2x2_5x5_32x32", "params": "fpropw5", "share": "32*36*2*4 + 64 + 8", "args": {"type": "h"}},70 "sgemm_nn_128x128": {"threads": 256, "sass": "sgemm_nn_128x128", "params": "gemm", "share": "128*8*2 + 128*8*2 + 4"},71 "sgemm_nt_128x128": {"threads": 256, "sass": "sgemm_nt_128x128", "params": "gemm", "share": "128*8*2 + 128*8*2 + 4"},72 "sgemm_tn_128x128": {"threads": 256, "sass": "sgemm_tn_128x128", "params": "gemm", "share": "128*8*2 + 128*8*2 + 4"},73 "hgemm_nn_128x128": {"threads": 256, "sass": "hgemm_nn_128x128", "params": "gemm", "share": "128*8*2 + 128*8*2 + 4"},74 "hgemm_nt_128x128": {"threads": 256, "sass": "hgemm_nt_128x128", "params": "gemm", "share": "128*8*2 + 128*8*2 + 4"},75 "hgemm_tn_128x128": {"threads": 256, "sass": "hgemm_tn_128x128", "params": "gemm", "share": "128*8*2 + 128*8*2 + 4"},76 "sgemm_nn_128x64": {"threads": 128, "sass": "sgemm_nn_128x64", "params": "gemm", "share": "128*8*2 + 64*8*2 + 4"},77 "sgemm_tn_128x64": {"threads": 128, "sass": "sgemm_tn_128x64", "params": "gemm", "share": "128*8*2 + 64*8*2 + 4"},78 "hgemm_nn_128x64": {"threads": 128, "sass": "hgemm_nn_128x64", "params": "gemm", "share": "128*8*2 + 64*8*2 + 4"},79 "hgemm_tn_128x64": {"threads": 128, "sass": "hgemm_tn_128x64", "params": "gemm", "share": "128*8*2 + 64*8*2 + 4"},80 "sgemm_nn_128x32": {"threads": 128, "sass": "sgemm_nn_128x32", "params": "gemm", "share": "(128*16 + 32)*2 + 32*16*2 + 4"},81 "sgemm_tn_128x32": {"threads": 128, "sass": "sgemm_tn_128x32", "params": "gemm", "share": "(128*16 + 0)*2 + 32*16*2 + 4"},82 "hgemm_nn_128x32": {"threads": 128, "sass": "hgemm_nn_128x32", "params": "gemm", "share": "(128*16 + 32)*2 + 32*16*2 + 4"},83 "hgemm_tn_128x32": {"threads": 128, "sass": "hgemm_tn_128x32", "params": "gemm", "share": "(128*16 + 0)*2 + 32*16*2 + 4"},84 "sgemm_nn_32x128": {"threads": 128, "sass": "sgemm_nn_32x128", "params": "gemm", "share": "(32*16 + 32)*2 + (128*16 + 0)*2 + 4"},85 "sgemm_nt_32x128": {"threads": 128, "sass": "sgemm_nt_32x128", "params": "gemm", "share": "(32*16 + 32)*2 + (128*16 + 32)*2 + 4"},86 "hgemm_nn_32x128": {"threads": 128, "sass": "hgemm_nn_32x128", "params": "gemm", "share": "(32*16 + 32)*2 + (128*16 + 0)*2 + 4"},87 "hgemm_nt_32x128": {"threads": 128, "sass": "hgemm_nt_32x128", "params": "gemm", "share": "(32*16 + 32)*2 + (128*16 + 32)*2 + 4"},88 "hgemm_nt_32x32": {"threads": 128, "sass": "hgemm_nt_32x32", "params": "gemm", "share": "32*65*4 + 4" },89 "hgemm_nt_16x64": {"threads": 128, "sass": "hgemm_nt_16x64", "params": "gemm", "share": "(16*64 + 32)*2 + (64*64 + 32)*2 + 4" },90 "hgemm_nn_32x64": {"threads": 128, "sass": "hgemm_nn_32x64", "params": "gemm", "share": "32*33*2 + 64*32*2 + 2048" }, #artificially limit occpancy91 "hgemm_nn_16x64": {"threads": 128, "sass": "hgemm_nn_16x64", "params": "gemm", "share": "(16*64 + 32)*2 + 64*64*2 + 4" },92 "sgemm_rnn_nn_128x32": {"threads": 128, "sass": "sgemm_nn_rnn_128x32", "params": "gemm_rnn", "share": "(128*16 + 32)*2 + 32*16*2 + 4"},93 "sgemm_rnn_nn_vec_128x32": {"threads": 128, "sass": "sgemm_nn_rnn_128x32", "params": "gemm_rnn", "share": "(128*16 + 32)*2 + 32*16*2 + 4", "args": {"vec": "1"}},94 "sgemm_rnn_bprop_tn_128x32": {"threads": 128, "sass": "sgemm_tn_rnn_bprop_128x32", "params": "gemm_rnn_bprop", "share": "(128*16 + 32)*2 + 32*16*2 + 4"},95 "sgemm_rnn_bprop_tn_vec_128x32": {"threads": 128, "sass": "sgemm_tn_rnn_bprop_128x32", "params": "gemm_rnn_bprop", "share": "(128*16 + 32)*2 + 32*16*2 + 4", "args": {"vec": "1"}},96 "persistent_rnn_fprop": {"threads": 256, "sass": "persistent_rnn_fprop", "params": "rnn_fprop", "share": "(64*48) + 4"},97 "persistent_rnn_bprop": {"threads": 256, "sass": "persistent_rnn_bprop", "params": "rnn_bprop", "share": "(64*48) + 4"},98}99_params = {100 "fprop": [101 "float* param_Sum",102 "float* param_X",103 "float* param_O",104 "float* param_I",105 "float* param_F",106 "float param_alpha",107 "float param_beta",108 "unsigned param_flags",109 "unsigned param_N",110 "unsigned param_K",111 "unsigned param_D",112 "unsigned param_H",113 "unsigned param_W",114 "unsigned param_WN",115 "unsigned param_HWN",116 "unsigned param_DHWN",117 "unsigned param_C",118 "unsigned param_KRST",119 "unsigned param_RST",120 "unsigned param_RS",121 "unsigned param_T",122 "unsigned param_R",123 "unsigned param_S",124 "unsigned param_magic_RS",125 "unsigned param_shift_RS",126 "unsigned param_magic_S",127 "unsigned param_shift_S",128 "int param_pad_d",129 "int param_pad_h",130 "int param_pad_w",131 "unsigned param_str_d",132 "unsigned param_str_h",133 "unsigned param_str_w",134 "unsigned param_dil_d",135 "unsigned param_dil_h",136 "unsigned param_dil_w",137 "unsigned param_P2",138 "unsigned param_Q",139 "unsigned param_PQk",140 "unsigned param_Qk",141 "unsigned param_k",142 "unsigned param_magic_PQk",143 "unsigned param_shift_PQk",144 "unsigned param_magic_Qk",145 "unsigned param_shift_Qk",146 "unsigned param_magic_k",147 "unsigned param_shift_k",148 "unsigned param_QN",149 "unsigned param_PQN",150 "unsigned param_MPQN",151 "unsigned param_gridN",152 "unsigned param_gridQN",153 "unsigned param_gridPQN",154 "unsigned param_gridMPQN",155 ],156 "fprop2": [157 "float* param_Sum",158 "float* param_X",159 "float* param_O",160 "float* param_I",161 "float* param_F",162 "float param_alpha",163 "float param_beta",164 "unsigned param_flags",165 "unsigned param_C",166 "unsigned param_D",167 "unsigned param_H",168 "unsigned param_W",169 "unsigned param_N",170 "unsigned param_K",171 "unsigned param_M",172 "unsigned param_P",173 "unsigned param_Q",174 "unsigned param_str_d",175 "unsigned param_str_h",176 "unsigned param_str_w",177 "int param_pad_d",178 "int param_pad_h",179 "int param_pad_w",180 "unsigned param_dil_d",181 "unsigned param_dil_h",182 "unsigned param_dil_w",183 "unsigned param_DHWN",184 "unsigned param_HWN",185 "unsigned param_WN",186 "unsigned param_MPQN",187 "unsigned param_PQN",188 "unsigned param_QN",189 "unsigned param_PQnk",190 "unsigned param_Qnk",191 "unsigned param_nk",192 "unsigned param_n",193 "unsigned param_k",194 "unsigned param_magic_PQnk",195 "unsigned param_shift_PQnk",196 "unsigned param_magic_Qnk",197 "unsigned param_shift_Qnk",198 "unsigned param_magic_nk",199 "unsigned param_shift_nk",200 "unsigned param_magic_k",201 "unsigned param_shift_k",202 "unsigned param_Km32",203 "unsigned param_K32p",204 "unsigned param_TRSK",205 "unsigned param_TRS",206 "unsigned param_RS",207 "unsigned param_S",208 "unsigned param_magic_RS",209 "unsigned param_shift_RS",210 "unsigned param_magic_S",211 "unsigned param_shift_S",212 "unsigned param_gridP2",213 "unsigned param_gridQ",214 "unsigned param_gridN",215 "unsigned param_gridQN",216 "unsigned param_gridPQN",217 "unsigned param_gridMPQN",218 "unsigned param_superM",219 "unsigned param_superP",220 "unsigned param_superQ",221 "unsigned param_superN",222 "unsigned param_shiftM",223 "unsigned param_shiftP",224 "unsigned param_shiftQ",225 "unsigned param_shiftN",226 "unsigned param_SuperM",227 "unsigned param_SuperP",228 "unsigned param_SuperQ",229 "unsigned param_SuperN",230 ],231 "updat2": [232 "float* param_F",233 "float* param_I",234 "float* param_E",235 "float param_alpha",236 "unsigned param_C",237 "unsigned param_D",238 "unsigned param_H",239 "unsigned param_W",240 "unsigned param_N",241 "unsigned param_K",242 "unsigned param_M",243 "unsigned param_P",244 "unsigned param_Q",245 "unsigned param_str_d",246 "unsigned param_str_h",247 "unsigned param_str_w",248 "int param_pad_d",249 "int param_pad_h",250 "int param_pad_w",251 "unsigned param_dil_d",252 "unsigned param_dil_h",253 "unsigned param_dil_w",254 "unsigned param_DHWN",255 "unsigned param_HWN",256 "unsigned param_WN",257 "unsigned param_MPQN16p",258 "unsigned param_MPQN",259 "unsigned param_PQN",260 "unsigned param_QN",261 "unsigned param_PQkc",262 "unsigned param_Qkc",263 "unsigned param_kc",264 "unsigned param_c",265 "unsigned param_k",266 "unsigned param_magic_PQkc",267 "unsigned param_shift_PQkc",268 "unsigned param_magic_Qkc",269 "unsigned param_shift_Qkc",270 "unsigned param_magic_kc",271 "unsigned param_shift_kc",272 "unsigned param_magic_c",273 "unsigned param_shift_c",274 "unsigned param_CRSTK",275 "unsigned param_CRST",276 "unsigned param_TRS",277 "unsigned param_RS",278 "unsigned param_S",279 "unsigned param_magic_TRS",280 "unsigned param_shift_TRS",281 "unsigned param_magic_RS",282 "unsigned param_shift_RS",283 "unsigned param_magic_S",284 "unsigned param_shift_S",285 "unsigned param_superM",286 "unsigned param_superP",287 "unsigned param_superQ",288 "unsigned param_superN",289 "unsigned param_shiftM",290 "unsigned param_shiftP",291 "unsigned param_shiftQ",292 "unsigned param_strideP",293 "unsigned param_strideQ",294 "unsigned param_stridePQ",295 "unsigned param_gridP",296 "unsigned param_gridQ",297 "unsigned param_loopX",298 "unsigned param_loopXp",299 "unsigned param_loopQ",300 "unsigned param_loopQp",301 "unsigned param_loopN",302 "unsigned param_loopNp",303 ],304 "gemm": [305 "float* param_C",306 "float* param_A",307 "float* param_B",308 "float param_alpha",309 "float param_beta",310 "unsigned param_flags",311 "unsigned param_lda",312 "unsigned param_ldb",313 "unsigned param_ldc",314 "unsigned param_m",315 "unsigned param_n",316 "unsigned param_k",317 "unsigned param_ldaz",318 "unsigned param_ldbz",319 "unsigned param_ldcz",320 "unsigned param_batch_loops",321 ],322 "gemm_rnn": [323 "float* param_C",324 "float* param_A",325 "float* param_B",326 "float* param_bias",327 "float* param_lock",328 "float param_alpha",329 "float param_beta",330 "float param_xcutoff",331 "int param_flags",332 "int param_lda",333 "int param_ldb",334 "int param_ldc",335 "int param_m",336 "int param_n",337 "int param_k",338 "int param_ldaz",339 "int param_ldbz",340 "int param_ldcz",341 "int param_batch_loops",342 "int param_dimB",343 "int param_dimC",344 "int param_unrolling",345 "int param_numBlks",346 "int param_numAblks"347 ],348 "gemm_rnn_bprop": [349 "float* param_C",350 "float* param_A",351 "float* param_B",352 "float* param_H",353 "float* param_lock",354 "float param_alpha",355 "float param_beta",356 "float param_xcutoff",357 "int param_flags",358 "int param_lda",359 "int param_ldb",360 "int param_ldc",361 "int param_ldh",362 "int param_m",363 "int param_n",364 "int param_k",365 "int param_ldaz",366 "int param_ldbz",367 "int param_ldcz",368 "int param_batch_loops",369 "int param_dimB",370 "int param_dimC",371 "int param_dimH",372 "int param_unrolling",373 "int param_numBlks",374 "int param_numAblks"375 ],376 "fpropw": [377 "float* param_S",378 "float* param_X",379 "float* param_O",380 "float* param_I",381 "float* param_F",382 "float param_alpha",383 "float param_beta",384 "unsigned param_flags",385 "unsigned param_C",386 "unsigned param_H",387 "unsigned param_P",388 "int param_pad_h",389 "int param_pad_w",390 "unsigned param_HWN",391 "unsigned param_WN",392 "unsigned param_PQN",393 "unsigned param_QN",394 "unsigned param_Qnk",395 "unsigned param_nk",396 "unsigned param_n",397 "unsigned param_k",398 "unsigned param_magic_Qnk",399 "unsigned param_shift_Qnk",400 "unsigned param_magic_nk",401 "unsigned param_shift_nk",402 "unsigned param_magic_k",403 "unsigned param_shift_k",404 "unsigned param_RSK",405 "unsigned param_4RSKp",406 "unsigned param_4HWNp",407 "unsigned param_gridK",408 "unsigned param_gridP2",409 "unsigned param_gridQ",410 "unsigned param_gridN",411 "unsigned param_gridQN",412 "unsigned param_gridPQN",413 "unsigned param_superP",414 "unsigned param_superQ",415 "unsigned param_superN",416 "unsigned param_shiftP",417 "unsigned param_shiftQ",418 "unsigned param_shiftN",419 ],420 "fpropw4X": [421 "float* param_S",422 "float* param_X",423 "float* param_O",424 "float* param_I",425 "float* param_F",426 "float param_alpha",427 "float param_beta",428 "unsigned param_flags",429 "unsigned param_C",430 "unsigned param_K",431 "unsigned param_N",432 "unsigned param_Xk",433 "unsigned param_k",434 "unsigned param_magic_Xk",435 "unsigned param_shift_Xk",436 "unsigned param_magic_k",437 "unsigned param_shift_k",438 "unsigned param_C_1152",439 "unsigned param_GXS_C_1152",440 "unsigned param_GYS_GXS_C_1152",441 "unsigned param_P",442 "unsigned param_Q",443 "unsigned param_QN",444 "unsigned param_PQN",445 "unsigned param_PQN15",446 "unsigned param_maskN",447 "unsigned param_shiftX",448 "unsigned param_shiftY",449 "unsigned param_superX",450 "unsigned param_superY",451 "unsigned param_gridN",452 "unsigned param_gridQN",453 "unsigned param_gridPQN",454 ],455 "fpropw4": [456 "float* param_S",457 "float* param_X",458 "float* param_O",459 "float* param_I",460 "float* param_F",461 "float param_alpha",462 "float param_beta",463 "unsigned param_flags",464 "unsigned param_C",465 "unsigned param_K",466 "unsigned param_N",467 "unsigned param_Y",468 "unsigned param_W",469 "unsigned param_YXN",470 "unsigned param_XN",471 "unsigned param_Y2",472 "unsigned param_GX",473 "unsigned param_Xk",474 "unsigned param_k",475 "unsigned param_magic_Xk",476 "unsigned param_shift_Xk",477 "unsigned param_magic_k",478 "unsigned param_shift_k",479 "unsigned param_P",480 "unsigned param_Q",481 "unsigned param_QN",482 "unsigned param_PQN",483 "unsigned param_PQN15",484 "unsigned param_maskN",485 "unsigned param_shiftX",486 "unsigned param_shiftY",487 "unsigned param_superX",488 "unsigned param_superY",489 "int param_pad_x",490 "int param_pad_y",491 "unsigned param_RSK",492 "unsigned param_RSK2p",493 "unsigned param_YXN2p",494 "unsigned param_gridN",495 "unsigned param_gridQN",496 "unsigned param_gridPQN",497 ],498 "fpropw5": [499 "float* param_O",500 "float* param_I",501 "float* param_F",502 "float param_alpha",503 "unsigned param_flags",504 "unsigned param_C",505 "unsigned param_K",506 "unsigned param_N",507 "unsigned param_H",508 "unsigned param_W",509 "unsigned param_HWN",510 "unsigned param_WN",511 "unsigned param_Y2",512 "unsigned param_GX",513 "unsigned param_Xk",514 "unsigned param_k",515 "unsigned param_magic_Xk",516 "unsigned param_shift_Xk",517 "unsigned param_magic_k",518 "unsigned param_shift_k",519 "unsigned param_P",520 "unsigned param_Q",521 "unsigned param_QN",522 "unsigned param_PQN",523 "unsigned param_PQNp",524 "unsigned param_PQN15p",525 "unsigned param_shiftY",526 "unsigned param_shiftX",527 "unsigned param_shiftN",528 "unsigned param_superY",529 "unsigned param_superX",530 "unsigned param_superN",531 "unsigned param_SuperY",532 "unsigned param_SuperX",533 "unsigned param_SuperN",534 "int param_pad_x",535 "int param_pad_y",536 "unsigned param_HWN2p",537 "unsigned param_C_1152",538 ],539 "updatw": [540 "float* param_F",541 "float* param_I",542 "float* param_E",543 "float param_alpha",544 "unsigned param_Y",545 "unsigned param_X",546 "unsigned param_P",547 "unsigned param_Q",548 "unsigned param_C",549 "unsigned param_K",550 "unsigned param_N",551 "int param_pad_y",552 "int param_pad_x",553 "unsigned param_GY",554 "unsigned param_GX",555 "unsigned param_GYS",556 "unsigned param_GXS",557 "unsigned param_shiftYI",558 "unsigned param_shiftXI",559 "unsigned param_superYI",560 "unsigned param_superXI",561 "unsigned param_superNI",562 "unsigned param_shiftY",563 "unsigned param_shiftX",564 "unsigned param_superY",565 "unsigned param_superX",566 "unsigned param_superN",567 "unsigned param_loopXI",568 "unsigned param_loopX",569 "unsigned param_loopN",570 "unsigned param_strideY",571 "unsigned param_strideX",572 "unsigned param_XN",573 "unsigned param_YXN",574 "unsigned param_QN",575 "unsigned param_PQN",576 "unsigned param_SK",577 "unsigned param_RSK",578 "unsigned param_Np",579 "unsigned param_XNp",580 "unsigned param_2XNp",581 "unsigned param_QNp",582 "unsigned param_CPQkc",583 "unsigned param_PQkc",584 "unsigned param_Qkc",585 "unsigned param_kc",586 "unsigned param_c",587 "unsigned param_k",588 "unsigned param_magic_CPQkc",589 "unsigned param_shift_CPQkc",590 "unsigned param_magic_PQkc",591 "unsigned param_shift_PQkc",592 "unsigned param_magic_Qkc",593 "unsigned param_shift_Qkc",594 "unsigned param_magic_kc",595 "unsigned param_shift_kc",596 "unsigned param_magic_c",597 "unsigned param_shift_c",598 "unsigned param_CRSK",599 ],600 "updatw4": [601 "float* param_F",602 "float* param_I",603 "float* param_E",604 "float param_alpha",605 "unsigned param_K",606 "unsigned param_C",607 "unsigned param_k",608 "unsigned param_c",609 "unsigned param_kc",610 "unsigned param_magic_kc",611 "unsigned param_shift_kc",612 "unsigned param_magic_c",613 "unsigned param_shift_c",614 "unsigned param_YXN2",615 "unsigned param_sYXN",616 "unsigned param_magic_sYXN",617 "unsigned param_shift_sYXN",618 "unsigned param_stride_YXNp",619 "unsigned param_YXN",620 "unsigned param_YXN_1152",621 "unsigned param_RSK",622 "unsigned param_CRSK",623 "unsigned param_Kp",624 "unsigned param_SKp",625 "unsigned param_RSK15_SK2p",626 ],627 "rnn_fprop": [628 "float* param_h",629 "float* param_hprev",630 "float* param_bias",631 "float* param_w",632 "int* param_lockAddr",633 "int param_ldh",634 "int param_ldw",635 "int param_bsz",636 "int param_seqLength",637 "int param_numBlks",638 "int param_rowSize",639 "int param_reverse",640 "float param_reluclip"641 ]642 ,643 "rnn_bprop": [644 "float* param_d",645 "float* param_dnext",646 "float* param_h",647 "float* param_w",648 "int* param_lockAddr",649 "int param_ldd",650 "int param_ldh",651 "int param_ldw",652 "int param_bsz",653 "int param_seqLength",654 "int param_numBlks",655 "int param_rowSize",656 "int param_reverse",657 "float param_reluclip"658 ]659}660_params["bprop"] = _params["fprop"] + [661 "unsigned param_magic_str_d",662 "unsigned param_shift_str_d",663 "unsigned param_magic_str_h",664 "unsigned param_shift_str_h",665 "unsigned param_magic_str_w",666 "unsigned param_shift_str_w",667 ]668_params["bprop2"] = _params["fprop2"] + [669 "unsigned param_magic_str_d",670 "unsigned param_shift_str_d",671 "unsigned param_magic_str_h",672 "unsigned param_shift_str_h",673 "unsigned param_magic_str_w",674 "unsigned param_shift_str_w",675 ]676_space_re = re.compile(r"\s+")677_share_template = r"""678 .shared .align 4 .b32 share[{0}];679"""680_kernel_template = r"""681.version {6}682.target {0}683.address_size 64684// args: {5}685.visible .entry {1}(686{2}687)688.reqntid {3}689{{690{4}691 ret;692}}693"""694def get_ptx_file(kernel_spec, kernel_name, arch, ptx_ver):695 thread_spec = kernel_spec["threads"]696 args_spec = str(kernel_spec.get("args",""))697 param_spec = _params[kernel_spec["params"]]698 kernel_params = []699 for p in param_spec:700 ptype, pname = _space_re.split(p)701 if ptype[-1] == '*':702 ptype = '.u64'703 elif ptype == 'float':704 ptype = '.f32'705 else:706 ptype = '.u32'707 kernel_params.append(" .param %s %s" % (ptype, pname))708 kernel_params = ",\n".join(kernel_params)709 if "share" in kernel_spec:710 share = _share_template.format(eval(kernel_spec["share"]))711 else:712 share = ""713 kernel_text = _kernel_template.format(arch, kernel_name, kernel_params, thread_spec, share, args_spec, ptx_ver)714 kernel_ptx = os.path.join(ptx_dir, kernel_name + ".ptx")715 current_text = ""716 if os.path.exists(kernel_ptx):717 f = open(kernel_ptx, "r")718 current_text = f.read()719 f.close()720 # only write out the kernel if text has changed.721 if kernel_text != current_text:722 f = open(kernel_ptx, "w")723 f.write(kernel_text)724 f.close()725 return kernel_ptx726include_re = re.compile(r'^<INCLUDE\s+file="([^"]+)"\s*/>')727def extract_includes(name, includes=None):728 if not includes:729 includes = list()730 sass_file = os.path.join(sass_dir, name)731 includes.append((sass_file, os.path.getmtime(sass_file)))732 for line in open(sass_file, "r"):733 match = include_re.search(line)734 if match:735 extract_includes(match.group(1), includes)736 return includes737def run_command(cmdlist):738 cmd = " ".join(cmdlist)739 proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)740 out, err = proc.communicate()741 if proc.returncode:742 raise RuntimeError("Error(%d):\n%s\n%s" % (proc.returncode, cmd, err))743 if debug:744 neon_logger.display(cmd)745 if out: neon_logger.display(out)746 if err: neon_logger.display(err)747@context_dependent_memoize748def get_kernel(base_name, options=None):749 attributes = drv.Context.get_device().get_attributes()750 major = attributes[drv.device_attribute.COMPUTE_CAPABILITY_MAJOR]751 minor = attributes[drv.device_attribute.COMPUTE_CAPABILITY_MINOR]752 if major < 5:753 raise RuntimeError("sass kernels require Maxwell or greater class hardware")754 arch = "sm_%d%d" % (major, minor)755 libprefix = "PERL5LIB=%s" % (maxas_dir)756 maxas_i = [libprefix, os.path.join(maxas_dir, "maxas.pl") + " -i -w"]757 maxas_p = [libprefix, os.path.join(maxas_dir, "maxas.pl") + " -p"]758 kernel_spec = kernels[base_name]759 kernel_name = base_name760 if "args" in kernel_spec:761 for pair in kernel_spec["args"].items():762 maxas_i.append("-D%s %s" % pair)763 maxas_p.append("-D%s %s" % pair)764 if options is not None:765 for opt in options:766 if type(opt) is tuple:767 maxas_i.append("-D%s %s" % opt)768 maxas_p.append("-D%s %s" % opt)769 kernel_name += "_%s%s" % opt770 else:771 maxas_i.append("-D%s 1" % opt)772 maxas_p.append("-D%s 1" % opt)773 kernel_name += "_%s" % opt774 maxas_i.insert(2, "-k " + kernel_name)775 sass_name = kernel_spec["sass"] + ".sass"776 cubin_name = kernel_name + ".cubin"777 ptx_version = "4.2" if major < 6 else "5.0"778 ptx_file = get_ptx_file(kernel_spec, kernel_name, arch, ptx_version)779 sass_file = os.path.join(sass_dir, sass_name)780 cubin_file = os.path.join(cubin_dir, cubin_name)781 if not os.path.exists(sass_file):782 raise RuntimeError("Missing: %s for kernel: %s" % (sass_name, kernel_name))783 ptx_age = os.path.getmtime(ptx_file)784 cubin_age = os.path.getmtime(cubin_file) if os.path.exists(cubin_file) else 0785 if ptx_age > cubin_age:786 run_command([ "ptxas -v -arch", arch, "-o", cubin_file, ptx_file ])787 cubin_age = 0788 includes = extract_includes(sass_name)789 for include, include_age in includes:790 if include_age > cubin_age:791 run_command(maxas_i + [sass_file, cubin_file])792 cubin_age = include_age793 break794 if debug:795 pre_file = os.path.join(pre_dir, kernel_name + "_pre.sass")796 dump_file = os.path.join(dump_dir, kernel_name + "_dump.sass")797 pre_age = os.path.getmtime(pre_file) if os.path.exists(pre_file) else 0798 dump_age = os.path.getmtime(dump_file) if os.path.exists(dump_file) else 0799 for include, include_age in includes:800 if include_age > pre_age:801 run_command(maxas_p + [sass_file, pre_file])802 break803 if cubin_age > dump_age:804 run_command(["nvdisasm -raw", cubin_file, ">", dump_file])805 params = _params[kernel_spec["params"]]806 sig = ""807 for p in params:808 ptype, pname = _space_re.split(p)809 if ptype[-1] == '*':810 sig += "Q"811 elif ptype == 'float':812 sig += "f"813 elif ptype == 'unsigned':814 sig += "I"815 else:816 sig += "i"817 module = drv.module_from_file(os.path.join(cubin_dir, kernel_name + ".cubin"))818 func = module.get_function(kernel_name)819 func.prepare(sig)820 func.threads = kernel_spec["threads"]...
_parameters_auto.py
Source:_parameters_auto.py
1# --------------------------------------------------------------------------2# File: _internal/_parameters_auto.py3# ---------------------------------------------------------------------------4# Licensed Materials - Property of IBM5# 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y556# Copyright IBM Corporation 2008, 2011. All Rights Reserved.7#8# US Government Users Restricted Rights - Use, duplication or9# disclosure restricted by GSA ADP Schedule Contract with10# IBM Corp.11# ------------------------------------------------------------------------12from cplex._internal._constants import *13SimplexLimitIterations = [ CPX_PARAM_ITLIM , "upper limit on primal and dual simplex iterations " ]14SimplexLimitLowerObj = [ CPX_PARAM_OBJLLIM , "lower limit on value of objective " ]15SimplexLimitPerturbation = [ CPX_PARAM_PERLIM , "upper limit on iterations with no progress :\n 0 = automatic\n >0 = user specified limit" ]16SimplexLimitSingularity = [ CPX_PARAM_SINGLIM , "upper limit on repaired singularities " ]17SimplexLimitUpperObj = [ CPX_PARAM_OBJULIM , "upper limit on value of objective " ]18NetworkToleranceFeasibility = [ CPX_PARAM_NETEPRHS , "feasibility tolerance " ]19NetworkToleranceOptimality = [ CPX_PARAM_NETEPOPT , "reduced cost optimality tolerance " ]20EmphasisMemory = [ CPX_PARAM_MEMORYEMPHASIS , "reduced memory emphasis " ]21EmphasisMIP = [ CPX_PARAM_MIPEMPHASIS , "emphasis for MIP optimization :\n 0 = balance optimality and integer feasibility\n 1 = integer feasibility\n 2 = optimality\n 3 = moving best bound\n 4 = finding hidden feasible solutions" ]22EmphasisNumerical = [ CPX_PARAM_NUMERICALEMPHASIS , "extreme numerical caution emphasis " ]23BarrierLimitCorrections = [ CPX_PARAM_BARMAXCOR , "maximum correction limit :\n -1 = automatically determined\n 0 = none\n >0 = maximum correction limit" ]24BarrierLimitGrowth = [ CPX_PARAM_BARGROWTH , "factor used to determine unbounded optimal face " ]25BarrierLimitIteration = [ CPX_PARAM_BARITLIM , "barrier iteration limit " ]26BarrierLimitObjRange = [ CPX_PARAM_BAROBJRNG , "barrier objective range " ]27BarrierAlgorithm = [ CPX_PARAM_BARALG , "barrier algorithm choice :\n 0 = default\n 1 = infeasibility - estimate start\n 2 = infeasibility - constant start\n 3 = standard barrier" ]28BarrierColNonzeros = [ CPX_PARAM_BARCOLNZ , "minimum number of entries to consider a column dense :\n 0 = dynamically calculated\n >0 = specific number of column entries" ]29BarrierConvergeTol = [ CPX_PARAM_BAREPCOMP , "tolerance on complementarity for convergence " ]30BarrierCrossover = [ CPX_PARAM_BARCROSSALG , "barrier crossover choice :\n -1 = no crossover\n 0 = automatic\n 1 = primal crossover\n 2 = dual crossover" ]31BarrierDisplay = [ CPX_PARAM_BARDISPLAY , "barrier display level :\n 0 = no display\n 1 = display normal information\n 2 = display detailed (diagnostic) output" ]32BarrierOrdering = [ CPX_PARAM_BARORDER , "barrier ordering algorithm :\n 0 = automatic\n 1 = approximate minimum degree\n 2 = approximate minimum fill\n 3 = nested dissection" ]33BarrierQCPConvergeTol = [ CPX_PARAM_BARQCPEPCOMP , "tolerance on complementarity for QCP convergence " ]34BarrierStartAlg = [ CPX_PARAM_BARSTARTALG , "barrier starting point algorithm :\n 1 = dual is 0\n 2 = estimate dual\n 3 = primal avg, dual is 0\n 4 = primal avg, dual estimate" ]35TuneDisplay = [ CPX_PARAM_TUNINGDISPLAY , "level of the tuning display :\n 0 = no display\n 1 = minimal display\n 2 = display settings being tried\n 3 = display settings and logs" ]36TuneMeasure = [ CPX_PARAM_TUNINGMEASURE , "method used to compare across multiple problems :\n 1 = average\n 2 = minmax" ]37TuneRepeat = [ CPX_PARAM_TUNINGREPEAT , "number of times to permute the model and repeat " ]38TuneTimeLimit = [ CPX_PARAM_TUNINGTILIM , "time limit per model and per test setting " ]39FeasoptMode = [ CPX_PARAM_FEASOPTMODE , "relaxation measure :\n 0 = find minimum-sum relaxation\n 1 = find optimal minimum-sum relaxation\n 2 = find minimum number of relaxations\n 3 = find optimal relaxation with minimum number of relaxations\n 4 = find minimum quadratic-sum relaxation\n 5 = find optimal minimum quadratic-sum relaxation" ]40FeasoptTolerance = [ CPX_PARAM_EPRELAX , "minimum amount of accepted relaxation " ]41ConflictDisplay = [ CPX_PARAM_CONFLICTDISPLAY , "level of conflict display :\n 0 = no display\n 1 = summary display\n 2 = display every model being solved" ]42SiftingAlgorithm = [ CPX_PARAM_SIFTALG , "algorithm used to solve sifting subproblems :\n 0 = automatic\n 1 = primal simplex\n 2 = dual simplex\n 3 = network simplex\n 4 = barrier" ]43SiftingDisplay = [ CPX_PARAM_SIFTDISPLAY , "level of sifting iteration display :\n 0 = no display\n 1 = display major sifting iterations\n 2 = display work LP logs" ]44SiftingIterations = [ CPX_PARAM_SIFTITLIM , "sifting iteration limit " ]45SimplexToleranceFeasibility = [ CPX_PARAM_EPRHS , "feasibility tolerance " ]46SimplexToleranceMarkowitz = [ CPX_PARAM_EPMRK , "Markowitz threshold tolerance " ]47SimplexToleranceOptimality = [ CPX_PARAM_EPOPT , "reduced cost optimality tolerance " ]48NetworkDisplay = [ CPX_PARAM_NETDISPLAY , "level of network iteration display :\n 0 = no display\n 1 = display true objective values\n 2 = display penalized objective values" ]49NetworkIterations = [ CPX_PARAM_NETITLIM , "network simplex iteration limit " ]50NetworkNetFind = [ CPX_PARAM_NETFIND , "level of network extraction :\n 1 = natural network only\n 2 = reflection scaling\n 3 = general scaling " ]51NetworkPricing = [ CPX_PARAM_NETPPRIIND , "pricing strategy index :\n 0 = let cplex select pricing strategy\n 1 = partial pricing\n 2 = multiple partial pricing (no sorting)\n 3 = multiple partial pricing (with sorting)" ]52SimplexCrash = [ CPX_PARAM_CRAIND , "type of crash used :\n LP primal: 0 = ignore objective coefficients during crash\n 1 or -1 = alternate ways of using objective coefficients\n LP dual: 1 = default starting basis\n 0 or -1 = aggressive starting basis\n QP primal: -1 = slack basis\n 0 = ignore Q terms and use LP solver for crash\n 1 = ignore objective and use LP solver for crash\n QP dual: -1 = slack basis\n 0 or 1 = use Q terms for crash" ]53SimplexDGradient = [ CPX_PARAM_DPRIIND , "type of dual gradient used in pricing :\n 0 = determined automatically\n 1 = standard dual pricing\n 2 = steepest-edge pricing\n 3 = steepest-edge pricing in slack space\n 4 = steepest-edge pricing, unit initial norms\n 5 = devex pricing" ]54SimplexDisplay = [ CPX_PARAM_SIMDISPLAY , "level of the iteration display :\n 0 = no display\n 1 = display after refactorization\n 2 = display every iteration" ]55SimplexPGradient = [ CPX_PARAM_PPRIIND , "type of primal gradient used in pricing :\n-1 = reduced-cost pricing\n 0 = hybrid reduced-cost and devex pricing\n 1 = devex pricing\n 2 = steepest-edge pricing\n 3 = steepest-edge pricing, 1 initial norms\n 4 = full pricing" ]56SimplexPricing = [ CPX_PARAM_PRICELIM , "size of the pricing candidate list " ]57SimplexRefactor = [ CPX_PARAM_REINV , "refactorization interval " ]58PresolveAggregator = [ CPX_PARAM_AGGIND , "limit on aggregator applications :\n -1 = automatic (1 for LP, infinite for MIP)\n 0 = none\n >0 = aggregator application limit" ]59PresolveBoundStrength = [ CPX_PARAM_BNDSTRENIND , "type of bound strengthening :\n -1 = automatic\n 0 = off\n 1 = on" ]60PresolveCoeffReduce = [ CPX_PARAM_COEREDIND , "level of coefficient reduction :\n -1 = automatic\n 0 = none\n 1 = reduce only to integral coefficients\n 2 = reduce any potential coefficient\n 3 = aggressive reduction with tilting" ]61PresolveDependency = [ CPX_PARAM_DEPIND , "indicator for dependency checker :\n -1 = automatic\n 0 = off\n 1 = at beginning\n 2 = at end\n 3 = at both beginning and end" ]62PresolveDual = [ CPX_PARAM_PREDUAL , "take dual :\n -1 = no\n 0 = automatic\n 1 = yes" ]63PresolveFill = [ CPX_PARAM_AGGFILL , "limit on fill in aggregation " ]64PresolveLinear = [ CPX_PARAM_PRELINEAR , "indicator for linear reductions :\n 0 = only linear reductions\n 1 = full reductions" ]65PresolveNumPass = [ CPX_PARAM_PREPASS , "limit on presolve applications :\n -1 = automatic\n 0 = none\n >0 = presolve application limit" ]66PresolvePresolve = [ CPX_PARAM_PREIND , "indicator for using presolve " ]67PresolveQPMakePSD = [ CPX_PARAM_QPMAKEPSDIND , "indicator for making binary qp psd or tighter " ]68PresolveReduce = [ CPX_PARAM_REDUCE , "type of primal and dual reductions :\n 0 = no primal and dual reductions\n 1 = only primal reductions\n 2 = only dual reductions\n 3 = both primal and dual reductions" ]69PresolveRelax = [ CPX_PARAM_RELAXPREIND , "indicator for additional presolve of LP relaxation of MIP :\n -1 = automatic\n 0 = off\n 1 = on" ]70PresolveRepeatPresolve = [ CPX_PARAM_REPEATPRESOLVE , "MIP repeat presolve indicator :\n -1 = automatic\n 0 = off\n 1 = repeat presolve without cuts\n 2 = repeat presolve with cuts\n 3 = repeat presolve with cuts and allow new root cuts" ]71PresolveSymmetry = [ CPX_PARAM_SYMMETRY , "indicator for symmetric reductions :\n -1 = automatic\n 0 = off\n 1-5 = increasing aggressive levels" ]72PolishingAbsMIPGap = [ CPX_PARAM_POLISHAFTEREPAGAP , "absolute MIP gap after which to start solution polishing " ]73PolishingMIPGap = [ CPX_PARAM_POLISHAFTEREPGAP , "relative MIP gap after which to start solution polishing " ]74PolishingNodes = [ CPX_PARAM_POLISHAFTERNODE , "node count after which to start solution polishing " ]75PolishingSolutions = [ CPX_PARAM_POLISHAFTERINTSOL , "solution count after which to start solution polishing " ]76PolishingTime = [ CPX_PARAM_POLISHAFTERTIME , "time after which to start solution polishing " ]77MIPSolutionAbsGap = [ CPX_PARAM_SOLNPOOLAGAP , "absolute objective gap " ]78MIPSolutionCapacity = [ CPX_PARAM_SOLNPOOLCAPACITY , "capacity of solution pool " ]79MIPSolutionIntensity = [ CPX_PARAM_SOLNPOOLINTENSITY , "intensity for populating the MIP solution pool :\n 0 = automatic\n 1 = mild: generate few solutions quickly\n 2 = moderate: generate a larger number of solutions\n 3 = aggressive: generate many solutions and expect performance penalty\n 4 = very aggressive: enumerate all practical solutions" ]80MIPSolutionRelGap = [ CPX_PARAM_SOLNPOOLGAP , "relative objective gap " ]81MIPSolutionReplace = [ CPX_PARAM_SOLNPOOLREPLACE , "solution pool replacement strategy :\n 0 = replace oldest solutions\n 1 = replace solutions with worst objective\n 2 = replace least diverse solutions" ]82MIPCutCliques = [ CPX_PARAM_CLIQUES , "type of clique cut generation :\n -1 = do not generate\n 0 = automatic\n 1 = moderate\n 2 = aggressive\n 3 = very aggressive" ]83MIPCutCovers = [ CPX_PARAM_COVERS , "type of cover cut generation :\n -1 = do not generate\n 0 = automatic\n 1 = moderate\n 2 = aggressive\n 3 = very aggressive" ]84MIPCutDisjunctive = [ CPX_PARAM_DISJCUTS , "type of disjunctive cut generation :\n -1 = do not generate\n 0 = automatic\n 1 = moderate\n 2 = aggressive\n 3 = very aggressive" ]85MIPCutFlowCovers = [ CPX_PARAM_FLOWCOVERS , "type of flow cover cut generation :\n -1 = do not generate\n 0 = automatic\n 1 = moderate\n 2 = aggressive" ]86MIPCutGomory = [ CPX_PARAM_FRACCUTS , "type of Gomory fractional cut generation :\n -1 = do not generate\n 0 = automatic\n 1 = moderate\n 2 = aggressive" ]87MIPCutGUBCovers = [ CPX_PARAM_GUBCOVERS , "type of GUB cover cut generation :\n -1 = do not generate\n 0 = automatic\n 1 = moderate\n 2 = aggressive" ]88MIPCutImplied = [ CPX_PARAM_IMPLBD , "type of implied bound cut generation :\n -1 = do not generate\n 0 = automatic\n 1 = moderate\n 2 = aggressive" ]89MIPCutMCFCut = [ CPX_PARAM_MCFCUTS , "type of MCF cut generation :\n -1 = do not generate\n 0 = automatic\n 1 = moderate\n 2 = aggressive" ]90MIPCutMIRCut = [ CPX_PARAM_MIRCUTS , "type of mixed integer rounding cut generation :\n -1 = do not generate\n 0 = automatic\n 1 = moderate\n 2 = aggressive" ]91MIPCutPathCut = [ CPX_PARAM_FLOWPATHS , "type of flow path cut generation :\n -1 = do not generate\n 0 = automatic\n 1 = moderate\n 2 = aggressive" ]92MIPCutZeroHalfCut = [ CPX_PARAM_ZEROHALFCUTS , "type of zero-half cut generation :\n -1 = do not generate\n 0 = automatic\n 1 = moderate\n 2 = aggressive" ]93MIPToleranceAbsMIPGap = [ CPX_PARAM_EPAGAP , "absolute mixed integer optimality gap tolerance " ]94MIPToleranceIntegrality = [ CPX_PARAM_EPINT , "integrality tolerance " ]95MIPToleranceLowerCutoff = [ CPX_PARAM_CUTLO , "lower objective cutoff " ]96MIPToleranceMIPGap = [ CPX_PARAM_EPGAP , "mixed integer optimality gap tolerance " ]97MIPToleranceObjDifference = [ CPX_PARAM_OBJDIF , "absolute amount successive objective values should differ " ]98MIPToleranceRelObjDifference = [ CPX_PARAM_RELOBJDIF , "relative amount successive objective values should differ " ]99MIPToleranceUpperCutoff = [ CPX_PARAM_CUTUP , "upper objective cutoff " ]100MIPStrategyBacktrack = [ CPX_PARAM_BTTOL , "factor for backtracking, lower values give more " ]101MIPStrategyBBInterval = [ CPX_PARAM_BBINTERVAL , "interval to select best bound node " ]102MIPStrategyBranch = [ CPX_PARAM_BRDIR , "direction of first branch :\n -1 = down branch first\n 0 = automatic\n 1 = up branch first " ]103MIPStrategyDive = [ CPX_PARAM_DIVETYPE , "dive strategy :\n 0 = automatic\n 1 = traditional dive\n 2 = probing dive\n 3 = guided dive " ]104MIPStrategyFile = [ CPX_PARAM_NODEFILEIND , "file for node storage when tree memory limit reached :\n 0 = no node file\n 1 = node file in memory and compressed" ]105MIPStrategyFile = [ CPX_PARAM_NODEFILEIND , "file for node storage when tree memory limit reached :\n 0 = no node file\n 1 = node file in memory and compressed\n 2 = node file on disk\n 3 = node file on disk and compressed" ]106MIPStrategyFPHeur = [ CPX_PARAM_FPHEUR , "feasibility pump heuristic :\n -1 = none\n 0 = automatic\n 1 = feasibility\n 2 = objective and feasibility" ]107MIPStrategyHeuristicFreq = [ CPX_PARAM_HEURFREQ , "frequency to apply periodic heuristic algorithm :\n -1 = none\n 0 = automatic\n positive values at this frequency" ]108MIPStrategyKappaStats = [ CPX_PARAM_MIPKAPPASTATS , "strategy to gather statistics on the kappa of subproblems :\n -1 = never\n 0 = automatic\n 1 = sample\n 2 = always" ]109MIPStrategyLBHeur = [ CPX_PARAM_LBHEUR , "indicator for local branching heuristic " ]110MIPStrategyMIQCPStrat = [ CPX_PARAM_MIQCPSTRAT , "MIQCP strategy :\n 0 = automatic\n 1 = solve QCP relaxation at each node\n 2 = solve LP relaxation at each node" ]111MIPStrategyNodeSelect = [ CPX_PARAM_NODESEL , "node selection strategy :\n 0 = depth-first search\n 1 = best-bound search\n 2 = best-estimate search\n 3 = alternate best-estimate search" ]112MIPStrategyOrder = [ CPX_PARAM_MIPORDIND , "indicator for using priority order " ]113MIPStrategyPresolveNode = [ CPX_PARAM_PRESLVND , "node presolve :\n -1 = no node presolve\n 0 = automatic\n 1 = force node presolve\n 2 = node probing" ]114MIPStrategyProbe = [ CPX_PARAM_PROBE , "probing :\n -1 = no probing\n 0 = automatic\n 1 = moderate\n 2 = aggressive\n 3 = very aggressive" ]115MIPStrategyRINSHeur = [ CPX_PARAM_RINSHEUR , "frequency to apply RINS heuristic :\n -1 = none\n 0 = automatic\n positive values at this frequency" ]116MIPStrategySearch = [ CPX_PARAM_MIPSEARCH , "indicator for search method :\n 0 = automatic\n 1 = traditional branch-and-cut search\n 2 = dynamic search" ]117MIPStrategyStartAlgorithm = [ CPX_PARAM_STARTALG , "algorithm to solve initial relaxation :\n 0 = automatic\n 1 = primal simplex\n 2 = dual simplex\n 3 = network simplex\n 4 = barrier\n 5 = sifting\n 6 = concurrent" ]118MIPStrategySubAlgorithm = [ CPX_PARAM_SUBALG , "algorithm to solve subproblems :\n 0 = automatic\n 1 = primal simplex\n 2 = dual simplex\n 3 = network simplex\n 4 = barrier\n 5 = sifting" ]119MIPStrategyVariableSelect = [ CPX_PARAM_VARSEL , "variable selection strategy :\n -1 = minimum integer infeasibility\n 0 = automatic\n 1 = maximum integer infeasibility\n 2 = pseudo costs\n 3 = strong branching\n 4 = pseudo reduced costs" ]120MIPLimitAggForCut = [ CPX_PARAM_AGGCUTLIM , "constraint aggregation limit for cut generation :\n 0 = no constraint aggregation for cut generation\n positive values at this limit" ]121MIPLimitAuxRootThreads = [ CPX_PARAM_AUXROOTTHREADS , "number of threads to use for auxiliary root tasks :\n -1 = off\n 0 = automatic\n n>0 = use n threads for auxiliary root tasks" ]122MIPLimitCutPasses = [ CPX_PARAM_CUTPASS , "number of cutting plane passes :\n -1 = none\n 0 = automatic\n positive values give number of passes to perform" ]123MIPLimitCutsFactor = [ CPX_PARAM_CUTSFACTOR , "rows multiplier factor to limit cuts " ]124MIPLimitEachCutLimit = [ CPX_PARAM_EACHCUTLIM , "limit on number of cuts for each type per pass " ]125MIPLimitGomoryCand = [ CPX_PARAM_FRACCAND , "candidate limit for generating Gomory fractional cuts " ]126MIPLimitGomoryPass = [ CPX_PARAM_FRACPASS , "pass limit for generating Gomory fractional cuts :\n 0 = automatic\n positive values at this limit" ]127MIPLimitNodes = [ CPX_PARAM_NODELIM , "branch and cut node limit " ]128MIPLimitPolishTime = [ CPX_PARAM_POLISHTIME , "time limit for polishing best solution " ]129MIPLimitPopulate = [ CPX_PARAM_POPULATELIM , "solutions limit for each populate call " ]130MIPLimitProbeTime = [ CPX_PARAM_PROBETIME , "time limit for probing " ]131MIPLimitRepairTries = [ CPX_PARAM_REPAIRTRIES , "number of times to try repair heuristic :\n -1 = none\n 0 = automatic\n positive values give number of repair attempts" ]132MIPLimitSolutions = [ CPX_PARAM_INTSOLLIM , "mixed integer solutions limit " ]133MIPLimitStrongCand = [ CPX_PARAM_STRONGCANDLIM , "strong branching candidate limit " ]134MIPLimitStrongIt = [ CPX_PARAM_STRONGITLIM , "strong branching iteration limit :\n 0 = automatic\n positive values at this limit" ]135MIPLimitSubMIPNodeLim = [ CPX_PARAM_SUBMIPNODELIM , "sub-MIP node limit " ]136MIPLimitTreeMemory = [ CPX_PARAM_TRELIM , "upper limit on size of tree in megabytes " ]137MIPDisplay = [ CPX_PARAM_MIPDISPLAY , "level of mixed integer node display :\n 0 = no display\n 1 = display integer feasible solutions\n 2 = display nodes under 'mip interval' control\n 3 = same as 2, but add information on node cuts\n 4 = same as 3, but add LP display for root node\n 5 = same as 3, but add LP display for all nodes" ]138MIPInterval = [ CPX_PARAM_MIPINTERVAL , "interval for printing mixed integer node display :\n 0 = automatic (equivalent to -1000)\n x>0 = display every x nodes and new incumbents\n x<0 = progressively less log output over time (closer to 0: more frequent)" ]139MIPOrderType = [ CPX_PARAM_MIPORDTYPE , "type of generated priority order :\n 0 = none\n 1 = decreasing cost\n 2 = increasing bound range\n 3 = increasing cost per coefficient count" ]140ReadAPIEncoding = [ CPX_PARAM_APIENCODING , "code page for API strings " ]141ReadConstraints = [ CPX_PARAM_ROWREADLIM , "constraint read size " ]142ReadDataCheck = [ CPX_PARAM_DATACHECK , "indicator for checking data consistency " ]143ReadFileEncoding = [ CPX_PARAM_FILEENCODING , "code page for file reading and writing " ]144ReadNonzeros = [ CPX_PARAM_NZREADLIM , "constraint nonzero read size " ]145ReadQPNonzeros = [ CPX_PARAM_QPNZREADLIM , "quadratic nonzero read size " ]146ReadScale = [ CPX_PARAM_SCAIND , "type of scaling used :\n-1 = no scaling\n 0 = equilibration scaling\n 1 = aggressive scaling" ]147ReadVariables = [ CPX_PARAM_COLREADLIM , "variable read size " ]148OutputCloneLog = [ CPX_PARAM_CLONELOG , "control the creation of clone log files :\n 0 = no clone log\n 1 = create clone log" ]149OutputIntSolFilePrefix = [ CPX_PARAM_INTSOLFILEPREFIX , "file name prefix for storing incumbents when they arrive " ]150OutputMPSLong = [ CPX_PARAM_MPSLONGNUM , "indicator for long numbers in MPS output files " ]151OutputWriteLevel = [ CPX_PARAM_WRITELEVEL , "variables to include in .sol and .mst files :\n 0 = auto\n 1 = all values\n 2 = discrete values\n 3 = non-zero values\n 4 = non-zero discrete values" ]152setAdvance = [ CPX_PARAM_ADVIND , "indicator for advanced starting information :\n 0 = no advanced start\n 1 = standard advanced start\n 2 = alternate advanced start" ]153setClockType = [ CPX_PARAM_CLOCKTYPE , "type of clock used to measure time :\n 0 = Automatic\n 1 = CPU Time\n 2 = Wall Clock Time" ]154setDetTimeLimit = [ CPX_PARAM_DETTILIM , "deterministic time limit in ticks " ]155setLPMethod = [ CPX_PARAM_LPMETHOD , "method for linear optimization :\n 0 = automatic\n 1 = primal simplex\n 2 = dual simplex\n 3 = network simplex\n 4 = barrier\n 5 = sifting\n 6 = concurrent dual, barrier, and primal" ]156setParallel = [ CPX_PARAM_PARALLELMODE , "parallel optimization mode :\n-1 = opportunistic\n 0 = automatic\n 1 = deterministic\n 2 = deterministic, even for sequential" ]157setParallel = [ CPX_PARAM_PARALLELMODE , "parallel optimization mode :\n-1 = opportunistic\n 0 = automatic\n 1 = deterministic" ]158setQPMethod = [ CPX_PARAM_QPMETHOD , "method for quadratic optimization :\n 0 = automatic\n 1 = primal simplex\n 2 = dual simplex\n 3 = network simplex\n 4 = barrier\n 5 = sifting\n 6 = concurrent dual, barrier, and primal" ]159setSolutionTarget = [ CPX_PARAM_SOLUTIONTARGET , "type of solution CPLEX will attempt to compute :\n 0 = auto\n 1 = optimal solution to convex problem\n 2 = first-order optimal solution" ]160setThreads = [ CPX_PARAM_THREADS , "default parallel thread count :\n 0 = automatic\n 1 = sequential\n >1 parallel" ]161setTimeLimit = [ CPX_PARAM_TILIM , "time limit in seconds " ]162setWorkDir = [ CPX_PARAM_WORKDIR , "directory for working files " ]163setWorkMem = [ CPX_PARAM_WORKMEM , "memory available for working storage (in megabytes) " ]164mipcbredlp = [ CPX_PARAM_MIPCBREDLP , "indicates that callbacks will use presolved model" ]165SimplexPerturbationConstant = [ CPX_PARAM_EPPER , "perturbation constant" ]166SimplexPerturbationIndicator = [ CPX_PARAM_PERIND , "perturbation indicator" ]167intParameterSet = [168CPX_PARAM_ITLIM,169CPX_PARAM_PERLIM,170CPX_PARAM_SINGLIM,171CPX_PARAM_MEMORYEMPHASIS,172CPX_PARAM_MIPEMPHASIS,173CPX_PARAM_NUMERICALEMPHASIS,174CPX_PARAM_BARMAXCOR,175CPX_PARAM_BARITLIM,176CPX_PARAM_BARALG,177CPX_PARAM_BARCOLNZ,178CPX_PARAM_BARCROSSALG,179CPX_PARAM_BARDISPLAY,180CPX_PARAM_BARORDER,181CPX_PARAM_BARSTARTALG,182CPX_PARAM_TUNINGDISPLAY,183CPX_PARAM_TUNINGMEASURE,184CPX_PARAM_TUNINGREPEAT,185CPX_PARAM_FEASOPTMODE,186CPX_PARAM_CONFLICTDISPLAY,187CPX_PARAM_SIFTALG,188CPX_PARAM_SIFTDISPLAY,189CPX_PARAM_SIFTITLIM,190CPX_PARAM_NETDISPLAY,191CPX_PARAM_NETITLIM,192CPX_PARAM_NETFIND,193CPX_PARAM_NETPPRIIND,194CPX_PARAM_CRAIND,195CPX_PARAM_DPRIIND,196CPX_PARAM_SIMDISPLAY,197CPX_PARAM_PPRIIND,198CPX_PARAM_PRICELIM,199CPX_PARAM_REINV,200CPX_PARAM_AGGIND,201CPX_PARAM_BNDSTRENIND,202CPX_PARAM_COEREDIND,203CPX_PARAM_DEPIND,204CPX_PARAM_PREDUAL,205CPX_PARAM_AGGFILL,206CPX_PARAM_PRELINEAR,207CPX_PARAM_PREPASS,208CPX_PARAM_PREIND,209CPX_PARAM_QPMAKEPSDIND,210CPX_PARAM_REDUCE,211CPX_PARAM_RELAXPREIND,212CPX_PARAM_REPEATPRESOLVE,213CPX_PARAM_SYMMETRY,214CPX_PARAM_POLISHAFTERNODE,215CPX_PARAM_POLISHAFTERINTSOL,216CPX_PARAM_SOLNPOOLCAPACITY,217CPX_PARAM_SOLNPOOLINTENSITY,218CPX_PARAM_SOLNPOOLREPLACE,219CPX_PARAM_CLIQUES,220CPX_PARAM_COVERS,221CPX_PARAM_DISJCUTS,222CPX_PARAM_FLOWCOVERS,223CPX_PARAM_FRACCUTS,224CPX_PARAM_GUBCOVERS,225CPX_PARAM_IMPLBD,226CPX_PARAM_MCFCUTS,227CPX_PARAM_MIRCUTS,228CPX_PARAM_FLOWPATHS,229CPX_PARAM_ZEROHALFCUTS,230CPX_PARAM_BBINTERVAL,231CPX_PARAM_BRDIR,232CPX_PARAM_DIVETYPE,233CPX_PARAM_NODEFILEIND,234CPX_PARAM_NODEFILEIND,235CPX_PARAM_FPHEUR,236CPX_PARAM_HEURFREQ,237CPX_PARAM_MIPKAPPASTATS,238CPX_PARAM_LBHEUR,239CPX_PARAM_MIQCPSTRAT,240CPX_PARAM_NODESEL,241CPX_PARAM_MIPORDIND,242CPX_PARAM_PRESLVND,243CPX_PARAM_PROBE,244CPX_PARAM_RINSHEUR,245CPX_PARAM_MIPSEARCH,246CPX_PARAM_STARTALG,247CPX_PARAM_SUBALG,248CPX_PARAM_VARSEL,249CPX_PARAM_AGGCUTLIM,250CPX_PARAM_AUXROOTTHREADS,251CPX_PARAM_CUTPASS,252CPX_PARAM_EACHCUTLIM,253CPX_PARAM_FRACCAND,254CPX_PARAM_FRACPASS,255CPX_PARAM_NODELIM,256CPX_PARAM_POPULATELIM,257CPX_PARAM_REPAIRTRIES,258CPX_PARAM_INTSOLLIM,259CPX_PARAM_STRONGCANDLIM,260CPX_PARAM_STRONGITLIM,261CPX_PARAM_SUBMIPNODELIM,262CPX_PARAM_MIPDISPLAY,263CPX_PARAM_MIPINTERVAL,264CPX_PARAM_MIPORDTYPE,265CPX_PARAM_ROWREADLIM,266CPX_PARAM_DATACHECK,267CPX_PARAM_NZREADLIM,268CPX_PARAM_QPNZREADLIM,269CPX_PARAM_SCAIND,270CPX_PARAM_COLREADLIM,271CPX_PARAM_CLONELOG,272CPX_PARAM_MPSLONGNUM,273CPX_PARAM_WRITELEVEL,274CPX_PARAM_ADVIND,275CPX_PARAM_CLOCKTYPE,276CPX_PARAM_LPMETHOD,277CPX_PARAM_PARALLELMODE,278CPX_PARAM_PARALLELMODE,279CPX_PARAM_QPMETHOD,280CPX_PARAM_SOLUTIONTARGET,281CPX_PARAM_THREADS,282CPX_PARAM_MIPCBREDLP,283CPX_PARAM_PERIND,284]285dblParameterSet = [286CPX_PARAM_OBJLLIM,287CPX_PARAM_OBJULIM,288CPX_PARAM_NETEPRHS,289CPX_PARAM_NETEPOPT,290CPX_PARAM_BARGROWTH,291CPX_PARAM_BAROBJRNG,292CPX_PARAM_BAREPCOMP,293CPX_PARAM_BARQCPEPCOMP,294CPX_PARAM_TUNINGTILIM,295CPX_PARAM_EPRELAX,296CPX_PARAM_EPRHS,297CPX_PARAM_EPMRK,298CPX_PARAM_EPOPT,299CPX_PARAM_POLISHAFTEREPAGAP,300CPX_PARAM_POLISHAFTEREPGAP,301CPX_PARAM_POLISHAFTERTIME,302CPX_PARAM_SOLNPOOLAGAP,303CPX_PARAM_SOLNPOOLGAP,304CPX_PARAM_EPAGAP,305CPX_PARAM_EPINT,306CPX_PARAM_CUTLO,307CPX_PARAM_EPGAP,308CPX_PARAM_OBJDIF,309CPX_PARAM_RELOBJDIF,310CPX_PARAM_CUTUP,311CPX_PARAM_BTTOL,312CPX_PARAM_CUTSFACTOR,313CPX_PARAM_POLISHTIME,314CPX_PARAM_PROBETIME,315CPX_PARAM_TRELIM,316CPX_PARAM_DETTILIM,317CPX_PARAM_TILIM,318CPX_PARAM_WORKMEM,319CPX_PARAM_EPPER,320]321strParameterSet = [322CPX_PARAM_APIENCODING,323CPX_PARAM_FILEENCODING,324CPX_PARAM_INTSOLFILEPREFIX,325CPX_PARAM_WORKDIR,...
__init__.py
Source:__init__.py
1#2# Licensed to the Apache Software Foundation (ASF) under one or more3# contributor license agreements. See the NOTICE file distributed with4# this work for additional information regarding copyright ownership.5# The ASF licenses this file to You under the Apache License, Version 2.06# (the "License"); you may not use this file except in compliance with7# the License. You may obtain a copy of the License at8#9# http://www.apache.org/licenses/LICENSE-2.010#11# Unless required by applicable law or agreed to in writing, software12# distributed under the License is distributed on an "AS IS" BASIS,13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14# See the License for the specific language governing permissions and15# limitations under the License.16#17import array18import sys19if sys.version > '3':20 basestring = str21 xrange = range22 unicode = str23from abc import ABCMeta24import copy25import numpy as np26from py4j.java_gateway import JavaObject27from pyspark.ml.linalg import DenseVector, Vector28from pyspark.ml.util import Identifiable29__all__ = ['Param', 'Params', 'TypeConverters']30class Param(object):31 """32 A param with self-contained documentation.33 .. versionadded:: 1.3.034 """35 def __init__(self, parent, name, doc, typeConverter=None):36 if not isinstance(parent, Identifiable):37 raise TypeError("Parent must be an Identifiable but got type %s." % type(parent))38 self.parent = parent.uid39 self.name = str(name)40 self.doc = str(doc)41 self.typeConverter = TypeConverters.identity if typeConverter is None else typeConverter42 def _copy_new_parent(self, parent):43 """Copy the current param to a new parent, must be a dummy param."""44 if self.parent == "undefined":45 param = copy.copy(self)46 param.parent = parent.uid47 return param48 else:49 raise ValueError("Cannot copy from non-dummy parent %s." % parent)50 def __str__(self):51 return str(self.parent) + "__" + self.name52 def __repr__(self):53 return "Param(parent=%r, name=%r, doc=%r)" % (self.parent, self.name, self.doc)54 def __hash__(self):55 return hash(str(self))56 def __eq__(self, other):57 if isinstance(other, Param):58 return self.parent == other.parent and self.name == other.name59 else:60 return False61class TypeConverters(object):62 """63 .. note:: DeveloperApi64 Factory methods for common type conversion functions for `Param.typeConverter`.65 .. versionadded:: 2.0.066 """67 @staticmethod68 def _is_numeric(value):69 vtype = type(value)70 return vtype in [int, float, np.float64, np.int64] or vtype.__name__ == 'long'71 @staticmethod72 def _is_integer(value):73 return TypeConverters._is_numeric(value) and float(value).is_integer()74 @staticmethod75 def _can_convert_to_list(value):76 vtype = type(value)77 return vtype in [list, np.ndarray, tuple, xrange, array.array] or isinstance(value, Vector)78 @staticmethod79 def _can_convert_to_string(value):80 vtype = type(value)81 return isinstance(value, basestring) or vtype in [np.unicode_, np.string_, np.str_]82 @staticmethod83 def identity(value):84 """85 Dummy converter that just returns value.86 """87 return value88 @staticmethod89 def toList(value):90 """91 Convert a value to a list, if possible.92 """93 if type(value) == list:94 return value95 elif type(value) in [np.ndarray, tuple, xrange, array.array]:96 return list(value)97 elif isinstance(value, Vector):98 return list(value.toArray())99 else:100 raise TypeError("Could not convert %s to list" % value)101 @staticmethod102 def toListFloat(value):103 """104 Convert a value to list of floats, if possible.105 """106 if TypeConverters._can_convert_to_list(value):107 value = TypeConverters.toList(value)108 if all(map(lambda v: TypeConverters._is_numeric(v), value)):109 return [float(v) for v in value]110 raise TypeError("Could not convert %s to list of floats" % value)111 @staticmethod112 def toListInt(value):113 """114 Convert a value to list of ints, if possible.115 """116 if TypeConverters._can_convert_to_list(value):117 value = TypeConverters.toList(value)118 if all(map(lambda v: TypeConverters._is_integer(v), value)):119 return [int(v) for v in value]120 raise TypeError("Could not convert %s to list of ints" % value)121 @staticmethod122 def toListString(value):123 """124 Convert a value to list of strings, if possible.125 """126 if TypeConverters._can_convert_to_list(value):127 value = TypeConverters.toList(value)128 if all(map(lambda v: TypeConverters._can_convert_to_string(v), value)):129 return [TypeConverters.toString(v) for v in value]130 raise TypeError("Could not convert %s to list of strings" % value)131 @staticmethod132 def toVector(value):133 """134 Convert a value to a MLlib Vector, if possible.135 """136 if isinstance(value, Vector):137 return value138 elif TypeConverters._can_convert_to_list(value):139 value = TypeConverters.toList(value)140 if all(map(lambda v: TypeConverters._is_numeric(v), value)):141 return DenseVector(value)142 raise TypeError("Could not convert %s to vector" % value)143 @staticmethod144 def toFloat(value):145 """146 Convert a value to a float, if possible.147 """148 if TypeConverters._is_numeric(value):149 return float(value)150 else:151 raise TypeError("Could not convert %s to float" % value)152 @staticmethod153 def toInt(value):154 """155 Convert a value to an int, if possible.156 """157 if TypeConverters._is_integer(value):158 return int(value)159 else:160 raise TypeError("Could not convert %s to int" % value)161 @staticmethod162 def toString(value):163 """164 Convert a value to a string, if possible.165 """166 if isinstance(value, basestring):167 return value168 elif type(value) in [np.string_, np.str_]:169 return str(value)170 elif type(value) == np.unicode_:171 return unicode(value)172 else:173 raise TypeError("Could not convert %s to string type" % type(value))174 @staticmethod175 def toBoolean(value):176 """177 Convert a value to a boolean, if possible.178 """179 if type(value) == bool:180 return value181 else:182 raise TypeError("Boolean Param requires value of type bool. Found %s." % type(value))183class Params(Identifiable):184 """185 Components that take parameters. This also provides an internal186 param map to store parameter values attached to the instance.187 .. versionadded:: 1.3.0188 """189 __metaclass__ = ABCMeta190 def __init__(self):191 super(Params, self).__init__()192 #: internal param map for user-supplied values param map193 self._paramMap = {}194 #: internal param map for default values195 self._defaultParamMap = {}196 #: value returned by :py:func:`params`197 self._params = None198 # Copy the params from the class to the object199 self._copy_params()200 def _copy_params(self):201 """202 Copy all params defined on the class to current object.203 """204 cls = type(self)205 src_name_attrs = [(x, getattr(cls, x)) for x in dir(cls)]206 src_params = list(filter(lambda nameAttr: isinstance(nameAttr[1], Param), src_name_attrs))207 for name, param in src_params:208 setattr(self, name, param._copy_new_parent(self))209 @property210 def params(self):211 """212 Returns all params ordered by name. The default implementation213 uses :py:func:`dir` to get all attributes of type214 :py:class:`Param`.215 """216 if self._params is None:217 self._params = list(filter(lambda attr: isinstance(attr, Param),218 [getattr(self, x) for x in dir(self) if x != "params" and219 not isinstance(getattr(type(self), x, None), property)]))220 return self._params221 def explainParam(self, param):222 """223 Explains a single param and returns its name, doc, and optional224 default value and user-supplied value in a string.225 """226 param = self._resolveParam(param)227 values = []228 if self.isDefined(param):229 if param in self._defaultParamMap:230 values.append("default: %s" % self._defaultParamMap[param])231 if param in self._paramMap:232 values.append("current: %s" % self._paramMap[param])233 else:234 values.append("undefined")235 valueStr = "(" + ", ".join(values) + ")"236 return "%s: %s %s" % (param.name, param.doc, valueStr)237 def explainParams(self):238 """239 Returns the documentation of all params with their optionally240 default values and user-supplied values.241 """242 return "\n".join([self.explainParam(param) for param in self.params])243 def getParam(self, paramName):244 """245 Gets a param by its name.246 """247 param = getattr(self, paramName)248 if isinstance(param, Param):249 return param250 else:251 raise ValueError("Cannot find param with name %s." % paramName)252 def isSet(self, param):253 """254 Checks whether a param is explicitly set by user.255 """256 param = self._resolveParam(param)257 return param in self._paramMap258 def hasDefault(self, param):259 """260 Checks whether a param has a default value.261 """262 param = self._resolveParam(param)263 return param in self._defaultParamMap264 def isDefined(self, param):265 """266 Checks whether a param is explicitly set by user or has267 a default value.268 """269 return self.isSet(param) or self.hasDefault(param)270 def hasParam(self, paramName):271 """272 Tests whether this instance contains a param with a given273 (string) name.274 """275 if isinstance(paramName, str):276 p = getattr(self, paramName, None)277 return isinstance(p, Param)278 else:279 raise TypeError("hasParam(): paramName must be a string")280 def getOrDefault(self, param):281 """282 Gets the value of a param in the user-supplied param map or its283 default value. Raises an error if neither is set.284 """285 param = self._resolveParam(param)286 if param in self._paramMap:287 return self._paramMap[param]288 else:289 return self._defaultParamMap[param]290 def extractParamMap(self, extra=None):291 """292 Extracts the embedded default param values and user-supplied293 values, and then merges them with extra values from input into294 a flat param map, where the latter value is used if there exist295 conflicts, i.e., with ordering: default param values <296 user-supplied values < extra.297 :param extra: extra param values298 :return: merged param map299 """300 if extra is None:301 extra = dict()302 paramMap = self._defaultParamMap.copy()303 paramMap.update(self._paramMap)304 paramMap.update(extra)305 return paramMap306 def copy(self, extra=None):307 """308 Creates a copy of this instance with the same uid and some309 extra params. The default implementation creates a310 shallow copy using :py:func:`copy.copy`, and then copies the311 embedded and extra parameters over and returns the copy.312 Subclasses should override this method if the default approach313 is not sufficient.314 :param extra: Extra parameters to copy to the new instance315 :return: Copy of this instance316 """317 if extra is None:318 extra = dict()319 that = copy.copy(self)320 that._paramMap = {}321 that._defaultParamMap = {}322 return self._copyValues(that, extra)323 def _shouldOwn(self, param):324 """325 Validates that the input param belongs to this Params instance.326 """327 if not (self.uid == param.parent and self.hasParam(param.name)):328 raise ValueError("Param %r does not belong to %r." % (param, self))329 def _resolveParam(self, param):330 """331 Resolves a param and validates the ownership.332 :param param: param name or the param instance, which must333 belong to this Params instance334 :return: resolved param instance335 """336 if isinstance(param, Param):337 self._shouldOwn(param)338 return param339 elif isinstance(param, str):340 return self.getParam(param)341 else:342 raise ValueError("Cannot resolve %r as a param." % param)343 @staticmethod344 def _dummy():345 """346 Returns a dummy Params instance used as a placeholder to347 generate docs.348 """349 dummy = Params()350 dummy.uid = "undefined"351 return dummy352 def _set(self, **kwargs):353 """354 Sets user-supplied params.355 """356 for param, value in kwargs.items():357 p = getattr(self, param)358 if value is not None:359 try:360 value = p.typeConverter(value)361 except TypeError as e:362 raise TypeError('Invalid param value given for param "%s". %s' % (p.name, e))363 self._paramMap[p] = value364 return self365 def _clear(self, param):366 """367 Clears a param from the param map if it has been explicitly set.368 """369 if self.isSet(param):370 del self._paramMap[param]371 def _setDefault(self, **kwargs):372 """373 Sets default params.374 """375 for param, value in kwargs.items():376 p = getattr(self, param)377 if value is not None and not isinstance(value, JavaObject):378 try:379 value = p.typeConverter(value)380 except TypeError as e:381 raise TypeError('Invalid default param value given for param "%s". %s'382 % (p.name, e))383 self._defaultParamMap[p] = value384 return self385 def _copyValues(self, to, extra=None):386 """387 Copies param values from this instance to another instance for388 params shared by them.389 :param to: the target instance390 :param extra: extra params to be copied391 :return: the target instance with param values copied392 """393 paramMap = self._paramMap.copy()394 if extra is not None:395 paramMap.update(extra)396 for param in self.params:397 # copy default params398 if param in self._defaultParamMap and to.hasParam(param.name):399 to._defaultParamMap[to.getParam(param.name)] = self._defaultParamMap[param]400 # copy explicitly set params401 if param in paramMap and to.hasParam(param.name):402 to._set(**{param.name: paramMap[param]})403 return to404 def _resetUid(self, newUid):405 """406 Changes the uid of this instance. This updates both407 the stored uid and the parent uid of params and param maps.408 This is used by persistence (loading).409 :param newUid: new uid to use, which is converted to unicode410 :return: same instance, but with the uid and Param.parent values411 updated, including within param maps412 """413 newUid = unicode(newUid)414 self.uid = newUid415 newDefaultParamMap = dict()416 newParamMap = dict()417 for param in self.params:418 newParam = copy.copy(param)419 newParam.parent = newUid420 if param in self._defaultParamMap:421 newDefaultParamMap[newParam] = self._defaultParamMap[param]422 if param in self._paramMap:423 newParamMap[newParam] = self._paramMap[param]424 param.parent = newUid425 self._defaultParamMap = newDefaultParamMap426 self._paramMap = newParamMap...
tParameter_Block.py
Source:tParameter_Block.py
1# -*-coding:utf-8 -*2# Copyright (c) 2011-2015, Intel Corporation3# All rights reserved.4#5# Redistribution and use in source and binary forms, with or without modification,6# are permitted provided that the following conditions are met:7#8# 1. Redistributions of source code must retain the above copyright notice, this9# list of conditions and the following disclaimer.10#11# 2. Redistributions in binary form must reproduce the above copyright notice,12# this list of conditions and the following disclaimer in the documentation and/or13# other materials provided with the distribution.14#15# 3. Neither the name of the copyright holder nor the names of its contributors16# may be used to endorse or promote products derived from this software without17# specific prior written permission.18#19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND20# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED21# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE22# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR23# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES24# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;25# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON26# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS28# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.29"""30Parameter block type testcases.31List of tested functions :32--------------------------33 - [setParameter] function34 - [getParameter] function35Initial Settings :36------------------37 Block component - 3 UINT:38 - UINT8, size = 8 bits, range : [0, 100]39 - UINT16, size = 16 bits, range : [0, 1000]40 - UINT16, size = 32 bits, range : [0, 1000]41Test cases :42------------43 - Testing nominal situation44 - Testing one-shot setting (setting directly a value for the block)45 - Testing error : Out of range TestCase46 - Testing error : Try to set an undefined param47"""48import os49import commands50import unittest51from Util.PfwUnitTestLib import PfwTestCase52from Util import ACTLogging53log=ACTLogging.Logger()54# Test of type UINT16 - range [0, 1000]55class TestCases(PfwTestCase):56 def setUp(self):57 self.block_name = "/Test/Test/TEST_TYPES/BLOCK_PARAMETER"58 self.param_name = []59 self.filesystem_name = []60 #UINT8_0, size = 861 self.param_name.append(self.block_name+"/BLOCK_UINT8")62 self.filesystem_name.append(os.environ["PFW_RESULT"] + "/BLOCK_UINT8")63 #UINT16_1, size = 1664 self.param_name.append(self.block_name+"/BLOCK_UINT16")65 self.filesystem_name.append(os.environ["PFW_RESULT"] + "/BLOCK_UINT16")66 #UINT32_2, size = 3267 self.param_name.append(self.block_name+"/BLOCK_UINT32")68 self.filesystem_name.append(os.environ["PFW_RESULT"] + "/BLOCK_UINT32")69 self.pfw.sendCmd("setTuningMode", "on")70 def tearDown(self):71 self.pfw.sendCmd("setTuningMode", "off")72 @unittest.expectedFailure73 def test_Nominal_Case(self):74 """75 Testing BLOCK_PARAMETER in nominal case76 ---------------------------------------77 Test case description :78 ~~~~~~~~~~~~~~~~~~~~~~~79 - set UINT parameters in nominal case :80 - UINT8 = 581 - UINT16 = 582 - UINT32 = 583 Tested commands :84 ~~~~~~~~~~~~~~~~~85 - [setParameter] function86 Used commands :87 ~~~~~~~~~~~~~~~88 - [getParameter] function89 Expected result :90 ~~~~~~~~~~~~~~~~~91 - Parameters set to nominal value92 - FILESYSTEM parameters set to nominal value93 """94 log.D(self.test_Nominal_Case.__doc__)95 value_param = ["5", "5", "5"]96 filesystem_value = ["0x5", "0x5", "0x5"]97 for index_param in range(len(self.param_name)) :98 log.I("set parameter %s to %s"99 %(self.param_name[index_param],value_param[index_param]))100 out,err = self.pfw.sendCmd("setParameter",self.param_name[index_param],value_param[index_param])101 assert err == None, log.E("setParameter %s %s : %s"102 % (self.param_name[index_param],value_param[index_param], err))103 assert out == "Done", log.F("setParameter %s %s"104 %(self.param_name[index_param],value_param[index_param]))105 log.I("Check parameter %s value"106 %(self.param_name[index_param]))107 out,err = self.pfw.sendCmd("getParameter",self.param_name[index_param])108 assert err == None, log.E("getParameter %s : %s"109 % (self.block_name, err))110 assert out == value_param[index_param], log.F("getParameter %s - Expected : %s Found : %s"111 %(self.param_name[index_param],value_param[index_param], out))112 log.I("Check filesystem value")113 assert (open(self.filesystem_name[index_param]).read()[:-1]114 == filesystem_value[index_param]), log.F("FILESYSTEM : parameter update error for %s after setting %s "115 %(self.block_name, self.param_name[index_param]))116 def test_Set_Block_Directly_Case(self):117 """118 Testing error BLOCK_PARAMETER : set block value directly119 --------------------------------------------------------120 Test case description :121 ~~~~~~~~~~~~~~~~~~~~~~~122 - set Param block directly without setting parameters :123 - BLOCK_PARAMETER = Dec : 1000000 Hexa : 0xF4240124 Tested commands :125 ~~~~~~~~~~~~~~~~~126 - [setParameter] function127 Used commands :128 ~~~~~~~~~~~~~~~129 - [getParameter] function130 Expected result :131 ~~~~~~~~~~~~~~~~~132 - Unable to set directly a parameter block133 - FILESYSTEM parameters set to nominal value134 """135 log.D(self.test_Set_Block_Directly_Case.__doc__)136 value = "1000000"137 log.I("Load the initial value of parameters")138 init_value_param = []139 init_filesystem_value = []140 for index_param in range(len(self.param_name)):141 out,err = self.pfw.sendCmd("getParameter",self.param_name[index_param])142 init_value_param.append(out)143 init_filesystem_value.append(open(self.filesystem_name[index_param]).read()[:-1])144 log.I("Try to set parameter %s to %s, failed expected"145 %(self.block_name,value))146 out,err = self.pfw.sendCmd("setParameter",self.block_name, value, expectSuccess=False)147 assert err == None, log.E("setParameter %s %s : %s"148 % (self.block_name, value, err))149 assert out != "Done", log.F("Error not detected when setting directly the block %s"150 % (self.block_name))151 log.I("Try to get parameter %s to %s, failed expected"152 %(self.block_name,value))153 out,err = self.pfw.sendCmd("getParameter",self.block_name, value, expectSuccess=False)154 assert err == None, log.E("getParameter %s : %s"155 % (self.block_name, err))156 assert out != value, log.F("Error not detected when getting directly the block %s"157 % (self.block_name))158 log.I("Check filesystem value")159 for index_param in range(len(self.param_name)):160 assert (open(self.filesystem_name[index_param]).read()[:-1]161 == init_filesystem_value[index_param]), log.F("FILESYSTEM : parameter update error for %s"162 %(self.block_name))163 log.I("Check Param value")164 for index_param in range(len(self.param_name)):165 out,err = self.pfw.sendCmd("getParameter",self.param_name[index_param])166 assert (out == init_value_param[index_param]), log.F("BLACKBOARD: Forbidden change value for parameter %s - Expected : %s Found : %s"167 %(self.param_name[index_param],init_value_param[index_param],out))168 def test_Out_Of_Bound_Param_Value_Case(self):169 """170 Testing error BLOCK_PARAMETER : Out of range TestCase171 -----------------------------------------------------172 Test case description :173 ~~~~~~~~~~~~~~~~~~~~~~~174 - set param UINT16 to 65536175 - check parameter UINT16 value176 - check parameter UINT8 value177 - check parameter UINT32 value178 - check block Filesystem value179 Tested commands :180 ~~~~~~~~~~~~~~~~~181 - [setParameter] function182 Used commands :183 ~~~~~~~~~~~~~~~184 - [getParameter] function185 Expected result :186 ~~~~~~~~~~~~~~~~~187 - Error detected when setting UINT16_1 to wrong value188 - FILESYSTEM parameters set to nominal value189 """190 log.D(self.test_Out_Of_Bound_Param_Value_Case.__doc__)191 param_value = "65536"192 log.I("Load the initial value of parameters")193 init_value_param = []194 init_filesystem_value = []195 for index_param in range(len(self.param_name)):196 out,err = self.pfw.sendCmd("getParameter",self.param_name[index_param])197 init_value_param.append(out)198 init_filesystem_value.append(open(self.filesystem_name[index_param]).read()[:-1])199 log.I("set parameter %s to %s, failed expected"200 %(self.param_name[1],param_value))201 out,err = self.pfw.sendCmd("setParameter",self.param_name[1],param_value, expectSuccess=False)202 assert err == None, log.E("setParameter %s %s : %s"203 % (self.param_name[1],param_value, err))204 assert out != "Done", log.F("Error not detected when setting parameter %s to out of bound value %s"205 % (self.param_name[1],param_value))206 log.I("Check parameter value")207 for index_param in range(len(self.param_name)):208 out,err = self.pfw.sendCmd("getParameter",self.param_name[index_param])209 assert out == init_value_param[index_param], log.F("BLACKBOARD: Forbidden change value for %s - Expected : %s Found : %s"210 %(self.param_name[index_param],init_value_param[index_param],out))211 log.I("Check filesystem value")212 assert (open(self.filesystem_name[index_param]).read()[:-1]213 == init_filesystem_value[index_param]), log.F("FILESYSTEM : parameter update error for %s"214 %(self.block_name))215 def test_Undefined_Param_Case(self):216 """217 Testing error BLOCK_PARAMETER : Out of range TestCase218 -----------------------------------------------------219 Test case description :220 ~~~~~~~~~~~~~~~~~~~~~~~221 - set parameter PARAM_UNDEF to 1222 - check block parameter Filesystem value223 Tested commands :224 ~~~~~~~~~~~~~~~~~225 - [setParameter] function226 Used commands :227 ~~~~~~~~~~~~~~~228 - [getParameter] function229 Expected result :230 ~~~~~~~~~~~~~~~~~231 - Error detected when setting PARAM_UNDEF232 - FILESYSTEM parameters set to nominal value233 """234 log.D(self.test_Undefined_Param_Case.__doc__)235 param_value = "1"236 param_undefined_name = self.block_name + "/PARAM_UNDEF"237 log.I("Load the initial value of parameters")238 init_value_param=[]239 init_filesystem_value=[]240 for index_param in range(len(self.param_name)) :241 out,err = self.pfw.sendCmd("getParameter",self.param_name[index_param])242 init_value_param.append(out)243 init_filesystem_value.append(open(self.filesystem_name[index_param]).read()[:-1])244 log.I("set parameter %s to %s, failed expected"245 %(param_undefined_name,param_value))246 out,err = self.pfw.sendCmd("setParameter",param_undefined_name,param_value, expectSuccess=False)247 assert err == None, log.E("setParameter %s %s : %s"248 % (param_undefined_name,param_value, err))249 assert out != "Done", log.F("Error not detected when setting parameter %s to out of bound value %s"250 % (param_undefined_name,param_value))251 log.I("Check parameter value")252 for index_param in range(len(self.param_name)):253 out,err = self.pfw.sendCmd("getParameter",self.param_name[index_param])254 assert out == init_value_param[index_param], log.F("BLACKBOARD: Forbidden change value for %s - Expected : %s Found : %s"255 %(self.param_name[index_param],init_value_param[index_param],out))256 log.I("Check filesystem value")257 assert (open(self.filesystem_name[index_param]).read()[:-1]258 == init_filesystem_value[index_param]), log.F("FILESYSTEM : parameter update error for %s"...
modulegen_customizations.py
Source:modulegen_customizations.py
...4 root_module["WifiMacHelper"].add_method(5 "SetType",6 retval("void"),7 [8 param("std::string", "type"),9 ],10 )11 root_module["WifiMacHelper"].add_method(12 "SetType",13 retval("void"),14 [15 param("std::string", "type"),16 param("std::string &", "param1_name"),17 param("ns3::AttributeValue const &", "param1_value"),18 ],19 )20 root_module["WifiMacHelper"].add_method(21 "SetType",22 retval("void"),23 [24 param("std::string", "type"),25 param("std::string &", "param1_name"),26 param("ns3::AttributeValue const &", "param1_value"),27 param("std::string &", "param2_name"),28 param("ns3::AttributeValue const &", "param2_value"),29 ],30 )31 root_module["WifiMacHelper"].add_method(32 "SetType",33 retval("void"),34 [35 param("std::string", "type"),36 param("std::string &", "param1_name"),37 param("ns3::AttributeValue const &", "param1_value"),38 param("std::string &", "param2_name"),39 param("ns3::AttributeValue const &", "param2_value"),40 param("std::string &", "param3_name"),41 param("ns3::AttributeValue const &", "param3_value"),42 ],43 )44 root_module["WifiMacHelper"].add_method(45 "SetType",46 retval("void"),47 [48 param("std::string", "type"),49 param("std::string &", "param1_name"),50 param("ns3::AttributeValue const &", "param1_value"),51 param("std::string &", "param2_name"),52 param("ns3::AttributeValue const &", "param2_value"),53 param("std::string &", "param3_name"),54 param("ns3::AttributeValue const &", "param3_value"),55 param("std::string &", "param4_name"),56 param("ns3::AttributeValue const &", "param4_value"),57 ],58 )59 root_module["WifiMacHelper"].add_method(60 "SetType",61 retval("void"),62 [63 param("std::string", "type"),64 param("std::string &", "param1_name"),65 param("ns3::AttributeValue const &", "param1_value"),66 param("std::string &", "param2_name"),67 param("ns3::AttributeValue const &", "param2_value"),68 param("std::string &", "param3_name"),69 param("ns3::AttributeValue const &", "param3_value"),70 param("std::string &", "param4_name"),71 param("ns3::AttributeValue const &", "param4_value"),72 param("std::string &", "param5_name"),73 param("ns3::AttributeValue const &", "param5_value"),74 ],75 )76 root_module["WifiMacHelper"].add_method(77 "SetType",78 retval("void"),79 [80 param("std::string", "type"),81 param("std::string &", "param1_name"),82 param("ns3::AttributeValue const &", "param1_value"),83 param("std::string &", "param2_name"),84 param("ns3::AttributeValue const &", "param2_value"),85 param("std::string &", "param3_name"),86 param("ns3::AttributeValue const &", "param3_value"),87 param("std::string &", "param4_name"),88 param("ns3::AttributeValue const &", "param4_value"),89 param("std::string &", "param5_name"),90 param("ns3::AttributeValue const &", "param5_value"),91 param("std::string &", "param6_name"),92 param("ns3::AttributeValue const &", "param6_value"),93 ],94 )95 root_module["WifiMacHelper"].add_method(96 "SetProtectionManager",97 retval("void"),98 [99 param("std::string", "type"),100 ],101 )102 root_module["WifiMacHelper"].add_method(103 "SetProtectionManager",104 retval("void"),105 [106 param("std::string", "type"),107 param("std::string &", "param1_name"),108 param("ns3::AttributeValue const &", "param1_value"),109 ],110 )111 root_module["WifiMacHelper"].add_method(112 "SetProtectionManager",113 retval("void"),114 [115 param("std::string", "type"),116 param("std::string &", "param1_name"),117 param("ns3::AttributeValue const &", "param1_value"),118 param("std::string &", "param2_name"),119 param("ns3::AttributeValue const &", "param2_value"),120 ],121 )122 root_module["WifiMacHelper"].add_method(123 "SetProtectionManager",124 retval("void"),125 [126 param("std::string", "type"),127 param("std::string &", "param1_name"),128 param("ns3::AttributeValue const &", "param1_value"),129 param("std::string &", "param2_name"),130 param("ns3::AttributeValue const &", "param2_value"),131 param("std::string &", "param3_name"),132 param("ns3::AttributeValue const &", "param3_value"),133 ],134 )135 root_module["WifiMacHelper"].add_method(136 "SetProtectionManager",137 retval("void"),138 [139 param("std::string", "type"),140 param("std::string &", "param1_name"),141 param("ns3::AttributeValue const &", "param1_value"),142 param("std::string &", "param2_name"),143 param("ns3::AttributeValue const &", "param2_value"),144 param("std::string &", "param3_name"),145 param("ns3::AttributeValue const &", "param3_value"),146 param("std::string &", "param4_name"),147 param("ns3::AttributeValue const &", "param4_value"),148 ],149 )150 root_module["WifiMacHelper"].add_method(151 "SetProtectionManager",152 retval("void"),153 [154 param("std::string", "type"),155 param("std::string &", "param1_name"),156 param("ns3::AttributeValue const &", "param1_value"),157 param("std::string &", "param2_name"),158 param("ns3::AttributeValue const &", "param2_value"),159 param("std::string &", "param3_name"),160 param("ns3::AttributeValue const &", "param3_value"),161 param("std::string &", "param4_name"),162 param("ns3::AttributeValue const &", "param4_value"),163 param("std::string &", "param5_name"),164 param("ns3::AttributeValue const &", "param5_value"),165 ],166 )167 root_module["WifiMacHelper"].add_method(168 "SetProtectionManager",169 retval("void"),170 [171 param("std::string", "type"),172 param("std::string &", "param1_name"),173 param("ns3::AttributeValue const &", "param1_value"),174 param("std::string &", "param2_name"),175 param("ns3::AttributeValue const &", "param2_value"),176 param("std::string &", "param3_name"),177 param("ns3::AttributeValue const &", "param3_value"),178 param("std::string &", "param4_name"),179 param("ns3::AttributeValue const &", "param4_value"),180 param("std::string &", "param5_name"),181 param("ns3::AttributeValue const &", "param5_value"),182 param("std::string &", "param6_name"),183 param("ns3::AttributeValue const &", "param6_value"),184 ],185 )186 root_module["WifiMacHelper"].add_method(187 "SetAckManager",188 retval("void"),189 [190 param("std::string", "type"),191 ],192 )193 root_module["WifiMacHelper"].add_method(194 "SetAckManager",195 retval("void"),196 [197 param("std::string", "type"),198 param("std::string &", "param1_name"),199 param("ns3::AttributeValue const &", "param1_value"),200 ],201 )202 root_module["WifiMacHelper"].add_method(203 "SetAckManager",204 retval("void"),205 [206 param("std::string", "type"),207 param("std::string &", "param1_name"),208 param("ns3::AttributeValue const &", "param1_value"),209 param("std::string &", "param2_name"),210 param("ns3::AttributeValue const &", "param2_value"),211 ],212 )213 root_module["WifiMacHelper"].add_method(214 "SetAckManager",215 retval("void"),216 [217 param("std::string", "type"),218 param("std::string &", "param1_name"),219 param("ns3::AttributeValue const &", "param1_value"),220 param("std::string &", "param2_name"),221 param("ns3::AttributeValue const &", "param2_value"),222 param("std::string &", "param3_name"),223 param("ns3::AttributeValue const &", "param3_value"),224 ],225 )226 root_module["WifiMacHelper"].add_method(227 "SetAckManager",228 retval("void"),229 [230 param("std::string", "type"),231 param("std::string &", "param1_name"),232 param("ns3::AttributeValue const &", "param1_value"),233 param("std::string &", "param2_name"),234 param("ns3::AttributeValue const &", "param2_value"),235 param("std::string &", "param3_name"),236 param("ns3::AttributeValue const &", "param3_value"),237 param("std::string &", "param4_name"),238 param("ns3::AttributeValue const &", "param4_value"),239 ],240 )241 root_module["WifiMacHelper"].add_method(242 "SetAckManager",243 retval("void"),244 [245 param("std::string", "type"),246 param("std::string &", "param1_name"),247 param("ns3::AttributeValue const &", "param1_value"),248 param("std::string &", "param2_name"),249 param("ns3::AttributeValue const &", "param2_value"),250 param("std::string &", "param3_name"),251 param("ns3::AttributeValue const &", "param3_value"),252 param("std::string &", "param4_name"),253 param("ns3::AttributeValue const &", "param4_value"),254 param("std::string &", "param5_name"),255 param("ns3::AttributeValue const &", "param5_value"),256 ],257 )258 root_module["WifiMacHelper"].add_method(259 "SetAckManager",260 retval("void"),261 [262 param("std::string", "type"),263 param("std::string &", "param1_name"),264 param("ns3::AttributeValue const &", "param1_value"),265 param("std::string &", "param2_name"),266 param("ns3::AttributeValue const &", "param2_value"),267 param("std::string &", "param3_name"),268 param("ns3::AttributeValue const &", "param3_value"),269 param("std::string &", "param4_name"),270 param("ns3::AttributeValue const &", "param4_value"),271 param("std::string &", "param5_name"),272 param("ns3::AttributeValue const &", "param5_value"),273 param("std::string &", "param6_name"),274 param("ns3::AttributeValue const &", "param6_value"),275 ],...
treenode_qstditem.py
Source:treenode_qstditem.py
1# Copyright (c) 2012, Willow Garage, Inc.2# All rights reserved.3#4# Software License Agreement (BSD License 2.0)5#6# Redistribution and use in source and binary forms, with or without7# modification, are permitted provided that the following conditions8# are met:9#10# * Redistributions of source code must retain the above copyright11# notice, this list of conditions and the following disclaimer.12# * Redistributions in binary form must reproduce the above13# copyright notice, this list of conditions and the following14# disclaimer in the documentation and/or other materials provided15# with the distribution.16# * Neither the name of Willow Garage, Inc. nor the names of its17# contributors may be used to endorse or promote products derived18# from this software without specific prior written permission.19#20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS21# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT22# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS23# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE24# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,25# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,26# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;27# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER28# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT29# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN30# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE31# POSSIBILITY OF SUCH DAMAGE.32#33# Author: Isaac Saito34from __future__ import division35import threading36import time37import dynamic_reconfigure.client38from python_qt_binding.QtCore import Qt39from python_qt_binding.QtGui import QBrush, QStandardItem40from rospy.exceptions import ROSException41from rqt_py_common.data_items import ReadonlyItem42from rqt_reconfigure import logging43from rqt_reconfigure.param_client_widget import ParamClientWidget44class ParamserverConnectThread(threading.Thread):45 def __init__(self, parent, param_name_raw):46 super(ParamserverConnectThread, self).__init__()47 self._parent = parent48 self._raw_param_name = param_name_raw49 def run(self):50 param_client = None51 try:52 param_client = dynamic_reconfigure.client.Client(53 str(self._raw_param_name), timeout=5.0)54 logging.debug(55 'ParamserverConnectThread param_client={}'.format(56 param_client57 ))58 self._parent.set_param_client(param_client)59 except ROSException as e:60 raise type(e)(61 e.message + "TreenodeQstdItem. Couldn't connect to {}".format(62 self._raw_param_name63 ))64class TreenodeQstdItem(ReadonlyItem):65 """66 Extending ReadonlyItem - the display content of this item shouldn't be67 modified.68 """69 NODE_FULLPATH = 170 def __init__(self, *args):71 """72 :param args[0]: str (will become 1st arg of QStandardItem)73 :param args[1]: integer value that indicates whether this class74 is node that has GRN (Graph Resource Names, see75 http://www.ros.org/wiki/Names). This can be None76 """77 grn_current_treenode = args[0]78 self._raw_param_name = grn_current_treenode79 self._set_param_name(grn_current_treenode)80 super(TreenodeQstdItem, self).__init__(grn_current_treenode)81 # dynamic_reconfigure.client.Client82 self._param_client = None83 # ParamClientWidget84 self._param_client_widget = None85 self._is_rosnode = False86 self._lock = threading.Lock()87 self._paramserver_connect_thread = None88 try:89 if args[1]:90 self._is_rosnode = True91 except IndexError: # tuple index out of range etc.92 logging.error('TreenodeQstdItem IndexError')93 def set_param_client(self, param_client):94 """95 @param param_client: dynamic_reconfigure.client.Client96 """97 self._param_client = param_client98 logging.debug('Qitem set param_client={} param={}'.format(99 self._param_client, self._raw_param_name100 ))101 def clear_param_client(self):102 if self._param_client is not None:103 self._param_client.close()104 del self._param_client105 self._param_client = None106 def get_param_client_widget(self):107 """108 @rtype: ParamClientWidget (QWidget)109 @return: None if param_client is not yet generated.110 @raise ROSException:111 """112 if not self._param_client_widget:113 logging.debug('get param_client={}'.format(114 self._param_client115 ))116 logging.debug('In get_param_client_widget 1')117 if not self._param_client:118 self.connect_param_server()119 logging.debug('In get_param_client_widget 2')120 timeout = 3 * 100121 loop = 0122 # Loop until _param_client is set. self._param_client gets123 # set from different thread (in ParamserverConnectThread).124 while self._param_client is None:125 # Avoid deadlock126 if timeout < loop:127 # Make itself unclickable128 self.setEnabled(False)129 raise ROSException('param client failed')130 time.sleep(0.01)131 loop += 1132 logging.debug('In get_param_client_widget loop#{}'.format(loop))133 logging.debug('In get_param_client_widget 4')134 self._param_client_widget = ParamClientWidget(135 self._param_client, self._raw_param_name136 )137 # Creating the ParamClientWidget transfers ownership of the138 # _param_client to it. If it is destroyed from Qt, we need to139 # clear our reference to it and stop the param server thread we140 # had.141 self._param_client_widget.destroyed.connect(142 self.clear_param_client_widget)143 self._param_client_widget.destroyed.connect(144 self.disconnect_param_server)145 logging.debug('In get_param_client_widget 5')146 else:147 pass148 return self._param_client_widget149 def clear_param_client_widget(self):150 self._param_client_widget = None151 def connect_param_server(self):152 """153 Connect to parameter server using dynamic_reconfigure client.154 Behavior is delegated to a private method _connect_param_server, and155 its return value, client, is set to member variable.156 @return void157 @raise ROSException:158 """159 # If the treenode doesn't represent ROS Node, return None.160 with self._lock:161 if not self._is_rosnode:162 logging.error('connect_param_server failed due to missing '163 'ROS Node. Return with nothing.')164 return165 if not self._param_client:166 if self._paramserver_connect_thread:167 if self._paramserver_connect_thread.isAlive():168 self._paramserver_connect_thread.join(1)169 self._paramserver_connect_thread = ParamserverConnectThread(170 self, self._raw_param_name)171 self._paramserver_connect_thread.start()172 def disconnect_param_server(self):173 with self._lock:174 if self._paramserver_connect_thread:175 # Try to stop the thread176 if self._paramserver_connect_thread.isAlive():177 self._paramserver_connect_thread.join(1)178 del self._paramserver_connect_thread179 self._paramserver_connect_thread = None180 self.clear_param_client()181 def enable_param_items(self):182 """183 Create QStdItem per parameter and addColumn them to myself.184 :rtype: None if _param_client is not initiated.185 """186 if not self._param_client_widget:187 return None188 param_names = self._param_client_widget.get_treenode_names()189 param_names_items = []190 brush = QBrush(Qt.lightGray)191 for param_name in param_names:192 item = ReadonlyItem(param_name)193 item.setBackground(brush)194 param_names_items.append(item)195 logging.debug('enable_param_items len of param_names={}'.format(196 len(param_names_items)197 ))198 self.appendColumn(param_names_items)199 def _set_param_name(self, param_name):200 """201 :param param_name: A string formatted as GRN (Graph Resource Names, see202 http://www.ros.org/wiki/Names).203 Example: /paramname/subpara/subsubpara/...204 """205 logging.debug('_set_param_name param_name={} '.format(param_name))206 # separate param_name by forward slash207 self._list_treenode_names = param_name.split('/')208 # Deleting the 1st elem which is zero-length str.209 del self._list_treenode_names[0]210 self._toplevel_treenode_name = self._list_treenode_names[0]211 logging.debug('param_name={} node_name={} _list_params[-1]={}'.format(212 param_name, self._toplevel_treenode_name,213 self._list_treenode_names[-1]214 ))215 def get_param_name_toplv(self):216 """217 :rtype: String of the top level param name.218 """219 return self._name_top220 def get_raw_param_name(self):221 return self._raw_param_name222 def get_treenode_names(self):223 """224 :rtype: List of string. Null if param225 """226 # TODO: what if self._list_treenode_names is empty or null?227 return self._list_treenode_names228 def get_node_name(self):229 """230 :return: A value of single tree node (ie. NOT the fullpath node name).231 Ex. suppose fullpath name is /top/sub/subsub/subsubsub and you232 are at 2nd from top, the return value is subsub.233 """234 return self._toplevel_treenode_name235 def type(self):...
testGeomParam.py
Source:testGeomParam.py
1#-******************************************************************************2#3# Copyright (c) 2012,4# Sony Pictures Imageworks Inc. and5# Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.6#7# All rights reserved.8#9# Redistribution and use in source and binary forms, with or without10# modification, are permitted provided that the following conditions are11# met:12# * Redistributions of source code must retain the above copyright13# notice, this list of conditions and the following disclaimer.14# * Redistributions in binary form must reproduce the above15# copyright notice, this list of conditions and the following disclaimer16# in the documentation and/or other materials provided with the17# distribution.18# * Neither the name of Sony Pictures Imageworks, nor19# Industrial Light & Magic, nor the names of their contributors may be used20# to endorse or promote products derived from this software without specific21# prior written permission.22#23# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS24# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT25# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR26# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT27# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,28# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT29# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,30# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY31# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT32# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE33# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.34#35#-******************************************************************************36from buildTestData import *37testList = []38def testOGeomParamImpl( iTPTraits, iTypedGeomParamSample ):39 compare = TraitsComparison[iTPTraits.__name__]40 ovals = ArrayTraitsData[iTPTraits.__name__][1]41 samp = iTypedGeomParamSample( ovals, GeometryScope.kConstantScope )42 ivals = samp.getVals()43 assert len( ivals ) == len( ovals )44 for i in range( len( ivals ) ):45 assert compare( ivals[i], ovals[i] )46 samp2 = iTypedGeomParamSample()47 samp2.setVals( ovals )48 ivals = samp2.getVals()49 assert len( ivals ) == len( ovals )50 for i in range( len( ivals ) ):51 assert compare( ivals[i], ovals[i] )52def testOGeomParamSample():53 testOGeomParamImpl( BooleanTPTraits, OBooleanGeomParamSample )54 testOGeomParamImpl( Uint8TPTraits , OUcharGeomParamSample )55 testOGeomParamImpl( Int8TPTraits , OCharGeomParamSample )56 testOGeomParamImpl( Uint16TPTraits , OUInt16GeomParamSample )57 testOGeomParamImpl( Int16TPTraits , OInt16GeomParamSample )58 testOGeomParamImpl( Uint32TPTraits , OUInt32GeomParamSample )59 testOGeomParamImpl( Int32TPTraits , OInt32GeomParamSample )60 testOGeomParamImpl( Uint64TPTraits , OUInt64GeomParamSample )61 testOGeomParamImpl( Int64TPTraits , OInt64GeomParamSample )62 testOGeomParamImpl( Float16TPTraits, OHalfGeomParamSample )63 testOGeomParamImpl( Float32TPTraits, OFloatGeomParamSample )64 testOGeomParamImpl( Float64TPTraits, ODoubleGeomParamSample )65 testOGeomParamImpl( StringTPTraits , OStringGeomParamSample )66 testOGeomParamImpl( WstringTPTraits, OWstringGeomParamSample )67 testOGeomParamImpl( V2sTPTraits , OV2sGeomParamSample )68 testOGeomParamImpl( V2iTPTraits , OV2iGeomParamSample )69 testOGeomParamImpl( V2fTPTraits , OV2fGeomParamSample )70 testOGeomParamImpl( V2dTPTraits , OV2dGeomParamSample )71 testOGeomParamImpl( V3sTPTraits , OV3sGeomParamSample )72 testOGeomParamImpl( V3iTPTraits , OV3iGeomParamSample )73 testOGeomParamImpl( V3fTPTraits , OV3fGeomParamSample )74 testOGeomParamImpl( V3dTPTraits , OV3dGeomParamSample )75 testOGeomParamImpl( P2sTPTraits , OP2sGeomParamSample )76 testOGeomParamImpl( P2iTPTraits , OP2iGeomParamSample )77 testOGeomParamImpl( P2fTPTraits , OP2fGeomParamSample )78 testOGeomParamImpl( P2dTPTraits , OP2dGeomParamSample )79 testOGeomParamImpl( P3sTPTraits , OP3sGeomParamSample )80 testOGeomParamImpl( P3iTPTraits , OP3iGeomParamSample )81 testOGeomParamImpl( P3fTPTraits , OP3fGeomParamSample )82 testOGeomParamImpl( P3dTPTraits , OP3dGeomParamSample )83 testOGeomParamImpl( Box2sTPTraits , OBox2sGeomParamSample )84 testOGeomParamImpl( Box2iTPTraits , OBox2iGeomParamSample )85 testOGeomParamImpl( Box2fTPTraits , OBox2fGeomParamSample )86 testOGeomParamImpl( Box2dTPTraits , OBox2dGeomParamSample )87 testOGeomParamImpl( Box3sTPTraits , OBox3sGeomParamSample )88 testOGeomParamImpl( Box3iTPTraits , OBox3iGeomParamSample )89 testOGeomParamImpl( Box3fTPTraits , OBox3fGeomParamSample )90 testOGeomParamImpl( Box3dTPTraits , OBox3dGeomParamSample )91 testOGeomParamImpl( M33fTPTraits , OM33fGeomParamSample )92 testOGeomParamImpl( M33dTPTraits , OM33dGeomParamSample )93 testOGeomParamImpl( M44fTPTraits , OM44fGeomParamSample )94 testOGeomParamImpl( M44dTPTraits , OM44dGeomParamSample )95 testOGeomParamImpl( QuatfTPTraits , OQuatfGeomParamSample )96 testOGeomParamImpl( QuatdTPTraits , OQuatdGeomParamSample )97 testOGeomParamImpl( C3hTPTraits , OC3hGeomParamSample )98 testOGeomParamImpl( C3fTPTraits , OC3fGeomParamSample )99 testOGeomParamImpl( C3cTPTraits , OC3cGeomParamSample )100 testOGeomParamImpl( C4hTPTraits , OC4hGeomParamSample )101 testOGeomParamImpl( C4fTPTraits , OC4fGeomParamSample )102 testOGeomParamImpl( C4cTPTraits , OC4cGeomParamSample )103 testOGeomParamImpl( N2fTPTraits , ON2fGeomParamSample )104 testOGeomParamImpl( N2dTPTraits , ON2dGeomParamSample )105 testOGeomParamImpl( N3fTPTraits , ON3fGeomParamSample )106 testOGeomParamImpl( N3dTPTraits , ON3dGeomParamSample )107testList.append( ( 'testOGeomParamSample', testOGeomParamSample ) )108# -------------------------------------------------------------------------109# Main loop110for test in testList:111 funcName = test[0]112 print ""113 print "Running %s" % funcName114 test[1]()115 print "passed"...
Using AI Code Generation
1import { param } from 'storybook-root-decorator';2import { withKnobs, text } from '@storybook/addon-knobs';3import { withInfo } from '@storybook/addon-info';4import { withA11y } from '@storybook/addon-a11y';5import { withTests } from '@storybook/addon-jest';6import { withConsole } from '@storybook/addon-console';7import { withTests } from '@storybook/addon-jest';8import { withConsole } from '@storybook/addon-console';9import { withTests } from '@storybook/addon-jest';10import { withConsole } from '@storybook/addon-console';11import { withTests } from '@storybook/addon-jest';12import { withConsole } from '@storybook/addon-console';13import { withTests } from '@storybook/addon-jest';14import { withConsole } from '@storybook/addon-console';15import { withTests } from '@storybook/addon-jest';16import { withConsole } from '@storybook/addon-console';17import { withTests } from '@storybook/addon-jest';18import { withConsole } from '@storybook/addon-console';19import { withTests } from '@storybook/addon-jest';
Using AI Code Generation
1import { storiesOf, addParameters } from '@storybook/react';2import { withKnobs } from '@storybook/addon-knobs';3import { withNotes } from '@storybook/addon-notes';4import { withInfo } from '@storybook/addon-info';5import { withA11y } from '@storybook/addon-a11y';6import { withReadme } from 'storybook-readme';7import { withDocs } from 'storybook-readme';8import { withReadme } from
Using AI Code Generation
1import { withRootDecorator } from 'storybook-root-decorator';2import { withKnobs, text } from '@storybook/addon-knobs';3export default {4};5export const MyComponent = () => {6 const name = text('Name', 'John Doe');7 return <MyComponent name={name} />;8};9import { withRootDecorator } from 'storybook-root-decorator';10export const decorators = [withRootDecorator];11import React from 'react';12import { ThemeProvider } from 'styled-components';13import { theme } from 'theme';14export const withRootDecorator = (storyFn) => (15 <ThemeProvider theme={theme}>{storyFn()}</ThemeProvider>16);17export default withRootDecorator;18export const theme = {19 colors: {20 },21};22import React from 'react';23import styled from 'styled-components';24 color: ${({ theme }) => theme.colors.primary};25`;26const MyComponent = ({ name }) => {27 return <StyledComponent>Hello {name}</StyledComponent>;28};29export default MyComponent;30import React from 'react';31import { render } from 'test-utils';32import MyComponent from './MyComponent';33describe('MyComponent', () => {34 it('renders', () => {35 const { getByText } = render(<MyComponent name="John" />);36 expect(getByText('Hello John')).toBeInTheDocument();37 });38});39MIT © [joshwcomeau](
Using AI Code Generation
1import { withRootDecorator } from 'storybook-root-decorator';2export default {3};4export const Test = () => {5 return <div>Test</div>;6};7import { withRootDecorator } from 'storybook-root-decorator';8export const decorators = [withRootDecorator()];9export const parameters = {10 rootDecorator: {11 },12};13import { withRootDecorator } from 'storybook-root-decorator';14export const decorators = [withRootDecorator()];15export const parameters = {16 rootDecorator: {17 },18};19import { withRootDecorator } from 'storybook-root-decorator';20export const decorators = [withRootDecorator()];21export const parameters = {22 rootDecorator: {23 },24};25import { withRootDecorator } from 'storybook-root-decorator';26export const decorators = [withRootDecorator()];27export const parameters = {28 rootDecorator: {29 },30};31import { withRootDecorator } from 'storybook-root-decorator';32export const decorators = [withRootDecorator()];33export const parameters = {34 rootDecorator: {35 },36};37import { withRootDecorator } from 'storybook-root-decorator';38export const decorators = [withRootDecorator()];39export const parameters = {40 rootDecorator: {41 },42};43import { withRootDecorator } from 'storybook-root-de
Using AI Code Generation
1import { param } from 'storybook-root'2export default () => (3 <h1>My name is {param('name')}</h1>4import { storiesOf } from '@storybook/react'5import Test from './test'6storiesOf('Test', module)7 .add('Test 1', () => <Test />, {8 params: {9 }10 })11 .add('Test 2', () => <Test />, {12 params: {13 }14 })15import { storiesOf } from '@storybook/react'16import Test from './test'17storiesOf('Test', module)18 .add('Test 1', () => <Test />, {19 params: {20 }21 })22 .add('Test 2', () => <Test />, {23 params: {24 }25 })26import { storiesOf } from '@storybook/react'27import Test from './test'28storiesOf('Test', module)29 .add('Test 1', () => <Test />, {30 params: {31 }32 })33 .add('Test 2', () => <Test />, {34 params: {35 }36 })37import { storiesOf } from '@storybook/react'38import Test from './test'39storiesOf('Test', module)40 .add('Test 1', () => <Test />, {41 params: {42 }43 })44 .add('Test 2', () => <Test />, {45 params: {46 }47 })48import { storiesOf } from '@storybook/react'49import Test from './test'50storiesOf('Test', module)51 .add('Test 1', () => <Test />, {52 params: {53 }54 })55 .add('Test 2', () => <Test />, {56 params: {57 }58 })59import { storiesOf } from '@storybook/react'60import Test from './test'61storiesOf('Test', module)
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!