Compute Penalty Function for Distance from Two Boundaries

  • Thread starter JasonBourne
  • Start date
  • Tags
    Function
In summary, the function produces a penalty value that increases rapidly as the distance from boundaries decreases and has a value of 1 for points on boundaries or on the origin.
  • #1
JasonBourne
3
0
Hello everyone,
I need your help desparately!

I need to figure out a penalty function that computes the penalty w.r.t distance of a point from two boundaries. The function produces a high penalty value if the point is closer to any of the two boundary and the penalty value decreases as the distance from boundaries increases. Two boundary can be viewed as distance from two axis.

Formulation:
Let x be the distance from Y axis and y be the distance from X axis, I need a penalty function

P = f(x,y) having above property

Thanks in advance.
Jason
 
Physics news on Phys.org
  • #2
Are you talking about a point inside a square that should be as far as possible away from the edges to get the minimum penalty? In that case, you could put the origin of your coordinate system at the center, and use a scale on the x and y-axis so that the corners are at (1,1), (1,-1), (-1,-1) and (-1,1). Then you can can set P=M(|x|+|y|)/2, where M is the maximum penalty. Or how about P=M(x2+y2)/2 ? This defines a penalty that's proportional to the distance from the center (so any two points on the same circle around the center gets the same penalty). If you want an option that's intermediate between these two, consider P=M(|x|s+|y|s)/2, where you choose an s from the interval (0,1), e.g. s=1/2, which gives you [tex]P=M(\sqrt{|x|}+\sqrt{|y|})[/tex]
 
  • #3
Thank Fredrik for your response, but a major issue about the problem which I think I didnt made that clear is that the point is bounded from 2 sides only. Other 2 sides are not bounded. Think of the point in any of the quadrant of a coordinate system where it is bounded by X and Y axis from two sides while other two sides are not bounded.

The function needs to max out after certain distance from the centre.


- Also smaller the distance from any of the boundary, larger the penalty value (i.e min of the two distances should have more effect on the penalty function). However I am more concerned about the above characteristics of the penalty function.
 
  • #4
There are two things you need to think about. The first is the shape of the curves on which every point is assigned the same penalty. The second is what penalty to assign to each of those curves. For the first problem, I suggest the curves y=k/x, where k is a constant. This restricts your penalty function to the form P(x,y)=f(xy). For the second problem, I need more information before I can suggest anything.

You should tell me something about what penalties you want to assign to points on the line y=x. Let r be the distance from the origin. Do you want a linear decrease from a maximum penalty to zero, or do you want the penalty to grow rapidly as r approaces zero? Do you want the penalty to be 0 above a certain value of r, or to decrease rapidly as r goes to infinity?
 
  • #5
Hello Fredrik,

Penalty on the curve closest to two boundaries will be higher and the penalty decreases rapidly as the curves move part from the two boundaries.

I want the penalty in the range [0-1]. Penalty value increases rapidly(exponentially) as the distance of the point from any of the two boundaries decreases and have value 1 for point on the boundary or on the origin. I want the penalty to decrease rapidly as r goes to infinity. it shouldn't be zero cause there is no such r value. As far as the penalty on the line y=x is concerned it will be directly proportional to r.
 
  • #6
JasonBourne said:
I want the penalty to decrease rapidly as r goes to infinity. [...] As far as the penalty on the line y=x is concerned it will be directly proportional to r.
Unfortunately these two contradict each other. ("Directly proportional to" would be P(r)=kr). Maybe you meant something like P(r)=1-r/d for r≤d and P(r)=0 for r>d, but it still contradicts the other thing you said.

I also realized that I made a mistake in my previous post. To have the penalty constant along curves of the form y=kx would make the penalty very small for some points that are very close to one of the axes (and far from the other). That's not what you want.

This makes it much more difficult to find a suitable function. P(r)=e-r does the job on the line y=x, but I can't think of a continuous function that's =1 everywhere on both axes and goes to zero when r goes to infinity. Is it necessary to have the penalty =1 at the origin? If it's OK to have the penalty =2 there, and close to 1 at points on either the x or the y-axis that's far from the origin, then P(x,y)=e-x+e-y would work. You can adjust how rapidly the function increases and decreases by puting another exponent on the variables: P(x,y)=e-xa+e-ya
 
Last edited:
  • #7
How about

[tex]p(x,y) = e^{-xy}[/tex]

? This is equal to 1 on either the x or y axis, and rapidly decreases to 0 as you get further away.
 
  • #8
Ben Niehoff said:
How about

[tex]p(x,y) = e^{-xy}[/tex]

? This is equal to 1 on either the x or y axis, and rapidly decreases to 0 as you get further away.
I tried to explain the problem with functions of that type in my previous post, but I made a mistake while typing. This is what I wrote:
Fredrik said:
To have the penalty constant along curves of the form y=kx would make the penalty very small for some points that are very close to one of the axes (and far from the other).
It should of course have been "constant along curves of the form y=k/x". This includes the choice P(x,y)=exp(-xy).

For example, if x=50 and y=1/10, the penalty is only 0.0025. I'm not sure if that's good or bad. JasonBourne, I suggest you try inserting a few values into this function to see if you get penalty scores you think are reasonable. You can also put a constant in the exponent, P(x,y)=exp(-kxy). This is equivalent to changing the units on the x and y axes.
 

FAQ: Compute Penalty Function for Distance from Two Boundaries

1. What is a penalty function for distance from two boundaries?

A penalty function for distance from two boundaries is a mathematical function that helps quantify the distance between a point and two given boundaries. It assigns a penalty value to a point based on its distance from the boundaries, with the penalty increasing as the point gets closer to the boundaries.

2. How is the penalty function calculated?

The penalty function is calculated by first determining the distance between the point and the two boundaries. This can be done using various metrics such as Euclidean distance or Manhattan distance. The distance is then used as an input for the penalty function, which outputs a penalty value based on the chosen function's formula or algorithm.

3. What is the purpose of using a penalty function for distance from two boundaries?

The purpose of using a penalty function for distance from two boundaries is to penalize points that are too close to the boundaries. This can be useful in various applications, such as optimizing a data clustering algorithm or finding the best placement for a new facility. The penalty function helps ensure that the resulting solution is not biased towards the boundaries and is more representative of the data.

4. Can a penalty function be applied to more than two boundaries?

Yes, a penalty function can be applied to more than two boundaries. The formula or algorithm for calculating the penalty value may need to be modified to account for multiple boundaries, but the concept remains the same. The function will assign a higher penalty to points that are closer to any of the boundaries.

5. How can the effectiveness of a penalty function be evaluated?

The effectiveness of a penalty function can be evaluated by comparing the results with and without the use of the function. If the function helps improve the accuracy or efficiency of the solution, then it can be considered effective. Additionally, the choice of the penalty function and its parameters can also be adjusted to see which combination yields the best results.

Similar threads

Back
Top