99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
首頁精彩閱讀優(yōu)化算法—擬牛頓法之DFP算法
優(yōu)化算法—擬牛頓法之DFP算法
2017-03-28
收藏

優(yōu)化算法—擬牛頓法之DFP算法

一、牛頓法

在博文“優(yōu)化算法——牛頓法(Newton Method)”中介紹了牛頓法的思路,牛頓法具有二階收斂性,相比較最速下降法,收斂的速度更快。在牛頓法中使用到了函數(shù)的二階導(dǎo)數(shù)的信息,對于函數(shù),其中x表示向量。在牛頓法的求解過程中,首先是將函數(shù)處展開,展開式為:

其中,,表示的是目標(biāo)函數(shù)在的梯度,是一個(gè)向量。,表示的是目標(biāo)函數(shù)在處的Hesse矩陣。省略掉最后面的高階無窮小項(xiàng),即為:

上式兩邊對x求導(dǎo),即為:

在基本牛頓法中,取得最值的點(diǎn)處的導(dǎo)數(shù)值為0,即上式左側(cè)為0。則:

求出其中的x:

從上式中發(fā)現(xiàn),在牛頓法中要求Hesse矩陣是可逆的。  
當(dāng)時(shí),上式為:

此時(shí),是否可以通過模擬出Hesse矩陣的構(gòu)造過程?此方法便稱為擬牛頓法(QuasiNewton),上式稱為擬牛頓方程。在擬牛頓法中,主要包括DFP擬牛頓法,BFGS擬牛頓法。

二、DFP擬牛頓法

1、DFP擬牛頓法簡介

DFP擬牛頓法也稱為DFP校正方法,DFP校正方法是第一個(gè)擬牛頓法,是有Davidon最早提出,后經(jīng)Fletcher和Powell解釋和改進(jìn),在命名時(shí)以三個(gè)人名字的首字母命名。
對于擬牛頓方程:

化簡可得:

,可以得到:

在DFP校正方法中,假設(shè):

2、DFP校正方法的推導(dǎo)

令:,其中的向量。。
則對于擬牛頓方程可以簡化為:

代入上式:

代入上式:

已知:為實(shí)數(shù)的向量。上式中,參數(shù)a和解的可能性有很多,我們?nèi)√厥獾那闆r,假設(shè)。則:

代入上式:

則:

則最終的DFP校正公式為:

3、DFP擬牛頓法的算法流程

設(shè)對稱正定,由上述的DFP校正公式確定,那么對稱正定的充要條件是。
在博文“優(yōu)化算法——牛頓法(Newton Method)”中介紹了非精確的線搜索準(zhǔn)則:Armijo搜索準(zhǔn)則,搜索準(zhǔn)則的目的是為了幫助我們確定學(xué)習(xí)率,還有其他的一些準(zhǔn)則,如Wolfe準(zhǔn)則以及精確線搜索等。在利用Armijo搜索準(zhǔn)則時(shí)并不是都滿足上述的充要條件,此時(shí)可以對DFP校正公式做些許改變:

DFP擬牛頓法的算法流程如下:

4、求解具體的優(yōu)化問題

求解無約束優(yōu)化問題

其中,。

python程序?qū)崿F(xiàn):
  1. function.py

[python] view plain copy 在CODE上查看代碼片派生到我的代碼片
#coding:UTF-8  
'''''
Created on 2015年5月19日
 
@author: zhaozhiyong
'''  
 
from numpy import *  
 
#fun  
def fun(x):  
    return 100 * (x[0,0] ** 2 - x[1,0]) ** 2 + (x[0,0] - 1) ** 2  
 
#gfun  
def gfun(x):  
    result = zeros((2, 1))  
    result[0, 0] = 400 * x[0,0] * (x[0,0] ** 2 - x[1,0]) + 2 * (x[0,0] - 1)  
    result[1, 0] = -200 * (x[0,0] ** 2 - x[1,0])  
    return result  

dfp.py
[python] view plain copy 在CODE上查看代碼片派生到我的代碼片
#coding:UTF-8  
'''''
Created on 2015年5月19日
 
@author: zhaozhiyong
'''  
 
from numpy import *  
from function import *  
 
