Changeset 1065 for trunk/GSASIImath.py
 Timestamp:
 Sep 25, 2013 1:04:46 PM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIImath.py
r1064 r1065 2087 2087 self.T0 = (fmaxfmin)*1.5 2088 2088 return best_state.x 2089 2090 def set_range(self,x0,frac): 2091 delrange = frac*(self.upperself.lower) 2092 self.upper = x0+delrange 2093 self.lower = x0delrange 2089 2094 2090 2095 def accept_test(self, dE): … … 2192 2197 T0=None, Tf=1e12, maxeval=None, maxaccept=None, maxiter=400, 2193 2198 boltzmann=1.0, learn_rate=0.5, feps=1e6, quench=1.0, m=1.0, n=1.0, 2194 lower=100, upper=100, dwell=50, slope=0.9,ranStart=True,dlg=None): 2199 lower=100, upper=100, dwell=50, slope=0.9,ranStart=False, 2200 ranRange=0.10,autoRan=False,dlg=None): 2195 2201 """Minimize a function using simulated annealing. 2196 2202 … … 2235 2241 :param float slope: 2236 2242 Parameter for log schedule 2237 :param bool ranStart= True:2238 False for fixed point start2243 :param bool ranStart=False: 2244 True for set 10% of ranges about x 2239 2245 2240 2246 :returns: (xmin, Jmin, T, feval, iters, accept, retval) where … … 2321 2327 2322 2328 current_state, last_state, best_state = _state(), _state(), _state() 2329 if ranStart: 2330 schedule.set_range(x0,ranRange) 2323 2331 if T0 is None: 2324 2332 x0 = schedule.getstart_temp(best_state) 2325 2333 else: 2326 if ranStart: 2327 x0 = random.uniform(size=len(x0))*(upperlower) + lower #comment to avoid random start 2334 x0 = random.uniform(size=len(x0))*(upperlower) + lower 2328 2335 best_state.x = None 2329 2336 best_state.cost = numpy.Inf … … 2356 2363 best_state.cost = last_state.cost 2357 2364 bestn = n 2365 if best_state.cost < 1.0 and autoRan: 2366 schedule.set_range(x0,best_state.cost/2.) 2358 2367 if dlg: 2359 2368 GoOn = dlg.Update(min(100.,best_state.cost*100), … … 2808 2817 boltzmann=MCSA['boltzmann'], learn_rate=0.5, 2809 2818 quench=MCSA['fast parms'][0], m=MCSA['fast parms'][1], n=MCSA['fast parms'][2], 2810 lower=lower, upper=upper, slope=MCSA['log slope'],ranStart=MCSA.get('ranStart',True),dlg=pgbar) 2819 lower=lower, upper=upper, slope=MCSA['log slope'],ranStart=MCSA.get('ranStart',False), 2820 ranRange=MCSA.get('ranRange',0.10),autoRan=MCSA.get('autoRan',False),dlg=pgbar) 2811 2821 M = mcsaCalc(results[0],refs,rcov,ifInv,allFF,RBdata,varyList,parmDict) 2812 2822 # for ref in refs.T: … … 2897 2907 if d: 2898 2908 V /= d 2909 if not A: #==0. 2910 A = 2.*np.pi 2899 2911 p = A/2. 2900 2912 Q[0] = np.cos(p) … … 2910 2922 Q = np.zeros(4) 2911 2923 d = nl.norm(np.array(V)) 2924 if not A: #== 0.! 2925 A = 360. 2912 2926 if d: 2913 2927 V /= d
Note: See TracChangeset
for help on using the changeset viewer.