def __init__(self, dim, integrator_type, h0, eps, k, g1, g2, alpha, beta, gamma=1.4, xsph_eps=0, kernel=base.CubicSplineKernel, hks=True): # solver dimension self.dim = dim # Hernquist and Katz normalization self.hks = hks # the SPH kernel to use self.kernel = kernel(dim) self.defaults = dict(alpha=alpha, beta=beta, gamma=gamma, adke_eps=eps, adke_k=k, adke_h0=h0, g1=g1, g2=g2, xsph_eps=xsph_eps) # base class constructor Solver.__init__(self, dim, integrator_type)
def __init__(self, start_rank=1, end_rank=10, rank=5, choose_best=True, convergence_threshold=0.00001, max_iters=200, num_cores=1, svd_algorithm="arpack", init_fill_method="mean", min_value=None, max_value=None, verbose=True): Solver.__init__(self, fill_method=init_fill_method, min_value=min_value, max_value=max_value) self.start_rank = start_rank self.end_rank = end_rank self.rank = rank self.choose_best = choose_best self.max_iters = max_iters self.num_cores = num_cores self.svd_algorithm = svd_algorithm self.convergence_threshold = convergence_threshold self.verbose = verbose
def __init__(self, dst_point, vertex_rect): Solver.__init__(self, dst_point, vertex_rect) self.vertex_rect = self.neighbor_lst # init wgt_lst as [0.0, 0.0, 0.0, 0.0] self.wgt_lst.append(0.0) self.wgt_lst.append(0.0) self.wgt_lst.append(0.0) self.wgt_lst.append(0.0)
def __init__(self, pfile=None): """!Set parameters for PDE to be solved including boundary conditions @param pfile: parameter file for PDEs """ self.solved_flag = False Solver.__init__(self, pfile)
def __init__(self, dim, integrator_type=None): self.dim = dim integrator_type = GSPHIntegrator # base class constructor Solver.__init__(self, dim, integrator_type) self.default_kernel = base.GaussianKernel(dim)
def __init__(self, cells, gamma=0.95, epsilon=0.032, conv=True): """Initializes a solver with additional value iteration parameters: gamma: discount factor (0 < gamma < 1) epsilon: convergence threshold (epsilon > 0). """ Solver.__init__(self, cells) self.gamma = gamma self.epsilon = epsilon self.conv = True
def __init__(self, dim, integrator_type, alpha=1.0, beta=1.0, gamma=1.4, xsph_eps=0): self.dim = dim self.defaults = dict(alpha=alpha, beta=beta, gamma=gamma, xsph_eps=xsph_eps) # base class constructor Solver.__init__(self, dim, integrator_type)
def __init__(self, cells, gamma = 0.95, l = 0.01, epsilon = 0.1, N_iter = 100000): """Initializes a solver with additional q-learning parameters: gamma: discount factor (0 < gamma < 1) l: learning rate (0<l<=1, higher is faster) epsilon: convergence threshold (epsilon > 0) N_iter: number of iterations """ Solver.__init__(self, cells) self.gamma = gamma self.l = l self.epsilon = epsilon self.N_iter = N_iter
def __init__(self, fem, source, physics, mn=None, mf=None, abs_dphi_tol=1e-16, rel_dphi_tol=1e-16, abs_res_tol=None, rel_res_tol=1e-16, max_iter=50, criterion='residual', norm_change='linf', norm_res='linf'): # field rescaling if mf is None: mf = physics.Vev if abs_res_tol is None: # based on size of mass term at infinity, for standard choice of mn size = physics.x0**2 * physics.Vev / mf abs_res_tol = 1e-10 * size Solver.__init__(self, fem, source, physics, mn, mf, 'vev', abs_dphi_tol, rel_dphi_tol, abs_res_tol, rel_res_tol, max_iter, criterion, norm_change, norm_res) # field value at source surface self.Phi_rs = None # gradient at source surface self.grad_Phi_rs = None # maximum gradient self.grad_Phi_max = None # tests from Derrick's theorem self.derrick = None # test of screening self.yukawa = None self.screening_factor = None # useful for plotting self.num_terms = 4
def __init__(self, fem, source, physics, mn=None, mf=None, abs_dphi_tol=1e-16, rel_dphi_tol=1e-16, abs_res_tol=1e-10, rel_res_tol=1e-16, max_iter=50, criterion='residual', norm_change='linf', norm_res='linf'): # field rescaling - results in max size of terms in the equation ~ 1 if mf is None: self.mf = physics.Ms / physics.g / physics.Rs**(physics.D - 2) / physics.M Solver.__init__(self, fem, source, physics, mn, mf, 'vev', abs_dphi_tol, rel_dphi_tol, abs_res_tol, rel_res_tol, max_iter, criterion, norm_change, norm_res) # field value at source surface self.Phi_rs = None # gradient at source surface self.grad_Phi_rs = None # maximum gradient self.grad_Phi_max = None # tests from Derrick's theorem self.derrick = None # test of screening self.yukawa = None self.screening_factor = None # useful for plotting self.num_terms = 4
def __init__(self, dim, integrator_type, h0, eps, k, beta=1.0, K=1.0, f=0.5, gamma=1.4, xsph_eps=0.0, summation_density=True, kernel=base.CubicSplineKernel, hks=True): # set the solver dimension self.dim = dim # Hernquist and Katz normalization self.hks = hks # the SPH kernel to use self.kernel = kernel(dim) # set the defaults self.defaults = dict(gamma=gamma, adke_eps=eps, adke_k=k, adke_h0=h0, beta=beta, K=K, f=f, xsph_eps=xsph_eps, summation_density=summation_density) # base class constructor Solver.__init__(self, dim, integrator_type)
def __init__(self, p, name='some solver'): """p is a problem instance of type MPProb""" Solver.__init__(self, p, name) self.lp = glpk.LPX() # Construct an empty linear program. self.lp.name = self.name self.lp.obj.maximize = self.p.maximize # columns self.lp.cols.add(self.p.numcols) self.lp.obj[:] = list(self.p.obj) for c, lb, ub, in zip(self.lp.cols, self.p.lb, self.p.ub): if np.isinf(lb): lb = None if np.isinf(ub): ub = None c.bounds = lb, ub # set variable types self.changeVarType(self.p.ctype) # rows if self.p.numrows > 0: self.lp.rows.add(self.p.numrows) for i in range(self.p.numrows): row = self.lp.rows[i] if self.p.sense[i] == 'E': row.bounds = self.p.rhs[i] elif self.p.sense[i] == 'L': row.bounds = None, self.p.rhs[i] elif self.p.sense[i] == 'G': row.bounds = self.p.rhs[i], None else: assert False, "wrong sense %s" % (self.p.sense[i],) # matrix coefficients self.lp.matrix = self.p.A.to_coordinate()
def __init__(self, dst_point, neighbor_lst, eps=1.0e-6, power=2): Solver.__init__(self, dst_point, neighbor_lst) self.eps = eps self.power = power
def __init__(self, search_range=None, problem=None, threads=1): Solver.__init__(self, search_range, problem, threads) self.solver_name = 'Brute Force Solver'
def __init__(self, lr): Solver.__init__(self) self.lr_ = lr self.momentum_ = 0.9 self.history_ = []
def __init__( self, visit_sequence='monotone', # order in which we visit the columns n_imputations=100, n_burn_in=10, # this many replicates will be thrown away n_pmm_neighbors=5, # number of nearest neighbors in PMM impute_type='col', # also can be pmm model=BayesianRidgeRegression(lambda_reg=0.001, add_ones=True), n_nearest_columns=np.infty, init_fill_method="mean", min_value=None, max_value=None, verbose=True): """ Parameters ---------- visit_sequence : str Possible values: "monotone" (default), "roman", "arabic", "revmonotone". n_imputations : int Defaults to 100 n_burn_in : int Defaults to 10 impute_type : str "ppm" is probablistic moment matching. "col" (default) means fill in with samples from posterior predictive distribution. n_pmm_neighbors : int Number of nearest neighbors for PMM, defaults to 5. model : predictor function A model that has fit, predict, and predict_dist methods. Defaults to BayesianRidgeRegression(lambda_reg=0.001). Note that the regularization parameter lambda_reg is by default scaled by np.linalg.norm(np.dot(X.T,X)). Sensible lambda_regs to try: 0.1, 0.01, 0.001, 0.0001. n_nearest_columns : int Number of other columns to use to estimate current column. Useful when number of columns is huge. Default is to use all columns. init_fill_method : str Valid values: {"mean", "median", or "random"} (the latter meaning fill with random samples from the observed values of a column) verbose : boolean """ Solver.__init__(self, n_imputations=n_imputations, min_value=min_value, max_value=max_value, fill_method=init_fill_method) self.visit_sequence = visit_sequence self.n_burn_in = n_burn_in self.n_pmm_neighbors = n_pmm_neighbors self.impute_type = impute_type self.model = model self.n_nearest_columns = n_nearest_columns self.verbose = verbose
def __init__(self, path): Solver.__init__(self, path)
def __init__(self, dst_point, pole_pnts, n): Solver.__init__(self, dst_point, pole_pnts) self.num = n
def __init__(self, dst_point, neighbor_lst, eps = 1.0e-6, power = 2): Solver.__init__(self, dst_point, neighbor_lst) self.eps = eps self.power = power
def __init__(self): Solver.__init__(self)
def __init__(self, alpha=0.1, intercept=True): Solver.__init__(self) # parameters self.alpha = alpha # regularization constant self.intercept = intercept # automatically gues intercept and do not regularize