/******************************************************************************
* NOMAD -  Nonlinear Optimization for Mixed vAriables and Derivatives.        *
* Copyright (C) 2001-2004  Gilles Couture - Ecole Polytechnique,              *
*                          Charles Audet - Ecole Polytechnique,               *
*		           John Dennis - Rice University.                     *
*                                                                             *
* Author: Gilles Couture                                                      *
* École Polytechnique de Montréal - GERAD                                     *
* C.P. 6079, Succ. Centre-ville, Montréal (Québec) H3C 3A7 Canada             *
* Tel:  (514) 340-6053 x6928                                                  *
* Email: Gilles.Couture@gerad.ca                                              *
* Fax: (514) 340-5665                                                         *
*                                                                             *
* This program is free software; you can redistribute it and/or               *
* modify it under the terms of the GNU General Public License                 *
* as published by the Free Software Foundation. You can find the              *
* GNU General Public License at:                                              *
*             http://www.gnu.org/copyleft/gpl.html                            *
*                                                                             *
* This program is distributed in the hope that it will be useful,             *
* but WITHOUT ANY WARRANTY; without even the implied warranty of              *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
* GNU General Public License for more details.                                *
*                                                                             *
* You should have received a copy of the GNU General Public License           *
* along with this program; if not, write to the Free Software                 *
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. *
*                                                                             *
* You can find information on the NOMAD software at:                          *
*             http://www.gerad.ca/NOMAD/                                      *
******************************************************************************/

// searcher.h -- class definition for Searcher, which is an abstract base class
// for all search strategy subclasses (like RandomSearcher).

#ifndef _SEARCHER_H_
#define _SEARCHER_H_
#include <fstream>
#include <vector>
using namespace std;
#include "augmentedpoint.h"
#include "description.h"
#include "evaluator.h"
#include "parameters.h"

class Searcher
{
  // The Searcher object has the following variables:
  // - "display_factor" is used for debugging purposes.
 protected:
  bool initial;
  int display_factor;
  const Description * const description;
  Evaluator * evaluator;
  const Parameters * const parameters;

 public:
  Searcher(const bool init, const Description * const des, Evaluator * eval,
	   const Parameters * const par)
    : initial(init), description(des), evaluator(eval), parameters(par)
    {display_factor = 0;}
  virtual ~Searcher() {}
  // 'search(...)' is a pure virtual function. It receives these parameters:
  // - The current mesh size, "delta".
  // - The current best point, "poll_center".
  // - The address of a list of points. The list is empty at the start, every
  //   point generated by the search is added to this list.
  virtual int search(const double delta, const double * poll_center,
		     const double * lower, const double * upper,
		     const int sent_from,
		     std::vector<AugmentedPoint *> & list_of_points,
		     int & term_flag, ofstream & fout, ofstream & fgraph,
		     ofstream & history) = 0;
  virtual void update(const double delta, std::vector<double> & dir,
		      const AugmentedPoint * new_incumbent) = 0;

  // Inline methods.
  // ---------------

  // This method resets the display factor.
  void setDisplay(const int display) {display_factor = display;}
};
#endif
