Changeset 1065
 Timestamp:
 Sep 25, 2013 1:04:46 PM (10 years ago)
 Location:
 trunk
 Files:

 2 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 
trunk/GSASIIphsGUI.py
r1060 r1065 696 696 def OnRanStart(event): 697 697 MCSAdata['ranStart'] = ranStart.GetValue() 698 699 def OnAutoRan(event): 700 MCSAdata['autoRan'] = autoRan.GetValue() 701 702 def OnRanRange(event): 703 try: 704 val = float(ranRange.GetValue())/100 705 if 0.01 <= val <= 0.99: 706 MCSAdata['ranRange'] = val 707 except ValueError: 708 pass 709 ranRange.SetValue('%.1f'%(MCSAdata['ranRange']*100.)) 698 710 699 711 def OnAnneal(event): … … 745 757 line2Sizer.Add(cycles,0,wx.ALIGN_CENTER_VERTICAL) 746 758 line2Sizer.Add((5,0),) 747 ranStart = wx.CheckBox(General,1,label=' Random start? (ignored if Start temp = None)')759 ranStart = wx.CheckBox(General,1,label=' MC/SA Refine at ') 748 760 ranStart.Bind(wx.EVT_CHECKBOX, OnRanStart) 749 ranStart.SetValue(MCSAdata.get('ranStart',True)) 750 line2Sizer.Add(ranStart,0,wx.ALIGN_CENTER_VERTICAL) 761 ranStart.SetValue(MCSAdata.get('ranStart',False)) 762 line2Sizer.Add(ranStart,0,wx.ALIGN_CENTER_VERTICAL) 763 ranRange = wx.TextCtrl(General,1,value='%.1f'%(MCSAdata.get('ranRange',0.10)*100),style=wx.TE_PROCESS_ENTER) 764 ranRange.Bind(wx.EVT_TEXT_ENTER,OnRanRange) 765 ranRange.Bind(wx.EVT_KILL_FOCUS,OnRanRange) 766 line2Sizer.Add(ranRange,0,wx.ALIGN_CENTER_VERTICAL) 767 line2Sizer.Add(wx.StaticText(General,label='% of ranges. '),0,wx.ALIGN_CENTER_VERTICAL) 768 # autoRan = wx.CheckBox(General,1,label=' Do auto range reduction? ') 769 # autoRan.Bind(wx.EVT_CHECKBOX, OnAutoRan) 770 # autoRan.SetValue(MCSAdata.get('autoRan',False)) 771 # line2Sizer.Add(autoRan,0,wx.ALIGN_CENTER_VERTICAL) 751 772 mcsaSizer.Add(line2Sizer) 752 773 mcsaSizer.Add((5,5),) … … 4066 4087 try: 4067 4088 Anew = float(ObjA.GetValue()) 4089 if not Anew: #==0.0! 4090 Anew = 360. 4068 4091 except ValueError: 4069 4092 Anew = A … … 4076 4099 else: 4077 4100 ObjA.SetValue('%.5f'%(A)) 4101 ObjV.SetValue('%.3f %.3f %.3f'%(V[0],V[1],V[2])) 4078 4102 G2plt.PlotStructure(G2frame,data) 4079 UpdateMCSA()4103 # UpdateMCSA() 4080 4104 4081 4105 def OnMolCent(event):
Note: See TracChangeset
for help on using the changeset viewer.