Changeset 155


Ignore:
Timestamp:
07/26/09 14:02:38 (7 years ago)
Author:
altafang
Message:

Moved dn to Solve() to avoid repetitive code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/alta/mystic-0.1a2/mystic/snobfit_solver.py

    r151 r155  
    7979    """Snobfit optimization. """ 
    8080 
    81     def __init__(self, dim, NP): 
     81    def __init__(self, dim): 
    8282        """ 
    8383Takes two initial inputs:  
    8484    dim      -- dimensionality of the problem 
    85     NP   -- size of the trial solution population. NP should be 
    86             len(x0) + numpy.maximum(dn, len(x0)/2) + 1 
    87             where len(x0) = dim, and dn is number of extra 
    88             data points (default dn= 5) 
    89         """ 
    90  
    91         AbstractSolver.__init__(self,dim, npop=NP) 
     85        """ 
     86 
     87        AbstractSolver.__init__(self,dim) 
    9288 
    9389 
     
    163159            numpy.random.seed( [seed] ) 
    164160 
     161        # Adjust if dn was passed as a parameter to Solve() 
     162        adjusted_dn = numpy.maximum(dn, self.nDim/2) 
     163        self.nPop = self.nDim/2 + adjusted_dn + 1 
     164 
    165165        # The number of safeguarded nearest neighbors 
    166166        self.snn = self.nPop - 1 
     
    171171        # Other initializations 
    172172        self.x = self._setInitRecommendedEvalPoints( x0 ) 
    173         #self.x = numpy.asfarray(self.population) 
    174173        (self.f, self.df) = self._setInitial_fdf(func) 
    175174        self.nx = self.x.shape[0] 
     
    24662465    from mystic.termination import SnobfitTermination 
    24672466 
    2468     adjusted_dn = numpy.maximum(dn, len(x0)/2) 
    2469     solver = SnobfitSolver(len(x0), len(x0)+adjusted_dn+1) 
     2467    solver = SnobfitSolver(len(x0)) 
    24702468    solver.SetInitialPoints(x0) 
    24712469    solver.enable_signal_handler() 
Note: See TracChangeset for help on using the changeset viewer.