This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Simulated Annealing bug+bugfix
- From: Taliver Heath <taliver at paul dot rutgers dot edu>
- To: gsl-discuss at sources dot redhat dot com
- Date: Sat, 8 Jun 2002 03:51:32 -0400
- Subject: Simulated Annealing bug+bugfix
I'm using gsl-1.1.1, and I found a potential bug in the simulated annealing
algorithm. As the systems walks through states, it should always keep track
of the best state seen. This minor change accomplishes this.
43,44c43,44
< void *x, *new_x;
< double E, new_E;
---
> void *x, *new_x, *best_x;
> double E, new_E, best_E;
59a60
> best_x = copy_constructor(x0_p);
63a65,66
> best_x = (void *) malloc (element_size);
> memcpy (best_x, x0_p, element_size);
65a69,70
> best_E = Ef(best_x);
>
74a80
>
86a93,102
>
> if(new_E<best_E){
> if (copyfunc) {
> copyfunc(new_x,best_x);
> } else {
> memcpy (best_x, new_x, element_size);
> }
> best_E=new_E;
> }
>
136c152
< copyfunc(x, x0_p);
---
> copyfunc(best_x, x0_p);
138c154
< memcpy (x0_p, x, element_size);
---
> memcpy (x0_p, best_x, element_size);
I'm not on the mailing list, so if this is an old fix, I apologize.
--Tal Heath