青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

eryar

PipeCAD - Plant Piping Design Software.
RvmTranslator - Translate AVEVA RVM to OBJ, glTF, etc.
posts - 603, comments - 590, trackbacks - 0, articles - 0

Use PSO to find minimum in OpenCASCADE

Posted on 2017-04-18 22:51 eryar 閱讀(1331) 評論(0)  編輯 收藏 引用 所屬分類: 2.OpenCASCADE

Use PSO to find minimum in OpenCASCADE

eryar@163.com

Abstract. Starting from OCCT6.8.0 will include one more algorithm for solving global optimization problems. Its development has been triggered by insufficient performance and robustness of existing algorithm of minimization of curve-surface distance in Extrema package. The PSO, Algorithms in this family are stochastic, and this feature can be perceived as opposite to robustness. However, we found it was not only much faster than original deterministic one, but also more robust in complex real-world situations. In particular, it has been able to find solution in situations like tangential or degenerated geometries where deterministic algorithms work poor and require extensive oversampling for robust results. The paper mainly focus on the usage and applications of the PSO algorithm.

Key Words. PSO, Particle Swarm Optimization, Minimization

1.Introduction

粒子群優(yōu)化(Particle Swarm Optimization, PSO)算法是Kennedy和Eberhart受人工生命研究結(jié)果的啟發(fā)、通過模擬鳥群覓食過程中的遷徙和群聚行為而提出的一種基于群體智能的全局隨機搜索算法,自然界中各種生物體均具有一定的群體行為,而人工生命的主要研究領(lǐng)域之一是探索自然界生物的群體行為,從而在計算機上構(gòu)建其群體模型。自然界中的鳥群和魚群的群體行為一直是科學(xué)家的研究興趣,生物學(xué)家Craig Reynolds在1987年提出了一個非常有影響的鳥群聚集模型,在他的仿真中,每一個個體遵循:

      (1) 避免與鄰域個體相沖撞;

      (2) 匹配鄰域個體的速度;

      (3) 飛向鳥群中心,且整個群體飛向目標(biāo)。

仿真中僅利用上面三條簡單的規(guī)則,就可以非常接近的模擬出鳥群飛行的現(xiàn)象。1995年,美國社會心理學(xué)家James Kennedy和電氣工程師Russell Eberhart共同提出了粒子群算法,其基本思想是受對鳥類群體行為進(jìn)行建模與仿真的研究結(jié)果的啟發(fā)。他們的模型和仿真算法主要對Frank Heppner的模型進(jìn)行了修正,以使粒子飛向解空間并在最好解處降落。Kennedy在他的書中描述了粒子群算法思想的起源。

粒子群優(yōu)化由于其算法簡單,易于實現(xiàn),無需梯度信息,參數(shù)少等特點在連續(xù)優(yōu)化問題和離散問題中都表現(xiàn)出良好的效果,特別是因為其天然的實數(shù)編碼特點適合處理實優(yōu)化問題。近年來成為國際上智能優(yōu)化領(lǐng)域研究的熱點。PSO算法最早應(yīng)用于非線性連續(xù)函數(shù)的優(yōu)化和神經(jīng)元網(wǎng)絡(luò)的訓(xùn)練,后來也被用于解決約束優(yōu)化問題、多目標(biāo)優(yōu)化問題,動態(tài)優(yōu)化問題等。

在OpenCASCADE中很多問題可以歸結(jié)為非線性連續(xù)函數(shù)的優(yōu)化問題,如求極值的包中計算曲線和曲面之間的極值點,或曲線與曲線間的極值點等問題。本文主要關(guān)注OpenCASCADE中PSO的用法,在理解其用法的基礎(chǔ)上再來理解其他相關(guān)的應(yīng)用。

2. PSO Usage

為了提高程序的性能及穩(wěn)定性,OpenCASCADE引入了智能化的算法PSO(Particle Swarm Optimization),相關(guān)的類為math_PSO,其類聲明的代碼如下:


//! In this class implemented variation of Particle Swarm Optimization (PSO) method.
//! A. Ismael F. Vaz, L. N. Vicente 
//! "A particle swarm pattern search method for bound constrained global optimization"
//!
//! Algorithm description:
//! Init Section:
//! At start of computation a number of "particles" are placed in the search space.
//! Each particle is assigned a random velocity.
//!
//! Computational loop:
//! The particles are moved in cycle, simulating some "social" behavior, so that new position of
//! a particle on each step depends not only on its velocity and previous path, but also on the
//! position of the best particle in the pool and best obtained position for current particle.
//! The velocity of the particles is decreased on each step, so that convergence is guaranteed.
//!
//! Algorithm output:
//! Best point in param space (position of the best particle) and value of objective function.
//!
//! Pros:
//! One of the fastest algorithms.
//! Work over functions with a lot local extremums.
//! Does not require calculation of derivatives of the functional.
//!
//! Cons:
//! Convergence to global minimum not proved, which is a typical drawback for all stochastic algorithms.
//! The result depends on random number generator.
//!
//! Warning: PSO is effective to walk into optimum surrounding, not to get strict optimum.
//! Run local optimization from pso output point.
//! Warning: In PSO used fixed seed in RNG, so results are reproducible.

