A patch from Takashi Imamichi. The backtracking line
search now supports Armijo, and regular/strong Wolfe conditions. git-svn-id: file:///home/svnrepos/software/liblbfgs/trunk@58 ecf4c44f-38d1-4fa4-9757-a0b4dd0349fc
This commit is contained in:
		@@ -153,11 +153,12 @@ enum {
 | 
			
		||||
    /** MoreThuente method proposd by More and Thuente. */
 | 
			
		||||
    LBFGS_LINESEARCH_MORETHUENTE = 0,
 | 
			
		||||
    /** Backtracking method with strong Wolfe condition. */
 | 
			
		||||
    LBFGS_LINESEARCH_BACKTRACKING_STRONG = 1,
 | 
			
		||||
    LBFGS_LINESEARCH_BACKTRACKING_STRONG_WOLFE = 1,
 | 
			
		||||
    /** Backtracking method with regular Wolfe condition. */
 | 
			
		||||
    LBFGS_LINESEARCH_BACKTRACKING = 2,
 | 
			
		||||
    /** Backtracking method with regular Wolfe condition. */
 | 
			
		||||
    LBFGS_LINESEARCH_BACKTRACKING_LOOSE = 2,
 | 
			
		||||
    LBFGS_LINESEARCH_BACKTRACKING_WOLFE = 2,
 | 
			
		||||
    /** Backtracking method with Armijo condition. */
 | 
			
		||||
    LBFGS_LINESEARCH_BACKTRACKING_ARMIJO = 3,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										40
									
								
								lib/lbfgs.c
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								lib/lbfgs.c
									
									
									
									
									
								
							@@ -347,8 +347,9 @@ int lbfgs(
 | 
			
		||||
        case LBFGS_LINESEARCH_MORETHUENTE:
 | 
			
		||||
            linesearch = line_search_morethuente;
 | 
			
		||||
            break;
 | 
			
		||||
        case LBFGS_LINESEARCH_BACKTRACKING:
 | 
			
		||||
        case LBFGS_LINESEARCH_BACKTRACKING_STRONG:
 | 
			
		||||
        case LBFGS_LINESEARCH_BACKTRACKING_ARMIJO:
 | 
			
		||||
        case LBFGS_LINESEARCH_BACKTRACKING_WOLFE:
 | 
			
		||||
        case LBFGS_LINESEARCH_BACKTRACKING_STRONG_WOLFE:
 | 
			
		||||
            linesearch = line_search_backtracking;
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
@@ -680,26 +681,33 @@ static int line_search_backtracking(
 | 
			
		||||
 | 
			
		||||
        ++count;
 | 
			
		||||
 | 
			
		||||
        if (*f <= finit + *stp * dgtest) {
 | 
			
		||||
            /* The sufficient decrease condition. */
 | 
			
		||||
 | 
			
		||||
            if (param->linesearch == LBFGS_LINESEARCH_BACKTRACKING_STRONG) {
 | 
			
		||||
                /* Check the strong Wolfe condition. */
 | 
			
		||||
                vecdot(&dg, g, s, n);
 | 
			
		||||
                if (dg > -wolfe * dginit) {
 | 
			
		||||
        if (*f > finit + *stp * dgtest) {
 | 
			
		||||
            width = dec;
 | 
			
		||||
                } else if (dg < wolfe * dginit) {
 | 
			
		||||
        } else {
 | 
			
		||||
            /* The sufficient decrease condition (Armijo condition). */
 | 
			
		||||
            if (param->linesearch == LBFGS_LINESEARCH_BACKTRACKING_ARMIJO) {
 | 
			
		||||
                /* Exit with the Armijo condition. */
 | 
			
		||||
                return count;
 | 
			
		||||
	        }
 | 
			
		||||
 | 
			
		||||
	        /* Check the Wolfe condition. */
 | 
			
		||||
	        vecdot(&dg, g, s, n);
 | 
			
		||||
	        if (dg < wolfe * dginit) {
 | 
			
		||||
    		    width = inc;
 | 
			
		||||
	        } else {
 | 
			
		||||
                    /* Strong Wolfe condition. */
 | 
			
		||||
		        if(param->linesearch == LBFGS_LINESEARCH_BACKTRACKING_WOLFE) {
 | 
			
		||||
		            /* Exit with the regular Wolfe condition. */
 | 
			
		||||
		            return count;
 | 
			
		||||
		        }
 | 
			
		||||
            } else {
 | 
			
		||||
                /* Exit with the loose Wolfe condition. */
 | 
			
		||||
                return count;
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
 | 
			
		||||
		        /* Check the strong Wolfe condition. */
 | 
			
		||||
		        if(dg > -wolfe * dginit) {
 | 
			
		||||
		            width = dec;
 | 
			
		||||
		        } else {
 | 
			
		||||
		            /* Exit with the strong Wolfe condition. */
 | 
			
		||||
		            return count;
 | 
			
		||||
		        }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (*stp < param->min_step) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user