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

Problem with cumulation for covariance matrix (pc) using B*D*z~N(0,C) #18

Open
AntoineMazuyer opened this issue Jan 24, 2018 · 2 comments

Comments

@AntoineMazuyer
Copy link
Contributor

AntoineMazuyer commented Jan 24, 2018

Hello,

I use CMAES and its C implementation to deal with stress inversion.
When my problem is very ill conditionned, I have a floating point exception in cmaes.c at line 893/894

/* cumulation for covariance matrix (pc) using B*D*z~N(0,C) */                                                                                                                                      
 hsig = sqrt(psxps) / sqrt(1. - pow(1.-t->sp.cs, 2*t->gen)) / t->chiN 
  < 1.4 + 2./(N+1); 

its with the "pow" function, t->gen = 752 and 1.-t->sp.cs = 0.62435950746181024, so the result must be really close to 0....

Have you got an idea how to avoid this kind of problens, moreover, it has begin to converge !!

screenshot from 2018-01-24 15-17-55

Cheers,

Antoine

@AntoineMazuyer
Copy link
Contributor Author

AntoineMazuyer commented Jan 28, 2018

I have managed to solve the problem by using a "custom pow" function that avoid small values:

static double custom_pow(double a, double b)
{
  double i = log(a);
  if ( b*i < -10) return 0;
  return exp(b * i);
}

@nikohansen
Copy link
Contributor

nikohansen commented Jan 30, 2018

This must be a machine dependent problem, as t->gen becomes always large. Your solution seems spot on. I would guess it should also be possible to configure the compiler to ignore numerical underflow errors, which is relatively safe to do.

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

2 participants