def run(self, quiet=False): ncs_para = ncs.NCS_CParameter(tmax=300000, lambda_exp=self.l, r=self.r, epoch=self.e, N=self.n) print(self) ncs_c = ncs.NCS_C(ncs_para, p) ncs_res = ncs_c.loop(quiet=quiet, seeds=0) print(ncs_res) self._val = ncs_res
def get_result(ncs_para, data): # print(ncs_para) r = ncs_para["r"] _lambda = ncs_para["lambda"] epoch = ncs_para["epoch"] n = ncs_para["n"] p = data try: ncs_para = ncs.NCS_CParameter(tmax=300000, lambda_exp=_lambda, r=r, epoch=epoch, N=n) ncs_c = ncs.NCS_C(ncs_para, p) ncs_res = ncs_c.loop(quiet=False, seeds=0) except: ncs_res = 1000000000 return ncs_res
raise Exception("not a json format file") _lambda = ncs_para["lambda"] r = ncs_para["r"] epoch = ncs_para["epoch"] n = ncs_para["n"] data = open("result.txt", 'a+') count = 3600 while count >= 0: r = random.uniform(0.889652071711, 0.889652071714) _lambda = random.uniform(0.997467, 0.997473) ncs_para = ncs.NCS_CParameter(tmax=300000, lambda_exp=_lambda, r=r, epoch=epoch, N=n) print("************ start problem %d **********" % p) ncs_c = ncs.NCS_C(ncs_para, p) ncs_res = ncs_c.loop(quiet=False, seeds=0) print("r: {}, lambda: {}, result: {}".format(r, _lambda, ncs_res)) if ncs_res < -459.99999: data.write("r: {}, lambda: {}, result: {}".format( r, _lambda, ncs_res)) data.flush() # if r > 0.837 and r < 0.843: # r += 0.006 # else: count -= 1 # print("r:{}".format(rmin)) data.close()