Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I think something is wrong with penaltyBoundToInterval and penaltyBoundToIntervalDerivative #400

Open
charon-cheung opened this issue Feb 6, 2023 · 0 comments

Comments

@charon-cheung
Copy link

charon-cheung commented Feb 6, 2023

The function is for bounding \c var to the interval -a < var < a , but the code is

  if (var < -a+epsilon)
  {
    return (-var - (a - epsilon));
  }
  if (var <= a-epsilon)
  {
    return 0.;
  }
  else
  {
    return (var - (a - epsilon));
  }

inline double penaltyBoundToIntervalDerivative(const double& var,const double& a, const double& epsilon)
{
  if (var < -a+epsilon)
  {
    return -1;
  }
  if (var <= a-epsilon)
  {
    return 0.;
  }
  else
  {
    return 1;		
  }
}

I think it should be if (var >= a-epsilon), the other overload funtion has the same problem

@charon-cheung charon-cheung changed the title I think something is wrong with penaltyBoundToInterval I think something is wrong with penaltyBoundToInterval and penaltyBoundToIntervalDerivative Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant