/* 
   main_default.cc
   example main program using an SMDSearch.
   
   Liz Dolan, 1999 and Anne Shepherd, 8/2000 at
   The College of William and Mary, Williamsburg, Virginia,
   under advisor Dr. Virginia Torczon   
   
   to compile use:
   g++ -g -Wall main_default.cc objective.cc DirectSearch.cc SimplexSearch.cc SMDSearch.cc -lm -o main_default

*/

#include "objective.h"    
#include "SMDSearch.h" 
#include <iostream>              // for cout

using namespace std;

int main(void)
{    
  long n = 1;                      // number of variables (dimension of
                                   //                      the search)
  double startVal = 0.0;           // starting point for x
  
  Vector<double> Sminimum(n);      // to store the minimum point later

  /* we'll initialize a one-entry Vector whose value is startVal,
   * and use it as our starting point.
   */
  Vector<double>minVec(n, startVal);

  /* now construct an SMDSearch object */
  SMDSearch SMD(n, minVec);

  double SMinVal;
  long Scalls;
  
  /* start searching */
  SMD.BeginSearch();

  /* recover information about the search */
  SMD.GetMinPoint(Sminimum);
  SMD.GetMinVal(SMinVal);
  Scalls = SMD.GetFunctionCalls();
  
  cout << "\nMinimum point found: \n" << Sminimum;
  cout << "\nValue: \n" << SMinVal <<  " in ";
  cout << Scalls << " function calls.\n" << endl<< "\n\n";

  return 0;

}//main



