main content

hyperbolic penalty value for a point with respect to a bounded region -凯发k8网页登录

hyperbolic penalty value for a point with respect to a bounded region

since r2021b

description

example

p = hyperbolicpenalty(x,xmin,xmax) calculates the nonnegative (hyperbolic) penalty vector p for the point x with respect to the region bounded by xmin and xmax. p has the same dimension as x. this syntax uses the default values of 1 and 0.1 for the lambda and tau parameters of the hyperbolic function, respectively.

example

p = hyperbolicpenalty(___,lambda,tau) specifies both the lambda and tau parameters of the hyperbolic function. if lambda is an empty matrix its default value is used. likewise if tau is an empty matrix or it is omitted, its default value is used instead.

examples

this example shows how to use the hyperbolicpenalty function to calculate the hyperbolic penalty for a given point with respect to a bounded region.

calculate the penalty value for the point 0.1 within the interval [-2,2], using default values for the lambda and tau parameters.

hyperbolicpenalty(0.1,-2,2)
ans = 0.0050

calculate the penalty value for the point 4 outside the interval [-2,2].

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

calculate the penalty value for the point 0.1 within the interval [-2,2], using a lambda parameter of 5.

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

calculate the penalty value for the point 4 outside the interval [-2,2], using a lambda parameter of 5.

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

calculate the penalty value for the point 4 outside the interval [-2,2], using a tau parameter of 0.5.

hyperbolicpenalty(4,-2,2,5,0.5)
ans = 20.0167

calculate the penalty value for the point [-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 for lambda and a tau parameter of 0.

hyperbolicpenalty([-2 0 4],[0 -1 -2],[1 1 2],1,0)
ans = 3×1
     4
     0
     4

visualize penalty values for an interval

create a vector of 1001 equidistant points distributed between -5 and 5.

x = -5:0.01:5;

calculate penalties for all the points in the vector, using default values for the lambda and tau parameters.

p = hyperbolicpenalty(x,-2,2);

plot the points and add grid, labels and title.

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

figure contains an axes object. the axes object with title penalty values over an interval, xlabel point position, ylabel penalty value contains an object of type line.

input arguments

point for which the penalty is calculated, specified as a numeric scalar, vector or matrix.

example: [0.5; 1.6]

lower bounds for x, specified as a numeric scalar, vector or matrix. to use the same minimum value for all elements in x specify xmin as a scalar.

example: -1

upper bounds for x, specified as a numeric scalar, vector or matrix. to use the same maximum value for all elements in x specify xmax as a scalar.

example: 2

lambda parameter of the hyperbolic function, specified as a scalar.

example: 3

tau parameter of the hyperbolic function, specified as a scalar.

example: 0.3

output arguments

penalty value, returned as a vector of nonnegative elements. each element pi depends on the position of xi with respect to the interval specified by xmini and xmaxi. the hyperbolic penalty function returns the value:

p(x)=λ(xxmin) λ2(xxmin)2 τ2λ(xmaxx) λ2(xmaxx)2 τ2

here, λ is the argument lambda, and τ is the argument tau. 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 with x outside this interval. if x is 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 in generaterewardfunction.

extended capabilities

c/c code generation
generate c and c code using matlab® coder™.

version history

introduced in r2021b

网站地图