class math_PSO
{
public:

  /**
  * Constructor.
  *
  * @param theFunc defines the objective function. It should exist during all lifetime of class instance.
  * @param theLowBorder defines lower border of search space.
  * @param theUppBorder defines upper border of search space.
  * @param theSteps defines steps of regular grid, used for particle generation.
                    This parameter used to define stop condition (TerminalVelocity).
  * @param theNbParticles defines number of particles.
  * @param theNbIter defines maximum number of iterations.
  
*/
  Standard_EXPORT math_PSO(math_MultipleVarFunction* theFunc,
                           const math_Vector& theLowBorder,
                           const math_Vector& theUppBorder,
                           const math_Vector& theSteps,
                           const Standard_Integer theNbParticles = 32,
                           const Standard_Integer theNbIter = 100);

  //! Perform computations, particles array is constructed inside of this function.
  Standard_EXPORT void Perform(const math_Vector& theSteps,
                               Standard_Real& theValue,
                               math_Vector& theOutPnt,
                               const Standard_Integer theNbIter = 100);

  //! Perform computations with given particles array.
  Standard_EXPORT void Perform(math_PSOParticlesPool& theParticles,
                               Standard_Integer theNbParticles,
                               Standard_Real& theValue,
                               math_Vector& theOutPnt,
                               const Standard_Integer theNbIter = 100);

private:

  void performPSOWithGivenParticles(math_PSOParticlesPool& theParticles,
                                    Standard_Integer theNbParticles,
                                    Standard_Real& theValue,
                                    math_Vector& theOutPnt,
                                    const Standard_Integer theNbIter = 100);

  math_MultipleVarFunction *myFunc;
  math_Vector myLowBorder; // Lower border.
  math_Vector myUppBorder; // Upper border.
  math_Vector mySteps; // steps used in PSO algorithm.
  Standard_Integer myN; // Dimension count.
  Standard_Integer myNbParticles; // Particles number.
  Standard_Integer myNbIter;
};

math_PSO的輸入主要為:求極小值的多元函數(shù)math_MultipleVarFunction,各個自變量的取值范圍。下面通過一個具體的例子來說明如何將數(shù)學(xué)問題轉(zhuǎn)換成代碼,利用程序來求解。在《最優(yōu)化方法》中找到如下例題:

wps266B.tmp

實現(xiàn)代碼如下所示:

