# Changeset 1065

Ignore:
Timestamp:
Sep 25, 2013 1:04:46 PM (8 years ago)
Message:

add MC refinement to MC/SA - works

Location:
trunk
Files:
2 edited

Unmodified
Removed
• ## trunk/GSASIImath.py

 r1064 self.T0 = (fmax-fmin)*1.5 return best_state.x def set_range(self,x0,frac): delrange = frac*(self.upper-self.lower) self.upper = x0+delrange self.lower = x0-delrange def accept_test(self, dE): T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50, slope=0.9,ranStart=True,dlg=None): lower=-100, upper=100, dwell=50, slope=0.9,ranStart=False, ranRange=0.10,autoRan=False,dlg=None): """Minimize a function using simulated annealing. :param float slope: Parameter for log schedule :param bool ranStart=True: False for fixed point start :param bool ranStart=False: True for set 10% of ranges about x :returns: (xmin, Jmin, T, feval, iters, accept, retval) where current_state, last_state, best_state = _state(), _state(), _state() if ranStart: schedule.set_range(x0,ranRange) if T0 is None: x0 = schedule.getstart_temp(best_state) else: if ranStart: x0 = random.uniform(size=len(x0))*(upper-lower) + lower #comment to avoid random start x0 = random.uniform(size=len(x0))*(upper-lower) + lower best_state.x = None best_state.cost = numpy.Inf best_state.cost = last_state.cost bestn = n if best_state.cost < 1.0 and autoRan: schedule.set_range(x0,best_state.cost/2.) if dlg: GoOn = dlg.Update(min(100.,best_state.cost*100), boltzmann=MCSA['boltzmann'], learn_rate=0.5, quench=MCSA['fast parms'][0], m=MCSA['fast parms'][1], n=MCSA['fast parms'][2], lower=lower, upper=upper, slope=MCSA['log slope'],ranStart=MCSA.get('ranStart',True),dlg=pgbar) lower=lower, upper=upper, slope=MCSA['log slope'],ranStart=MCSA.get('ranStart',False), ranRange=MCSA.get('ranRange',0.10),autoRan=MCSA.get('autoRan',False),dlg=pgbar) M = mcsaCalc(results[0],refs,rcov,ifInv,allFF,RBdata,varyList,parmDict) #    for ref in refs.T: if d: V /= d if not A:       #==0. A = 2.*np.pi p = A/2. Q[0] = np.cos(p) Q = np.zeros(4) d = nl.norm(np.array(V)) if not A:       #== 0.! A = 360. if d: V /= d