File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ aca = np.ascontiguousarray
6262cdef ParameterVector make_params(a, s, dlist) except * :
6363 cdef ParameterVector ret
6464 cdef vector[adouble] r
65+ assert np.all(a > 0 )
6566 assert len (a) > 0
6667 for aa in a:
6768 if not isinstance (aa, ADF):
Original file line number Diff line number Diff line change @@ -168,11 +168,16 @@ def __call__(self, x):
168168
169169 def match (self , other_model ):
170170 a = np .cumsum (self .s )
171+ a0 = np .cumsum (other_model .s )
171172 def f (x ):
172173 self [:] = x
173- return ((self (a ).astype ('float' ) - other_model (a ).astype ('float' )) ** 2 ).sum ()
174- res = scipy .optimize .minimize (f , self [:].astype ('float' ))
175- # logger.debug(res)
174+ r1 = ((self (a ).astype ('float' ) - other_model (a ).astype ('float' )) ** 2 ).sum ()
175+ r2 = ((self (a0 ).astype ('float' ) - other_model (a0 ).astype ('float' )) ** 2 ).sum ()
176+ return r1 + r2
177+ m = other_model [:].astype ('float' ).min ()
178+ M = other_model [:].astype ('float' ).max ()
179+ bounds = ((m , M ),) * len (self [:])
180+ res = scipy .optimize .minimize (f , self [:].astype ('float' ), bounds = bounds )
176181 self [:] = res .x
177182
178183 def stepwise_values (self ):
You can’t perform that action at this time.
0 commit comments