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

// augmentedpoint.h -- class definition for AugmentedPoint. This class defines
// all the points generated by NOMAD.

#ifndef _AUGMENTEDPOINT_H_
#define _AUGMENTEDPOINT_H_

class Point;

class AugmentedPoint
{
  // An AugmentedPoint object has the following attributes:

  // - A real number, Hx is the feasibility function value of the point.
  //   Feasible points have an Hx of 0, unfeasible points have an Hx > 0.

  // - An array of real numbers, 'output_values', contains the values of the
  //   outputs of the point.

  // - An enumeration, indicating the possible index values stored in the
  //   'index' array:
  //   'Fx' is for f(x): one f(x) is stored in every problem.
  //   'Sx' is for the surrogate function value, s(x). There can be zero or
  //   one (if the problem uses a surrogate) s(x) value stored in a problem.
  //   'Gx' is for the general constraints function values, gi(x). There can be
  //   zero, one or many gi(x) values stored in a problem.

  // - A static integer variable, 'output_dimension' contains the number of
  //   outputs for all the augmented points in the run.

  // - A static integer array, 'index', describes what kind of outputs are
  //   stored in the 'output_values' array for all augmented points.

  // - A pointer to a Point object.

 private:
  double Hx;
  double * output_values;
  enum {Fx, Sx, Gx};
  static int output_dimension;
  static const int * index;
  Point * p;

  // The class methods are described in "augmentedpoint.cpp"
 public:
  AugmentedPoint(const int dim, const int out, const int * out_index,
		 const double * coord, const double * scales_add,
		 const double * scales_mult);
  AugmentedPoint(const int dim, const double * coord);
  AugmentedPoint(const AugmentedPoint & ap);
  ~AugmentedPoint();
  AugmentedPoint & operator=(const AugmentedPoint & ap);
  double getLow() const;
  double * getPoint() const;
  int getDimension() const;
  int getPosition(const int val) const;
  void complete(const double * outputs);
  void setGxValues(const double * g_x, const int gen_cons_nb);
  void setLow(const double val);
  void showHistory(ofstream & fout, const double * scales_add,
		   const double * scales_mult) const;
  void showResults(ofstream & fout, const double * scales_add,
		   const double * scales_mult) const;

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

  friend ostream & operator<<(ostream & os, const AugmentedPoint & ap);

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

	// This method returns the point's objective function value - f(x).
	double getFx() const {return output_values[0];}
  // This method returns the point's h(x) value.
  double getHx() const {return Hx;}
  // This method returns an output value, as specified by 'n'.
  double getOutput(const int n) const {return output_values[n];}
  // This method returns the point's outputs.
  double * getOutputValues() const {return output_values;}
  // The variable 'Hx' is set to the received parameter.
  void setHx(const double val) {Hx = val;}
  // This method sets the 'n'th output value to 'val'.
  void setOutput(const int n, const double val) {output_values[n] = val;}
};
#endif
