7 import xml.dom.minidom
as minidom
9 from random
import randint
10 from math
import sin, cos, pi
11 except ImportError, err:
12 print "ERROR: Cannot load module: %s" % (err)
21 return sqr(y-(5.1/(4*sqr(pi)))*sqr(x)+5*x/pi-6)+10*(1-1/(8*pi))*cos(x)+10
27 print "ERROR: 2 arguments required" 30 inputFilename = argv[0];
31 outputFilename = argv[1];
35 doc = minidom.parse(inputFilename)
37 print "Unable to open and parse input xml file: " + inputFilename
40 node = doc.getElementsByTagName(
"node")[0]
41 x1 = float(node.getAttribute(
"par1"))
42 x2 = float(node.getAttribute(
"par2"))
45 ms = randint(0,500)/1000.0
47 print "Python: delay = " + str(ms) +
" ms." 51 y = branin(float(x1)*15-5,float(x2)*15)
52 f1=open(outputFilename,
"w+")
58 if __name__ ==
'__main__' :
61 tb = sys.exc_info()[2]
62 traceback.print_exception(e.__class__, e, tb)