- Timestamp:
- 03/29/16 14:18:53 (7 weeks ago)
- Location:
- mystic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
mystic/examples/test_peaks.py
r855 r858 16 16 nd = 2 17 17 npop = 20 18 tol = 0.05 18 19 lb = [-3.]*nd 19 20 ub = [3.]*nd … … 28 29 solver.SetRandomInitialPoints(lb, ub) 29 30 solver.SetStrictRanges(lb, ub) 30 term = VTR( )31 term = VTR(tol) 31 32 #term = COG() 32 33 solver.Solve(peaks, term, disp=True) … … 34 35 print 'solution = ', sol 35 36 print 'expected = [0.23, -1.63]' 37 38 try: 39 from scipy.stats import uniform 40 except ImportError: 41 exit() 42 43 print '-'*60 44 print 'using a uniform distribution...' 45 solver = DifferentialEvolutionSolver(nd, npop) 46 solver.SetDistributionInitialPoints(uniform(lb[0],ub[0])) 47 solver.SetStrictRanges(lb, ub) 48 term = VTR(tol) 49 #term = COG() 50 solver.Solve(peaks, term, disp=True) 51 sol = solver.Solution() 52 print 'solution = ', sol 53 print 'expected = [0.23, -1.63]' 54 55 56 -
mystic/mystic/abstract_solver.py
r855 r858 400 400 self.population[i][j] = random.uniform(min[j],max[j]) 401 401 402 def SetMultinormalInitialPoints(self, mean, var =None):402 def SetMultinormalInitialPoints(self, mean, var=None): 403 403 """Generate Initial Points from Multivariate Normal. 404 404 … … 424 424 for i in range(len(self.population)): 425 425 self.population[i] = prng.multivariate_normal(mean, var).tolist() 426 return 427 428 def SetDistributionInitialPoints(self, dist): 429 """Generate Random Initial Points from Distribution (dist) 430 431 input:: 432 - dist: a scipy.stats distribution instance""" 433 from mystic.tools import random_state 434 prng = random_state(module='numpy.random') 435 for i in range(self.nPop): 436 self.population[i] = dist.rvs(self.nDim, random_state=prng).tolist() 426 437 return 427 438 … … 840 851 continue 841 852 853 # keep stepping if collapse 854 # while collapse and cc.collapse(self, verbose=False): 855 # while not self.Step(**settings): 856 # continue 857 842 858 # restore default handler for signal interrupts 843 859 if self._handle_sigint:
Note: See TracChangeset
for help on using the changeset viewer.