load "./lgbmo"
int n=2;
real[int] X(n),DX(n);
real[int] X0(n);
for(int i=0;i<n;++i) X0[i]=0.5;

func real J(real[int] & x)
{
  real s=n;
  x -= X0;
  for (int i=0;i<x.n;i++)
    s +=(x[i]*x[i]-cos(18.*x[i]));
  //cout << " J " << s << "       .... " << x[0] << " " << x[1] << endl;
  return s;
}

func real[int] DJ(real[int] &x)
{
  x -= X0; 
  for (int i=0;i<x.n;i++)
    x[i]=2*x[i]+18*sin(18*x[i]);
  //cout << " dJ "  << "       .... " << x[0] << " " << x[1] << endl;
  return x;  // return of global variable ok 
};

for(int i=0;i<n;++i)
  X[i]=abs(sin((i+1)/(n*2.)));
verbosity=9;

//  buggus.. 
 
real  mm=0;// bmo(J,DJ,X,min=-10,max=10);
cout << " min = " << mm << endl;

cout << " x = " << X << endl;
cout << " X0 = " << X0 << endl;

