System.out.println("Testing Amebsa");
// Test interface #1
double[] point=buildVector(4,3.5);
func_amebsa func_amebsa = new func_amebsa();
Amebsa amb1 = new Amebsa(point,del,func_amebsa,FTOL);
iter.val=1000;
temperature=100.0;
for (j=0;j<NMAX;j++) {
test=amb1.anneal(iter,temperature);
if (test) break;
else {
iter.val=1000;
temperature *= 0.8;
}
}
// System.out.printf(j);
// System.out.printf(iter);
// System.out.printf(abs(1.0-amb1.yb));
// System.out.printf(amb1.pb[0] << " " << amb1.pb[1] << " " << amb1.pb[2] << " " << amb1.pb[3]);
// System.out.printf(endl;
sbeps=1.e-8;
localflag = abs(1.0-amb1.yb) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** Amebsa, interface 1: Incorrect minimum function value");
}
sbeps=1.e-4;
localflag = false;
for (i=0;i<4;i++)
localflag = localflag || abs(amb1.pb[i]) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** Amebsa, interface 1: Did not converge to the global minumum at the origin");
}
// Test interface #2
Amebsa amb2 = new Amebsa(point,dels,func_amebsa,FTOL);
iter.val=1000;
temperature=100.0;
for (j=0;j<NMAX;j++) {
test=amb2.anneal(iter,temperature);
if (test) break;
else {
iter.val=1000;
temperature *= 0.8;
}
}
// System.out.printf(j);
// System.out.printf(iter);
// System.out.printf(amb2.yb);
// System.out.printf(amb2.pb[0] << " " << amb2.pb[1] << " " << amb2.pb[2] << " " << amb2.pb[3]);
// System.out.printf(endl;
sbeps=1.e-8;
localflag = abs(1.0-amb2.yb) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** Amebsa, interface 2: Incorrect minimum function value");
}
sbeps=1.e-4;
localflag = false;
for (i=0;i<4;i++)
localflag = localflag || abs(amb2.pb[i]) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** Amebsa, interface 2: Did not converge to the global minumum at the origin");
}
// Test interface #3
Amebsa amb3 =new Amebsa(p,func_amebsa,FTOL);
iter.val=1000;
temperature=100.0;
for (j=0;j<NMAX;j++) {
test=amb3.anneal(iter,temperature);
if (test) break;
else {
iter.val=1000;
temperature *= 0.8;
}