-
Notifications
You must be signed in to change notification settings - Fork 187
/
S_brute_force_gen_sym.py
64 lines (48 loc) · 1.44 KB
/
S_brute_force_gen_sym.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# runs BF on data and saves the best RPN expressions in results.dat
# all the .dat files are created after I run this script
# the .scr are needed to run the fortran code
import csv
import os
import shutil
import subprocess
import sys
from subprocess import call
import numpy as np
import sympy as sp
from sympy.parsing.sympy_parser import parse_expr
from .resources import _get_resource
def brute_force_gen_sym(pathdir, filename, BF_try_time, BF_ops_file_type, sigma=10, band=0):
try_time = BF_try_time
try_time_prefactor = BF_try_time
file_type = BF_ops_file_type
try:
os.remove("results_gen_sym.dat")
except:
pass
try:
os.remove("brute_solutions.dat")
except:
pass
try:
os.remove("brute_constant.dat")
except:
pass
try:
os.remove("brute_formulas.dat")
except:
pass
print("Trying to solve mysteries with brute force...")
print("Trying to solve {}".format(pathdir+filename))
shutil.copy2(pathdir+filename, "mystery.dat")
data = "'{}' '{}' mystery.dat results_gen_sym.dat {:f} {:f}".format(_get_resource(file_type),
_get_resource(
"arity2templates.txt"),
sigma,
band)
with open("args.dat", 'w') as f:
f.write(data)
try:
subprocess.call(["feynman_sr_mdl5"], timeout=try_time)
except:
pass
return 1