# OPEN CASCADE Multiple Variable Function

## OPEN CASCADE Multiple Variable Function

eryar@163.com

Abstract. Multiple variable function with gradient and Hessian matrix is very very import in OPEN CASCADE optimization algorithms. In order to understand these optimization algorithm better, let’s study some basic knowledge about Gradient, Hessian Matrix.

Key Words. Multiple Variable Function, Gradient, Hessian Matrix, 最优化算法,

1. Introduction

Figure 1.1 Multiple Variable Function in OPEN CASCADE

2.Multiple Variable Function

Figure 2.1 math_MultipleVarFunction class diagram

v NbVariables() const = 0：自变量的个数；

v Value(const math_Vector& X, Standard_Real& F) = 0：计算指定自变量X对应的函数值F。自变量X是个向量，其中的值分别对应多个自变量；

```/*
*
*           File : main.cpp
*         Author : Shing Liu(eryar@163.com)
*           Date : 2015-11-28 21:00
*
*    Description : Test Gauss Multiple integration.
*/

#define WNT
#include <math_MultipleVarFunction.hxx>
#include <math_GaussMultipleIntegration.hxx>

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

class math_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(1) + X(2) * X(2);

return Standard_True;
}
};

void testMultipleIntegration(void)
{
math_Vector aLower(1, 2);
math_Vector aUpper(1, 2);
math_IntegerVector aOrder(1, 2, 10);

aLower(1) = -1.0;
aLower(2) = -1.0;

aUpper(1) =  1.0;
aUpper(2) =  1.0;

math_TestFunction aFunction;
math_GaussMultipleIntegration aIntegrator(aFunction, aLower, aUpper, aOrder);

if (aIntegrator.IsDone())
{
std::cout << aIntegrator;
}
}

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

return 0;
}```

Figure 2.2 Integration Value

http://www.cppblog.com/eryar/archive/2014/09/11/208275.html

v NbVariables() const = 0：多元函数自变量个数；

v Value(const math_Vector& X, Standard_Real& F) = 0：计算多元函数在指定变量X处对应的函数值F，通过引用传出；

v Gradient(const math_Vector& X, math_Vector& G) = 0：计算多元函数在指定变量X处的梯度值，通过引用传出；

v Values(const math_Vector& X, Standard_Real& F, math_Vector& G) = 0：计算多元函数在指定变量X处的函数值F和梯度值G；

4.Hessian Matrix

Figure 4.1 math_MultipleVarFunctionWithHessian class diagram

Values(const math_Vector&X, Standard_Real&F, math_Vector&G, math_Matrix&H) = 0

Figure 4.2 math_MultipleVarFunctionWithHessian class diagram

5.Conclusion

6. References

1. 同济大学数学教研室. 高等数学. 高等教育出版社. 1996

2. 同济大学应用数学系. 线性代数. 高等教育出版社. 2003

3. 易大义, 陈道琦. 数值分析引论. 浙江大学出版社. 1998

4. 《运筹学》教材编写组. 运筹学. 清华大学出版社. 2012

5. 何坚勇. 最优化方法. 清华大学出版社. 2007

6. 杨庆之. 最优化方法. 科学出版社. 2015

7. 王宜举, 修乃华. 非线性最优化理论与方法. 科学出版社. 2012