This example shows how to use the logarithmic barrierPenalty
function to calculate the barrier 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 maximum value and curvature parameters.
Calculate the penalty value for the point 4
outside the interval [-2
,2
].
Calculate the penalty value for the point 4
outside the interval [-2
,2
], using a maximum value parameter of 5
.
Calculate the penalty value for the point 0.1 inside the interval [-2
,2
], using a curvature parameter of 0.5
.
Calculate the penalty value for the point [-2
,0
,4
] with respect to the box defined by [0
,1
], [-1
,1
], and [-2
,2
] along the x, y, and z dimensions, respectively, using the default value for maximum value and a curvature parameter of 0
.
Visualize Penalty Values for an Interval
Create a vector of 1001 equidistant points distributed between -5
and 5
.
Calculate penalties for all the points in the vector, using the default value for the maximum value parameter and a value of 0.01
for the curvature parameter.
Plot the points and add grid, labels and title.