/*
Copyright(C) 2017 Shing Liu(eryar@163.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

// NOTE
// ----
// Tool: Visual Studio 2013 & OpenCASCADE7.1.0
// Date: 2017-04-18  20:52 

#include <math_PSO.hxx>

#pragma comment(lib, "TKernel.lib")
#pragma comment(lib, "TKMath.lib")

// define function:
// f(x) = x1 - x2 + 2x1^2 + 2x1x2 + x2^2
class TestFunction : public math_MultipleVarFunction
{
public:
    virtual Standard_Integer NbVariables() const
    {
        return 2;
    }

    virtual Standard_Boolean Value(const math_Vector& X, Standard_Real& F)
    {
        F = X(1) - X(2) + 2.0 * X(1) * X(1) + 2.0 * X(1) * X(2) + X(2) * X(2);

        return Standard_True;
    }

};


void test()
{
    TestFunction aFunction;
    math_Vector aLowerBorder(1, aFunction.NbVariables());
    math_Vector aUpperBorder(1, aFunction.NbVariables());
    math_Vector aSteps(1, aFunction.NbVariables());

    aLowerBorder(1) = -10.0;
    aLowerBorder(2) = -10.0;

    aUpperBorder(1) = 10.0;
    aUpperBorder(2) = 10.0;

    aSteps(1) = 0.1;
    aSteps(2) = 0.1;

    Standard_Real aValue = 0.0;
    math_Vector aOutput(1, aFunction.NbVariables());

    math_PSO aPso(&aFunction, aLowerBorder, aUpperBorder, aSteps);
    aPso.Perform(aSteps, aValue, aOutput);

    std::cout << "Minimum value: " << aValue << " at (" << aOutput(1) << ", " << aOutput(2) << ")" << std::endl;

}

int main(int argc, char* argv[])
{
    test();

    return 0;
}

計算結(jié)果為最小值-1.25, 在x1=-1,x2=1.50013處取得,如下圖所示:

wps267B.tmp

3.Applications

計算曲線和曲面之間的極值,也是一個計算多元函數(shù)的極值問題。對應(yīng)的類為Extrema_GenExtCS。

4.Conclusion

常見的優(yōu)化算法如共軛梯度法、Netwon-Raphson法(math_NewtonMinimum),F(xiàn)letcher-Reeves法(math_FRPR)、Broyden-Fletcher-Glodfarb-Shanno法(math_BFGS)等都是局部優(yōu)化方法,所有這些局部優(yōu)化方法都是針對無約束優(yōu)化問題提出的,而且對目標(biāo)函數(shù)均有一定的解析性要求,如Newton-Raphson要求目標(biāo)函數(shù)連續(xù)可微,同時要求其一階導(dǎo)數(shù)連續(xù)。OpenCASCADE中的math_NewtonMinimu中還要求多元函數(shù)具有Hessian矩陣,即二階導(dǎo)數(shù)連續(xù)。

隨著現(xiàn)科學(xué)技術(shù)的不斷發(fā)展和多學(xué)科的相互交叉與滲透,很多實際工程優(yōu)化問題不僅需要大量的復(fù)雜科學(xué)計算,而且對算法的實時性要求也特別高,這些復(fù)雜優(yōu)化問題通常具有以下特點:

1) 優(yōu)化問題的對象涉及很多因素,導(dǎo)致優(yōu)化問題的目標(biāo)函數(shù)的自變量維數(shù)很多,通常達(dá)到數(shù)百維甚至上萬維,使得求解問題的計算量大大增加;

2) 優(yōu)化問題本身的復(fù)雜性導(dǎo)致目標(biāo)函數(shù)是非線性,同時由于有些目標(biāo)函數(shù)具有不可導(dǎo),不連續(xù)、極端情況下甚至函數(shù)本身不能解析的表達(dá);如曲線或曲面退化導(dǎo)致的尖點或退化點的不連續(xù)情況;

3) 目標(biāo)函數(shù)在定義域內(nèi)具有多個甚至無數(shù)個極值點,函數(shù)的解空間形狀復(fù)雜。

當(dāng)以上三個因素中一個或幾個出現(xiàn)在優(yōu)化問題中時,將會極大地增加優(yōu)化問題求解的困難程度,單純地基于解析確定性的優(yōu)化方法很難奏效,因此必須結(jié)合其他方法來解決這些問題。

PSO算法簡單,易于實現(xiàn)且不需要目標(biāo)函數(shù)的梯度(一階可導(dǎo))和Hassian矩陣(二階可導(dǎo)),速度快,性能高。但是PSO也有不足之處,這是許多智能算法的共性,即只能找到滿足條件的解,這個解不能確定為精確解。

5.References

1. aml. Application of stohastic algorithms in extrema. https://dev.opencascade.org/index.php?q=node/988

2. 何堅勇. 最優(yōu)化方法. 清華大學(xué)出版社. 2007

3. 沈顯君. 自適應(yīng)粒子群優(yōu)化算法及其應(yīng)用. 清華大學(xué)出版社. 2015

4. 汪定偉, 王俊偉, 王洪峰, 張瑞友, 郭哲. 智能優(yōu)化方法. 高等教育出版社. 2007

 

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久久免费av| 国产精品v欧美精品v日本精品动漫| 欧美日韩国产精品一区二区亚洲| 日韩视频精品在线| 一区二区毛片| 韩国精品在线观看| 亚洲国产裸拍裸体视频在线观看乱了| 免费视频一区| 久久久精品一区二区三区| 国产区精品视频| 亚洲一级免费视频| 欧美激情一区二区三区成人| 国产午夜精品理论片a级探花| 午夜激情综合网| 亚洲高清久久| 亚洲乱码精品一二三四区日韩在线 | 亚洲狼人精品一区二区三区| 亚洲黄色影片| 国产婷婷一区二区| 日韩亚洲欧美成人| 亚洲丶国产丶欧美一区二区三区| 亚洲毛片在线观看| 黑人巨大精品欧美一区二区| 99riav久久精品riav| 狠狠色丁香婷婷综合| 日韩视频在线观看免费| 亚洲精品永久免费精品| 久久欧美中文字幕| 久久三级福利| 国内成人精品2018免费看| 中国av一区| 亚洲免费在线视频| 欧美视频在线视频| 9久re热视频在线精品| 夜色激情一区二区| 欧美欧美午夜aⅴ在线观看| 欧美国产精品va在线观看| 国产专区一区| 久久久久一区二区三区四区| 久久久久久久久久久久久女国产乱 | 免费在线成人av| 黄色成人av| 欧美一区二区三区播放老司机 | 免费亚洲网站| 91久久久久久久久| 欧美国产一区二区三区激情无套| 欧美电影免费| 午夜精品免费在线| 精品1区2区| 欧美午夜激情视频| 久久久国产91| 亚洲一区日韩在线| 玖玖玖国产精品| 亚洲香蕉在线观看| 国产九九精品视频| 欧美激情亚洲一区| 欧美尤物一区| 亚洲在线中文字幕| 亚洲国产黄色| 欧美a级一区| 亚洲欧美在线一区二区| 亚洲国产欧美精品| 国产日韩欧美在线| 国产精品一区二区欧美| 欧美日韩福利视频| 欧美激情1区| 久久精视频免费在线久久完整在线看| 亚洲激情电影在线| 亚洲大胆美女视频| 欧美黑人在线观看| 美女爽到呻吟久久久久| 久久伊人一区二区| 久热re这里精品视频在线6| 久久aⅴ国产欧美74aaa| 亚洲午夜在线| 午夜电影亚洲| 久久精品99无色码中文字幕| 亚洲伊人网站| 欧美一区二区视频在线观看2020| 亚洲性感激情| 欧美亚洲视频| 亚洲精品视频在线观看网站| 在线免费不卡视频| 亚洲综合视频网| 欧美日本国产在线| 91久久国产综合久久| 亚洲三级电影全部在线观看高清| 欧美在线免费观看视频| 亚洲宅男天堂在线观看无病毒| 欧美日韩国产不卡| 亚洲素人在线| 亚洲一区二区免费看| 国产精品视频免费在线观看| 亚洲综合日韩中文字幕v在线| 欧美国产第一页| 欧美精品国产精品| 亚洲影院免费| 久久精品一区二区三区四区| 国产一区 二区 三区一级| 蜜桃伊人久久| 欧美日本一道本| 欧美一区二区三区播放老司机| 欧美一区二区在线| 亚洲日本免费| 久久久久国色av免费看影院| 亚洲福利在线看| 亚洲午夜av在线| 亚洲福利免费| 亚洲一区影院| 这里是久久伊人| 久久黄色影院| 午夜日韩av| 欧美精品一区二区视频| 久久精品日韩一区二区三区| 老司机午夜精品| 久久综合九色综合欧美狠狠| 美女视频黄 久久| 亚洲性感美女99在线| 国产精品xvideos88| 欧美在线播放视频| 美国成人直播| 美国三级日本三级久久99| 欧美日韩理论| 亚洲精品1区| 精久久久久久| 久久精品国产第一区二区三区| 亚洲乱码国产乱码精品精天堂 | 亚洲国产精品成人精品| 欧美视频导航| 亚洲午夜av在线| 久久久精彩视频| 亚洲一区三区视频在线观看| 久久亚洲一区| 两个人的视频www国产精品| 欧美麻豆久久久久久中文| 欧美激情导航| 99国产一区二区三精品乱码| 篠田优中文在线播放第一区| 亚洲一二三区精品| 欧美久久电影| 91久久精品国产91性色tv| 狠狠色综合色综合网络| 欧美亚洲一区三区| 国产一区自拍视频| 午夜日韩激情| 亚洲国产高清一区| 一区二区三区回区在观看免费视频| 欧美风情在线| 亚洲——在线| 免费观看日韩av| 亚洲视频播放| 亚洲高清毛片| 国产麻豆综合| 麻豆免费精品视频| 一区二区三区四区蜜桃| 欧美一二三视频| 在线免费观看欧美| 国产精品一区二区久久| 欧美搞黄网站| 国产亚洲欧美日韩日本| 亚洲视频在线观看| 久久久国产视频91| 欧美亚洲成人网| 欧美激情在线播放| 亚洲欧美中文另类| 亚洲电影免费观看高清完整版在线| 久久久久国色av免费看影院| 夜夜嗨av一区二区三区免费区| 欧美成人一区在线| 欧美激情四色 | 欧美国产精品人人做人人爱| 亚洲黄色在线观看| 欧美一区二区免费视频| 欧美日韩精品一区视频 | 亚洲黄色免费电影| 老牛国产精品一区的观看方式| 亚洲一区二区三区高清| 亚洲私人影院| 久久久综合精品| 亚洲黄色成人久久久| 一本一本大道香蕉久在线精品| 99精品99久久久久久宅男| 日韩系列在线| 久久一二三区| 国产精品豆花视频| 亚洲精品视频一区| 久久久久久久久伊人| 亚洲国产激情| 女人香蕉久久**毛片精品| 国产综合在线视频| 欧美日韩国产电影| 久久精品二区| 免费成人黄色片| 欧美网站在线观看| 国产视频一区在线观看| 亚洲韩国日本中文字幕| 亚洲在线中文字幕| 亚洲全部视频| 蘑菇福利视频一区播放| 国产欧美在线观看|