#include <cassert>
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;



#include <print.h>
#include <commandline.h>

#include <probsysequ01.h>
#include <exploreh.h>

#include <lineoptimizergold2.h>



//#include <powell02.h>
#include <powelltest.h>
#include <linepathd1.h>


//static double h0step=0.2;

void powelltest01(int argc, char** argv)
{
/*

  cout << "explore and golden ratio line search" << endl;
  cout << "  k=3 lineiter=10 are defaults." << endl;

  typedef exploreh<probsysequ01,double*,double> exp2;
  typedef linepathd1< probsysequ01,double*,double*,double > lnpath;
  typedef lineoptimizergold2< lnpath, double > lnmin;


  commandline cmd(argc,argv);
  uint lineiter(10);
  cmd.mapvar(lineiter,"lineiter");
  uint k(3);
  cmd.mapvar(k,"k");

  powell02< exp2, lnmin > w(2,lineiter,h0step);

  cmd.mapvar(w.linet0,"t0");
  cmd.mapvar(w.linet1,"t1");

  cout << SHOW( w.exp.fn.counter) << endl;

  double x0[2] = { 0.5, 0.5 };
  w.reset(x0);


  cout << SHOW( w.exp.fn.counter) << endl;

  for (uint i=0; i<k; ++i)
  {
//cout << printvecfunc(w.xi,2) << endl;
//cout << SHOW(w.exp.fmin) << endl;
    ++w;
//    cout << SHOW(w.fn.counter) << endl;
  }

  double * xi  = w.xi0[0];

  long double y0((long double)0.2);
  long double y1((long double)2.0/(long double)3.0);
  long double dist = (y0-xi[0])*(y0-xi[0]) + (y1-xi[1])*(y1-xi[1]);

  cout << "Compare with true solution" << endl;
  cout << "fn count, k, lineiter, distance" << endl;
  cout << w.exp.fn.counter << "  ";
  cout << k << "  ";
  cout << lineiter << "  ";
  cout << scientific << dist << endl;
  cout << SHOW(w.exp.fmin) << endl;
*/

}

void powelltest02(int argc, char** argv)
{

}




