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

// description.h -- class definition for Description.

#ifndef DESCRIPTION_H
#define DESCRIPTION_H

class Description
{
private:
  // Some boolean variables.
  bool black_box_use, bounds_use, cache_use, surrogate_use;
  // These strings are file names for the various components of NOMAD.
  char * cache, * constraints, * directory, * general_constraints, * input,
    * name, * problem_file, * results, * scales, * start_pt_file, * surrogate,
    * truth;
  // These real variables hold the user's choices for lower and upper bounds
  // (used for scaling).
  double lower, upper;
  // There are five real arrays: The starting point, the lower bounds, the
  // upper bounds and the scaling vectors.
  double * lower_bounds, * scales_add, * scales_mult, * starting_point,
    * upper_bounds;
  // Some integer variables.
  int dimension, general_constraints_number, output_dimension, scaling_choice;
  int * output_index;

  // These class methods are described in "description.cpp".
  bool checkStartingPoint();
  void automaticScalingNoBounds();
  void automaticScalingWithBounds();
  void boundScaling();
  void buildOutputIndex();
  void buildScales();
  void captureArrays();
  void fillArray(ifstream & fin, double * coord);
  void freeArrays();
  void readProblemFile(ifstream & fin);
  void showScales(ofstream & fout) const;

public:
  Description(const char * file = NULL);
  ~Description();
  bool buildArrays();
  bool readyToSolve();
  void enterBlackBoxes(const bool black_box, const char * truth_exec,
		       const char * general, const char * surr_exec);
  void enterConstraints(const bool bounds, const char * bounds_file,
			const int gen_cons_nbr);
  void enterFiles(const char * dir, const char * in, const char * res);
  void enterOptions(const bool cache_usage, const char * cache_file,
		    const bool surr_use);
  void enterProblem(const char * prob_name, const int dim,
		    const char * start_pt);
  void enterScales(const int index, const char * scales_file, const double low,
		   const double up);
  void loadProblemFile(const char * file);
  void setProblemFile(const char * file);
  void write() const;

  // Non-member functions.
  // ---------------------

  friend ostream & operator<<(ostream & os, const Description & des);

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

  // This method returns the boolean variable 'black_box_use'.
  bool getBlackBoxUse() const {return black_box_use;}
  // This method returns the boolean variable 'bounds_use'.
  bool getBoundsUse() const {return bounds_use;}
  // This method returns the boolean variable 'cache_use'.
  bool getCacheUse() const {return cache_use;}
  // This method returns the boolean variable 'surrogate_use'.
  bool getSurrogateUse() const {return surrogate_use;}
  // This method returns the path of the permanent cache.
  char * getCache() const {return cache;}
  // This method returns the path of the constraints file.
  char * getConstraints() const {return constraints;}
  // This method returns the problem directory.
  char * getDirectory() const {return directory;}
  // This method returns the paths of the general constraints' black boxes.
  char * getGeneralConstraints() const {return general_constraints;}
  // This method returns the path of the input file.
  char * getInput() const {return input;}
  // This method returns the problem name.
  char * getName() const {return name;}
  // This method returns the path of the problem file.
  char * getProblemFile() const {return problem_file;}
  // This method returns the path of the results file.
  char * getResultsFile() const {return results;}
  // This method returns the path of the scales file.
  char * getScales() const {return scales;}
  // This method returns the path of the starting point file.
  char * getStartingPointFile() const {return start_pt_file;}
  // This method returns the path of the surrogate black box.
  char * getSurrogate() const {return surrogate;}
  // This method returns the path of the objective function (truth) black box.
  char * getTruth() const {return truth;}
  // This method returns a pointer to 'this' object.
  Description * getPtr() {return this;}
  // This method returns the lower scaling bound.
  double getLowScale() const {return lower;}
  // This method returns the upper scaling bound.
  double getUpScale() const {return upper;}
  // This method returns a pointer to the lower bounds.
  double * getLowerBounds() const {return lower_bounds;}
  // This method returns a pointer to the scales addition array.
  double * getScalesAdd() const {return scales_add;}
  // This method returns a pointer to the scales multiplication array.
  double * getScalesMult() const {return scales_mult;}
  // This method returns a pointer to the starting point.
  double * getStartingPoint() const {return starting_point;}
  // This method returns a pointer to the upper bounds.
  double * getUpperBounds() const {return upper_bounds;}
  // This method returns the problem dimension.
  int getDimension() const {return dimension;}
  // This method returns the number of general constraints.
  int getGeneralConstraintsNumber() const
    {return general_constraints_number;}
  // This method returns the output dimension.
  int getOutputDimension() const {return output_dimension;}
  // This method returns the scaling choice.
  int getScalingChoice() const {return scaling_choice;}
  // This method returns a pointer to the output index array.
  int * getOutputIndex() const {return output_index;}
};
#endif
