2017-12-06 5 views
0

매우 복잡한 최소화 문제에 대해 scipy.optimize.minimize의 trust-krylov 메소드를 사용하고 있습니다. 여기에 실제 코드를 게시하십시오). 내가 찾은 것은 루틴이 실행되는 것입니다. 많은 반복 이전에 반복되는 목적 함수의 차동 변화가 'tol'키워드 아래로 떨어지면 반복적으로 반복됩니다. 목표 함수 J를 호출하고 반복 i에서 i + 1 로의 변경을 dJ라고합시다.scipy 최소화 'trust-krylov'가 'tol'에 도달하면 중지하지 않는 것 같습니다.

'tol'은 반복 사이의 객관적인 값 dJ의 최소 허용 변화를 의미하는 것으로 이해합니다. 내가 'TOL'을 설정한다면

res=minimize(J,X0,method='trust-krylov', tol=1.e-4, jac=Jacobian,hessp=Hessian) 

같이 4 1.E하는 나는 코드가 DJ가 딥이 값 이하로 유지 후 몇 번 반복 실행을 중지 기대. 그러나 나는 지금 당장 코드를 실행 중이며 dJ는 1.e-8 이하이고 16 번의 반복 및 계산 후에도 계속 실행됩니다. 가능한 버그?

답변

0

귀하는 tol 인수를 오해하고 계십니다.

|obj_i - obj_i-1| (스칼라 계산)이지만 약 : ||grad_i||_p (벡터 계산)은 아닙니다.

종종 후자의 조건이 사용되며 대부분의 비선형 최적화 프로그램의 일부입니다 (특히 KKT 조건 또는 2 차 정보를 사용할 수없는 경우). 그것은 또한 이론을 직접적으로 따릅니다 :로컬 최적 점에 대한 1 차 필요한 최적 조건.

당신은 소스를 볼 수 있습니다 :

here: tol becomes gtol :

if meth in ('bfgs', 'cg', 'l-bfgs-b', 'tnc', 'dogleg', 
      'trust-ncg', 'trust-exact', 'trust-krylov'): 
    options.setdefault('gtol', tol) 

here: _minimize_trust_krylov is called :

elif meth == 'trust-krylov': 
    return _minimize_trust_krylov(fun, x0, args, jac, hess, hessp, 
            callback=callback, **options) 

_trustregion_krylov talks about the oder conditionsexact/inexact에 따라 최종 최적화 프로그램이 호출됩니다

if inexact: 
    return _minimize_trust_region(fun, x0, args=args, jac=jac, 
            hess=hess, hessp=hessp, 
            subproblem=get_trlib_quadratic_subproblem(
             tol_rel_i=-2.0, tol_rel_b=-3.0, 
             disp=trust_region_options.get('disp', False) 
            ), 
            **trust_region_options) 
else: 
    return _minimize_trust_region(fun, x0, args=args, jac=jac, 
            hess=hess, hessp=hessp, 
            subproblem=get_trlib_quadratic_subproblem(
             tol_rel_i=1e-8, tol_rel_b=1e-6, 
             disp=trust_region_options.get('disp', False) 
            ), 
            **trust_region_options) 

the optimizer used 함유 다음 행 :

gtol : float 
    Gradient norm must be less than `gtol` 
    before successful termination. 

# check if the gradient is small enough to stop 
if m.jac_mag < gtol: 
    warnflag = 0 
    break 

# check if we have looked at enough iterations 
if k >= maxiter: 
    warnflag = 1 
    break 

here jac_mag is found는 :

은이 대답의 시작과 유클리드 놈 다음
@property 
def jac_mag(self): 
    """Magniture of jacobian of objective function at current iteration.""" 
    if self._g_mag is None: 
     self._g_mag = scipy.linalg.norm(self.jac) 
    return self._g_mag 

(p = 2가) 사용된다!