/* 
   main.cc
   example PatternSearch main program
   Liz Dolan, 1999 at
   The College of William and Mary, Williamsburg, Virginia,
   under advisor Dr. Virginia Torczon   
   
   to compile use:
   g++ main.cc objective.cc PatternSearch.cc CoordinateSearch.cc CompassSearch.cc NLessSearch.cc HJSearch.cc EdHJSearch.cc -lm -o pds

   if you get obnoxious warning messages:^)
   g++ -w main.cc objective.cc PatternSearch.cc CoordinateSearch.cc CompassSearch.cc NLessSearch.cc HJSearch.cc EdHJSearch.cc -lm -o pds

*/

#include "objective.h"     //contains function, initial point, n, starting step etc.
#include "CompassSearch.h" 
#include "NLessSearch.h"
#include "HJSearch.h"
#include "EdHJSearch.h"
#include "CoordinateSearch.h"
#include <iostream.h>
  
int main(void)
{
  
  HJSearch HJsearcher(n);
  Vector<double> HJminimum(n);
  EdHJSearch EdHJsearcher(n);
  Vector<double> Edminimum(n);
  CompassSearch Csearcher(n);
  Vector<double> Cminimum(n);
  CoordinateSearch Coorsearcher(n);
  Vector<double> Coorminimum(n);
  NLessSearch Nsearcher(n);
  Vector<double> Nminimum(n);

  double HJMinimum, EdMinimum, NMinimum, CMinimum, CoorMinimum;
  int HJcalls, Edcalls, Ncalls, Ccalls, Coorcalls;
  double step;

  cout << "initial step length: " << getInitialStep() << endl;
  HJsearcher.ExploratoryMoves();
  HJsearcher.GetMinPoint(HJminimum);
  HJsearcher.GetMinVal(HJMinimum);
  HJcalls = HJsearcher.GetFunctionCalls();
  step = HJsearcher.GetStepLength();
  cout << "HJ, Point: \n" << HJminimum << endl;
  cout << "Value: \n" << HJMinimum << endl;
  cout << "Last used step length: " << step * 2 << " in " << HJcalls << " function calls.\n";

  EdHJsearcher.ExploratoryMoves();
  EdHJsearcher.GetMinPoint(Edminimum);
  EdHJsearcher.GetMinVal(EdMinimum);
  Edcalls = EdHJsearcher.GetFunctionCalls();
  step = EdHJsearcher.GetStepLength();
  cout << "EdHJ, Point: \n" << Edminimum << endl;
  cout << "Value: \n" << EdMinimum << endl;
  cout << "Last used step length: " << step * 2 << " in " << Edcalls << " function calls.\n";
     
  Nsearcher.ExploratoryMoves();
  Nsearcher.GetMinPoint(Nminimum);
  Nsearcher.GetMinVal(NMinimum);
  Ncalls = Nsearcher.GetFunctionCalls();
  step = Nsearcher.GetStepLength();
  cout << "NLess, Point: \n" << Nminimum << endl;
  cout << "Value: \n" << NMinimum << endl;
  cout << "Last used step length: " << step * 2 << " in " << Ncalls << " function calls.\n";

  Coorsearcher.ExploratoryMoves();
  Coorsearcher.GetMinPoint(Coorminimum);
  Coorsearcher.GetMinVal(CoorMinimum);
  Coorcalls = Coorsearcher.GetFunctionCalls();
  step = Coorsearcher.GetStepLength();
  cout << "Coordinate, Point: \n" << Coorminimum << endl;
  cout << "Value: \n" << CoorMinimum << endl;
  cout << "Last used step length: " << step * 2 << " in " << Coorcalls << " function calls.\n";

  Csearcher.ExploratoryMoves();
  Csearcher.GetMinPoint(Cminimum);
  Csearcher.GetMinVal(CMinimum);
  Ccalls = Csearcher.GetFunctionCalls();
  step = Csearcher.GetStepLength();
  cout << "Compass, Point: \n" << Cminimum << endl;
  cout << "Value: \n" << CMinimum << endl;
  cout << "Last used step length: " << step * 2 << " in " << Ccalls << " function calls.\n";

return 0;

}//main



