主要内容

hyperbolicPenalty

相对于有限区域的点的双曲线罚值

    Description

    example

    p= hyperbolicPenalty(x,xmin,xmax)calculates the nonnegative (hyperbolic) penalty vectorp为了pointxwith respect to the region bounded byxminxmax.phas the same dimension asx. This syntax uses the default values of10.1为了lambdatau双曲线函数的参数。

    example

    p= hyperbolicPenalty(___,lambda,tau)specifies both thelambdatauparameters of the hyperbolic function. Iflambdais an empty matrix its default value is used. Likewise iftauis an empty matrix or it is omitted, its default value is used instead.

    Examples

    collapse all

    This example shows how to use thehyperbolicPenaltyfunction to calculate the hyperbolic penalty for a given point with respect to a bounded region.

    Calculate the penalty value for the point0.1within the interval [-2,2],使用默认值lambdatauparameters.

    hyperbolicPenalty(0.1,-2,2)
    ANS = 0.0050

    Calculate the penalty value for the point4outside the interval [-2,2].

    hyperbolicPenalty(4,-2,2)
    ans = 4.0033

    Calculate the penalty value for the point0.1within the interval [-2,2], using alambda参数5.

    hyperbolicPenalty(0.1,-2,2,5)
    ans = 0.0010

    Calculate the penalty value for the point4outside the interval [-2,2], using alambda参数5.

    hyperbolicPenalty(4,-2,2,5)
    ans = 20.0007

    Calculate the penalty value for the point4outside the interval [-2,2], using atau参数0.5.

    双曲线(4,-2,2,5,0.5)
    ans = 20.0167

    计算该点的罚款值[-2,0,4] with respect to the box defined by the intervals [0,1],[[-1,1], and [-2,2] along the x, y, and z dimensions, respectively, using the default value forlambdatau参数0.

    跃升([-2 0 4],[0 -1 -2],[1 1 2],1,0)
    ans =3×14 0 4

    Visualize Penalty Values for an Interval

    创建一个分布在 -55.

    x = -5:0.01:5;

    Calculate penalties for all the points in the vector, using default values for thelambdatauparameters.

    p =双曲线(x,-2,2);

    Plot the points and add grid, labels and title.

    plot(x,p) grid xlabel("point position");ylabel("penalty value");标题("Penalty values over an interval");

    Input Arguments

    collapse all

    计算惩罚的点,指定为数字标量,向量或矩阵。

    Example:[0.5; 1.6]

    下限x, specified as a numeric scalar, vector or matrix. To use the same minimum value for all elements inxspecifyxminas a scalar.

    Example:-1

    上限forx, specified as a numeric scalar, vector or matrix. To use the same maximum value for all elements inxspecifyxmaxas a scalar.

    Example:2

    双曲线功能的lambda参数, specified as a scalar.

    Example:3

    双曲线函数的TAU参数,指定为标量。

    Example:0.3

    Output Arguments

    collapse all

    刑罚的价值,作为一个返回vector of nonnegative elements. Each elementpi取决于xi关于由xminixmaxi. The hyperbolic penalty function returns the value:

    p ( x ) = λ ( x x min ) + λ 2 ( x x min ) 2 + τ 2 λ ( x max x ) + λ 2 ( x max x ) 2 + τ 2

    Here,λis the argumentlambda, 和τis the argumenttau. Note that for positive values ofτthe returned penalty value is always positive, because on the right side of the equation the magnitude of the second term is always greater than that of the first, and the magnitude of the fourth term is always greater than that of the third. Ifτis zero, then the returned penalty is zero inside the interval defined by the bounds, and it grows linearly withxoutside this interval. Ifxis multidimensional, then the calculation is applied independently on each dimension. Penalty functions are typically used to generate negative rewards when constraints are violated, such as ingenerateRewardFunction.

    Extended Capabilities

    C/C++ Code Generation
    Generate C and C++ code using MATLAB® Coder™.

    Version History

    Introduced in R2021b