def dfp(fun, gfun, x0):  
    result = []  
    maxk = 500  
    rho = 0.55  
    sigma = 0.4  
    m = shape(x0)[0]  
    Hk = eye(m)  
    k = 0  
    while (k < maxk):  
        gk = mat(gfun(x0))#計(jì)算梯度  
        dk = -mat(Hk)*gk  
        m = 0  
        mk = 0  
        while (m < 20):  
            newf = fun(x0 + rho ** m * dk)  
            oldf = fun(x0)  
            if (newf < oldf + sigma * (rho ** m) * (gk.T * dk)[0,0]):  
                mk = m  
                break  
            m = m + 1  
          
        #DFP校正  
        x = x0 + rho ** mk * dk  
        sk = x - x0  
        yk = gfun(x) - gk  
        if (sk.T * yk > 0):  
            Hk = Hk - (Hk * yk * yk.T * Hk) / (yk.T * Hk * yk) + (sk * sk.T) / (sk.T * yk)  
          
        k = k + 1  
        x0 = x  
        result.append(fun(x0))  
      
    return result  

testDFP.py
[python] view plain copy 在CODE上查看代碼片派生到我的代碼片
#coding:UTF-8 數(shù)據(jù)分析師培訓(xùn)
'''''
Created on 2015年5月19日
 
@author: zhaozhiyong
'''  
 
from bfgs import *  
from dfp import dfp  
 
import matplotlib.pyplot as plt    
 
x0 = mat([[-1.2], [1]])  
result = dfp(fun, gfun, x0)  
 
n = len(result)  
ax = plt.figure().add_subplot(111)  
x = arange(0, n, 1)  
y = result  
ax.plot(x,y)  
 
plt.show() 

數(shù)據(jù)分析咨詢請掃描二維碼

若不方便掃碼,搜微信號:CDAshujufenxi

數(shù)據(jù)分析師資訊
更多

OK
客服在線
立即咨詢
客服在線
立即咨詢
') } function initGt() { var handler = function (captchaObj) { captchaObj.appendTo('#captcha'); captchaObj.onReady(function () { $("#wait").hide(); }).onSuccess(function(){ $('.getcheckcode').removeClass('dis'); $('.getcheckcode').trigger('click'); }); window.captchaObj = captchaObj; }; $('#captcha').show(); $.ajax({ url: "/login/gtstart?t=" + (new Date()).getTime(), // 加隨機(jī)數(shù)防止緩存 type: "get", dataType: "json", success: function (data) { $('#text').hide(); $('#wait').show(); // 調(diào)用 initGeetest 進(jìn)行初始化 // 參數(shù)1:配置參數(shù) // 參數(shù)2:回調(diào),回調(diào)的第一個(gè)參數(shù)驗(yàn)證碼對象,之后可以使用它調(diào)用相應(yīng)的接口 initGeetest({ // 以下 4 個(gè)配置參數(shù)為必須,不能缺少 gt: data.gt, challenge: data.challenge, offline: !data.success, // 表示用戶后臺檢測極驗(yàn)服務(wù)器是否宕機(jī) new_captcha: data.new_captcha, // 用于宕機(jī)時(shí)表示是新驗(yàn)證碼的宕機(jī) product: "float", // 產(chǎn)品形式,包括:float,popup width: "280px", https: true // 更多配置參數(shù)說明請參見:http://docs.geetest.com/install/client/web-front/ }, handler); } }); } function codeCutdown() { if(_wait == 0){ //倒計(jì)時(shí)完成 $(".getcheckcode").removeClass('dis').html("重新獲取"); }else{ $(".getcheckcode").addClass('dis').html("重新獲取("+_wait+"s)"); _wait--; setTimeout(function () { codeCutdown(); },1000); } } function inputValidate(ele,telInput) { var oInput = ele; var inputVal = oInput.val(); var oType = ele.attr('data-type'); var oEtag = $('#etag').val(); var oErr = oInput.closest('.form_box').next('.err_txt'); var empTxt = '請輸入'+oInput.attr('placeholder')+'!'; var errTxt = '請輸入正確的'+oInput.attr('placeholder')+'!'; var pattern; if(inputVal==""){ if(!telInput){ errFun(oErr,empTxt); } return false; }else { switch (oType){ case 'login_mobile': pattern = /^1[3456789]\d{9}$/; if(inputVal.length==11) { $.ajax({ url: '/login/checkmobile', type: "post", dataType: "json", data: { mobile: inputVal, etag: oEtag, page_ur: window.location.href, page_referer: document.referrer }, success: function (data) { } }); } break; case 'login_yzm': pattern = /^\d{6}$/; break; } if(oType=='login_mobile'){ } if(!!validateFun(pattern,inputVal)){ errFun(oErr,'') if(telInput){ $('.getcheckcode').removeClass('dis'); } }else { if(!telInput) { errFun(oErr, errTxt); }else { $('.getcheckcode').addClass('dis'); } return false; } } return true; } function errFun(obj,msg) { obj.html(msg); if(msg==''){ $('.login_submit').removeClass('dis'); }else { $('.login_submit').addClass('dis'); } } function validateFun(pat,val) { return pat.test(val); }