SimpleOpt Namespace Reference

Functions

def real_fun (x)
 
def toy_fun (x)
 
def main ()
 

Function Documentation

◆ main()

def SimpleOpt.main ( )
55 def main():
56  global SourceDir, BuildDir
57 
58  # Set up terminal output
59  clr = colorClass()
60  clr.set_use_colors(True)
61  clr.def_colors()
62 
63  # Hello tag
64  print(clr.END + clr.BOLD + clr.VIOLET + "-------------------------------------------")
65  print(clr.END + clr.BOLD + clr.VIOLET + " MercuryDPM SimpleOpt tool ")
66  print(clr.END + clr.BOLD + clr.VIOLET + "-------------------------------------------")
67 
68  if (len(sys.argv) == 3): # Full format: "run source_dir build_dir"
69  source_dir = sys.argv[1]
70  build_dir = sys.argv[2]
71 
72  print("Source dir: ", source_dir)
73  print("Build dir: ", build_dir)
74 
75  res = minimize(real_fun, x0, method='Powell', options = {'xtol':1e-3, 'ftol':1e-4})
76 
77  print(res)
78 
79  print(clr.END + "Converged to the known solution: ", np.allclose(res["x"], xc))
80 
81 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet print(const Packet &a)
Definition: GenericPacketMath.h:1166
def main()
Definition: SimpleOpt.py:55

References Eigen::internal.print().

◆ real_fun()

def SimpleOpt.real_fun (   x)
27 def real_fun(x):
28  import subprocess
29  global SourceDir, BuildDir
30  ret = 0
31 
32  command = [build_dir+'/Drivers/SimpleOpt/Opt']
33 
34  for i in range(len(x)):
35  command.append('-p'+str(i))
36  command.append(str(x[i]))
37 
38 
39  #print(command)
40 
41  subprocess.run(command)
42  f = open(build_dir+'/Drivers/SimpleOpt/functional.txt', "r")
43  ret = float(f.read())
44  return ret
45 
46 
def real_fun(x)
Definition: SimpleOpt.py:27
str
Definition: compute_granudrum_aor.py:141

References compute_granudrum_aor.str.

◆ toy_fun()

def SimpleOpt.toy_fun (   x)
47 def toy_fun(x):
48  global xc
49  ret = 0
50  for m in range(len(x)):
51  ret = ret + (x[m] - xc[m])**2
52  return ret
53 
54 
def toy_fun(x)
Definition: SimpleOpt.py:47