def invoke_gelpia_serial(symExpr): inputStr = extract_input_dep(list(symExpr.free_symbols)) str_expr = re.sub(r'\*\*', "^", str(symExpr)) str_expr = re.sub(r'Abs', "abs", str_expr) str_expr = re.sub(r're\b', "", str_expr) str_expr = re.sub(r'im\b', "0.0*", str_expr) str_expr = inputStr + str_expr max_lower = Value("d", float("nan")) max_upper = Value("d", float("nan")) #print("ID:",Globals.gelpiaID, "\t Finding max, min\n") ##-- Create dumps if verbose is on --- if Globals.argList.gverbose: filename = "gelpia_{batchid}_{pid}.txt".format(batchid=Globals.batchID, pid=os.getpid()) fout = open(filename, 'w') fout.write("# --input-epsilon {ieps}\n".format( ieps=str(gelpia_input_epsilon))) fout.write("# --output-epsilon {oeps}\n".format( oeps=str(gelpia_output_epsilon))) fout.write("# --output-epsilon-relative {oreps}\n".format( oreps=str(gelpia_output_epsilon_relative))) fout.write("# --timeout {tout}\n".format(tout=str(gelpia_timeout))) fout.write( "# --max-iters {miters}\n".format(miters=str(gelpia_max_iters))) fout.write(str_expr) fout.close() ##--- p = Process(target=gelpia.find_max, args=(str_expr, gelpia_epsilons, gelpia_timeout, gelpia_grace, gelpia_update, gelpia_max_iters, gelpia_seed, False, gelpia.SRC_DIR, gelpia_rust_executable, max_lower, max_upper)) p.start() min_lower, min_upper = gelpia.find_min(str_expr, gelpia_epsilons, gelpia_timeout, gelpia_grace, gelpia_update, gelpia_max_iters, gelpia_seed, False, gelpia.SRC_DIR, gelpia_rust_executable) p.join() return [min_lower, max_upper.value]
def __init__(self, query): self.query = query if self.query in CACHE: cached = CACHE[self.query] self.max_lower = cached.max_lower self.max_upper = cached.max_upper self.min_lower = cached.min_lower self.min_upper = cached.min_upper self.abs_max = cached.abs_max return timer.start() # Run and set results as member max_lower = Value("d", float("nan")) max_upper = Value("d", float("nan")) max_args = {"function": self.query, "max_lower": max_lower, "max_upper": max_upper} max_args.update(GelpiaResult.CONFIG) p = Process(target=gelpia.find_max, kwargs=max_args) p.start() self.min_lower, self.min_upper = gelpia.find_min(function=self.query, **GelpiaResult.CONFIG) p.join() timer.stop() self.max_lower = max_lower.value self.max_upper = max_upper.value self.abs_max = max(self.max_upper, -self.min_lower) if isinf(self.abs_max): raise GelpiaInfError(self.query) CACHE[self.query] = self
def invoke_gelpia(symExpr, inputStr, label="Func-> Dur:"): #try: # const_intv = float(str(symExpr)) # return [const_intv, const_intv] #except ValueError: # pass #print("In gelpia", seng.count_ops(symExpr)) #print(symExpr) str_expr = re.sub(r'\*\*', "^", str(symExpr)) str_expr = re.sub(r'Abs', "abs", str_expr) str_expr = re.sub(r're\b', "", str_expr) str_expr = re.sub(r'im\b', "0.0*", str_expr) #print("Pass conversion gelpia") str_expr = inputStr + str_expr #print("Begining New gelpia query->ID:", Globals.gelpiaID) Globals.gelpiaID += 1 fout = open("gelpia_"+str(Globals.gelpiaID)+".txt", "w") fout.write("# --input-epsilon {ieps}\n".format(ieps=str(gelpia_input_epsilon))) fout.write("# --output-epsilon {oeps}\n".format(oeps=str(gelpia_output_epsilon))) fout.write("# --output-epsilon-relative {oreps}\n".format(oreps=str(gelpia_output_epsilon_relative))) fout.write("# --timeout {tout}\n".format(tout=str(gelpia_timeout))) fout.write("# --max-iters {miters}\n".format(miters=str(gelpia_max_iters))) fout.write(str_expr) fout.close() #print(str_expr) start_time = time.time() max_lower = Value("d", float("nan")) max_upper = Value("d", float("nan")) #print("ID:",Globals.gelpiaID, "\t Finding max, min\n") p = Process(target=gelpia.find_max, args=(str_expr, gelpia_epsilons, gelpia_timeout, gelpia_grace, gelpia_update, gelpia_max_iters, gelpia_seed, False, gelpia.SRC_DIR, gelpia_rust_executable, max_lower, max_upper)) p.start() min_lower, min_upper = gelpia.find_min(str_expr, gelpia_epsilons, gelpia_timeout, gelpia_grace, gelpia_update, gelpia_max_iters, gelpia_seed, False, gelpia.SRC_DIR, gelpia_rust_executable) p.join() end_time = time.time() #print("Finishing gelpia query->ID:", Globals.gelpiaID) #print(str_expr) #print(label, end_time - start_time, " , FSYM: ", len(symExpr.free_symbols)) return [min_lower, max_upper.value]