/******************************************************************************
* 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/                                      *
******************************************************************************/

// parameters.h -- class definition for Parameters.

#ifndef PARAMETERS_H
#define PARAMETERS_H

class Parameters
{
private:
  // Boolean variables.
  bool filter_relative, initial_complete, iterative_complete, poll_complete,
    poll_order, speculative_search;
  // The path of the parameters file.
  char * parameters_file;
  // Real number (double) variables.
  double hmax, hmin, max_poll_size, poll_basis, frame_center_trigger,
		poll_size, poll_size_term, surrogate_tolerance;
  // Integer variables.
  int coarsening_exponent, consecutive_fails, filter_norm, initial,
    initial_points, iterations, iterative, iterative_points, new_truth_evals,
    poll_directions, random_seed, refining_exponent, secondary_polldirs,
    truth_evals;

  // These methods are described in "parameters.cpp".
  void readParameterFile(ifstream & fin);

public:
  Parameters(const char * file);
  ~Parameters();
  bool readyToSolve() const;
  void enterMesh(const double delta_p, const double basis,
		 const double max_delta_p, const int coarsen,
		 const int refine);
  void enterPoll(bool fixed, const bool complete, int choice,
		 const int secondary);
	void enterProgressiveBarrier(const bool choice, const double h_max,
			 const double h_min, const double trigger, const int norm);
  void enterRandomSeed(const int seed);
  void enterSearch(const int ini_type, const bool ini_complete,
		   const int ini_pts, const int iter_type,
		   const bool iter_complete, const int iter_pts,
		   const bool speculative);
  void enterSurrogate(const double surr_tol);
  void enterTerminationCriteria(const double poll_size_criterion,
				const int consecutive_failures,
				const int truth_evaluations,
				const int iter_number,
				const int new_truth_evaluations);
  void load(const char * file);
  void setFile(const char * file);
  void show(ostream & fout, const bool filter_use,
	    const bool surrogate_use) const;
  void write() const;

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

  // Returns true if 'hmax' is relative to the starting point's h(x) value.
  bool getFilterRelative() const {return filter_relative;}
  // Returns true if the initial search is complete.
  bool getInitialComplete() const {return initial_complete;}
  // Returns true if the iterative search is complete.
  bool getIterativeComplete() const {return iterative_complete;}
  // This return value indicates if a speculative search should be performed or
  // not.
  bool getSpeculativeSearch() const {return speculative_search;}
  // Returns the parameter file address.
  char * getFile() const {return parameters_file;}
	// Returns the value of 'hmax'.
  double getHmax() const {return hmax;}
  // Returns the value of 'hmin'.
  double getHmin() const {return hmin;}
  // Returns the value of the maximum poll size.
  double getMaxPollSize() const {return max_poll_size;}
  // Returns the poll basis value.
  double getPollBasis() const {return poll_basis;}
  // Returns the poll center trigger value.
  double getFrameCenterTrigger() const {return frame_center_trigger;}
  // Returns the poll size.
  double getPollSize() const {return poll_size;}
  // Returns the poll size termination criterion.
  double getPollSizeTerm() const {return poll_size_term;}
  // Returns the surrogate tolerance factor.
  double getSurrogateTolerance() const {return surrogate_tolerance;}
  // Returns the coarsening exponent.
  int getCoarsen() const {return coarsening_exponent;}
  // Returns the consecutive failures termination criterion.
  int getConsecutiveFails() const {return consecutive_fails;}
  // Returns the filter norm.
  int getFilterNorm() const {return filter_norm;}
  // Returns the number of points to generate in the initial search.
  int getInitialPoints() const {return initial_points;}
  // Returns the initial search type.
  int getInitialSearch() const {return initial;}
  // Returns the number of points to generate in the iterative search.
  int getIterativePoints() const {return iterative_points;}
  // Returns the iterative search type.
  int getIterativeSearch() const {return iterative;}
  // Returns the iterations termination criterion.
  int getMaxIterations() const {return iterations;}
  // Returns the new truth evaluations termination criterion.
  int getNewTruthEvals() const {return new_truth_evals;}
  // Returns the poll directions choice.
  int getPollDirs() const {return poll_directions;}
  // Returns the poll order.
  int getPollOrder() const {return poll_order;}
  // Returns the poll type.
  int getPollType() const {return poll_complete;}
  // Returns the refining exponent.
  int getRefine() const {return refining_exponent;}
  // Returns the random seed.
  int getSeed() const {return random_seed;}
  // Returns the number of secondary poll directions.
  int getSecondaryPollDirs() const {return secondary_polldirs;}
  // Returns the truth evaluations termination criterion.
  int getTruthEvals() const {return truth_evals;}
  // This method returns a pointer to 'this' object.
  Parameters * getPtr() {return this;}
};
#endif
