/*MultiCompassSearch.h 
  header file for a search based on the class PatternSearch.
  Derived from Class PatternSearch, the MultiCompassSearch is a multi-start version.
  This is, of course, MAPS compatable.
  Chris Siefert, College of William and Mary 6/23/00
*/

#ifndef _MultiCompassSearch_
#define _MultiCompassSearch_

#include "maps_general.h"
#include "CompassSearch.h"
#include "vec.h"

/** MultiCompassSearch is  based on the class CompassSearch, 
  derived from Class PatternSearch. the MultiCompassSearch is a multi-start version.
  This is, of course, MAPS compatable.
  Chris Siefert, College of William and Mary 6/23/00 
*/
class MultiCompassSearch: public CompassSearch
{

  public :

    /**@name Public Methods */
    //@{
  /**@name Constructors and Destructor */
  //@{

  /** Constructor for class MultiCompassSearch.
      after it calls its parent class constructor, it sets the
      following:
      \begin{itemize}
      \item[]random_start_pt=NULL
      \item[]NumSearches=1
      \item[]IterationCap=-1
      \item[]stream=0
      \end{itemize}
      @param numberOfVariables is the dimension of the problem
      @param startPoint is the starting point for the search
*/
  MultiCompassSearch(int numberOfVariables, Vector<double> & startPoint);

/**Another constructor.  This is equivalent to the CompassSearch
 constructor with the same signature.
*/  
  MultiCompassSearch(long dim,
                     Vector<double>& startPoint,
                     double startStep,
                     double stopStep,
                     void (*objective)(long vars, Vector<double>&x, double &
                                       func, bool & flag, void * an_obj),
                     void *input_obj);
  /** Destructor */
  ~MultiCompassSearch();

  //@} // constructors and destructor

  /**overloaded assignment operator */
  MultiCompassSearch& operator=(const MultiCompassSearch &A);

  /**@name Other public methods */
  //@{
  
  /**Resets the private fields. 
     INPUT: The number of different searches to run, the number of iterations
  to cap each search at, and the random stream number.
    @param NS the new number of searches
    @param IC the new iteration cap
    @param str is the new random number stream
    @param b is a reference to a struct containing the new bounds
    @return void */
  virtual void ResetParams(long NS, long IC, long str, const Bounds &b){
    NumSearches=NS;IterationCap=IC;stream=str;bds.lower=b.lower;bds.upper=b.upper;}
  
  /**This MultiStarts a bunch of CompassSearches, and reports the best result.
   @return void */
  void BeginSearch();
  //@} //other public methods
  //@} // public methods
  
protected:

  /**@name Protected fields */
  //@{
  /**The number of searches you want to do */
  long NumSearches;

  /** Your maximum number of allowed function calls for each search in the
   series.*/
  long IterationCap;
  
  /**the random number stream, for rngs */
  long stream;

  /** a random startig point */
  Vector<double> *random_start_pt;

  /** this is a struct of type Bounds.  See maps_general.h for declaration. */
  Bounds bds;

  //@} //protected fields
};//class MultiCompassSearch


#endif














